1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-27 17:08:31 +02:00

lib/shell: add library of convenience functions

This library holds a few convenience functions for generating shell
code.
This commit is contained in:
Robert Helgesson 2018-01-04 12:21:06 +01:00
parent df6590abfc
commit 58a629b02e
No known key found for this signature in database
GPG Key ID: C3DB11069E65DC86
2 changed files with 13 additions and 0 deletions

View File

@ -15,4 +15,6 @@
entryAfter = d.dagEntryAfter;
entryBefore = d.dagEntryBefore;
};
shell = import ./shell.nix { inherit lib; };
}

11
modules/lib/shell.nix Normal file
View 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);
}