diff options
author | Robert Helgesson <robert@rycee.net> | 2018-01-04 12:21:06 +0100 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2018-01-07 16:59:22 +0100 |
commit | 58a629b02e46b76ef55c0fd7e4fa998cb87cad91 (patch) | |
tree | d8de8eaf1250b3fc14fb2c75905aa1efae2e73c2 /modules/lib/shell.nix | |
parent | df6590abfc650d23532ef097892f61ba6d203c5f (diff) |
lib/shell: add library of convenience functions
This library holds a few convenience functions for generating shell
code.
Diffstat (limited to 'modules/lib/shell.nix')
-rw-r--r-- | modules/lib/shell.nix | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/lib/shell.nix b/modules/lib/shell.nix new file mode 100644 index 00000000000..f1443c5466a --- /dev/null +++ b/modules/lib/shell.nix @@ -0,0 +1,11 @@ +{ lib }: + +rec { + # Produces a Bourne shell like variable export statement. + export = n: v: "export ${n}=\"${toString v}\""; + + # Given an attribute set containing shell variable names and their + # assignment, this function produces a string containing an export + # statement for each set entry. + exportAll = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList export vars); +} |