fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #1006115e76ae

master
1013 B30 linesraw
1{ lib }:
2
3rec {
4  # Produces a Zsh shell like value
5  toZshValue = v:
6    if builtins.isBool v then
7      if v then "true" else "false"
8    else if builtins.isString v then
9      ''"${v}"''
10    else if builtins.isList v then
11      "(${lib.concatStringsSep " " (map toZshValue v)})"
12    else
13      ''"${toString v}"'';
14
15  # Produces a Zsh shell like definition statement
16  define = 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.
21  defineAll = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList define vars);
22
23  # Produces a Zsh shell like export statement
24  export = 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.
29  exportAll = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList export vars);
30}