diff --git a/modules/lib/default.nix b/modules/lib/default.nix index 5c273f15..8291be0b 100644 --- a/modules/lib/default.nix +++ b/modules/lib/default.nix @@ -15,4 +15,6 @@ entryAfter = d.dagEntryAfter; entryBefore = d.dagEntryBefore; }; + + shell = import ./shell.nix { inherit lib; }; } diff --git a/modules/lib/shell.nix b/modules/lib/shell.nix new file mode 100644 index 00000000..f1443c54 --- /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); +}