summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2016-10-19 23:25:15 +0200
committerDaiderd Jordan <daiderd@gmail.com>2016-10-19 23:31:43 +0200
commitce690db770d88decba4d279b05a4ef2af7a67204 (patch)
treee7aa690d809d6960f3c278e71363abdef8b2e668 /modules
parent491e06ab15c46c04d1f0f5a73049a5d51964ef19 (diff)
added support for environment.variables
Diffstat (limited to 'modules')
-rw-r--r--modules/environment.nix24
1 files changed, 24 insertions, 0 deletions
diff --git a/modules/environment.nix b/modules/environment.nix
index 68c5677..ace1b1c 100644
--- a/modules/environment.nix
+++ b/modules/environment.nix
@@ -6,6 +6,12 @@ let
cfg = config.environment;
+ exportVariables =
+ mapAttrsToList (n: v: ''export ${n}="${v}"'') cfg.variables;
+
+ exportedEnvVars =
+ concatStringsSep "\n" exportVariables;
+
in {
options = {
@@ -31,10 +37,28 @@ in {
description = "List of additional package outputs to be symlinked into <filename>/run/current-system/sw</filename>.";
};
+ environment.variables = mkOption {
+ default = {};
+ description = ''
+ A set of environment variables used in the global environment.
+ These variables will be set on shell initialisation.
+ The value of each variable can be either a string or a list of
+ strings. The latter is concatenated, interspersed with colon
+ characters.
+ '';
+ type = types.attrsOf (types.loeOf types.str);
+ apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
+ };
+
+
};
config = {
+ system.build.setEnvironment = pkgs.writeText "set-environment" ''
+ ${exportedEnvVars}
+ '';
+
system.path = pkgs.buildEnv {
name = "system-path";
paths = cfg.systemPackages;