lib/shell: add library of convenience functions
This library holds a few convenience functions for generating shell code.
This commit is contained in:
parent
df6590abfc
commit
58a629b02e
|
@ -15,4 +15,6 @@
|
|||
entryAfter = d.dagEntryAfter;
|
||||
entryBefore = d.dagEntryBefore;
|
||||
};
|
||||
|
||||
shell = import ./shell.nix { inherit lib; };
|
||||
}
|
||||
|
|
11
modules/lib/shell.nix
Normal file
11
modules/lib/shell.nix
Normal file
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue