fork/home-manager
git clone https://git.julia.blue/fork/home-manager
115e76ae
master
1{ lib } : 2 3rec { 4# Produces a Zsh shell like value 5toZshValue = v : 6if builtins . isBool v then 7if v then "true" else "false" 8else if builtins . isString v then 9''" ${ v } "'' 10else if builtins . isList v then 11"( ${ lib . concatStringsSep " " ( map toZshValue v )} )" 12else 13''" ${ toString v } "'' ; 14 15# Produces a Zsh shell like definition statement 16define = n :v :" ${ n } = ${ toZshValue v } " ; 17 18# Given an attribute set containing shell variable names and their 19# assignments, this function produces a string containing a definition 20# statement for each set entry. 21defineAll = vars :lib . concatStringsSep "\n" ( lib . mapAttrsToList define vars ); 22 23# Produces a Zsh shell like export statement 24export = n :v :"export ${ define n v } " ; 25 26# Given an attribute set containing shell variable names and their 27# assignments, this function produces a string containing an export 28# statement for each set entry. 29exportAll = vars :lib . concatStringsSep "\n" ( lib . mapAttrsToList export vars ); 30}