Loading nixos/modules/config/shells-environment.nix +6 −2 Original line number Diff line number Diff line Loading @@ -34,14 +34,18 @@ in description = '' A set of environment variables used in the global environment. These variables will be set on shell initialisation (e.g. in /etc/profile). The value of each variable can be either a string or a list of strings. The latter is concatenated, interspersed with colon characters. Setting a variable to `null` does nothing. You can override a variable set by another module to `null` to unset it. ''; type = with lib.types; attrsOf (oneOf [ (listOf (oneOf [ int str path ])) int str path ]); type = with lib.types; attrsOf (nullOr (oneOf [ (listOf (oneOf [ int str path ])) int str path ])); apply = let toStr = v: if lib.isPath v then "${v}" else toString v; in lib.mapAttrs (n: v: if lib.isList v then lib.concatMapStringsSep ":" toStr v else toStr v); in attrs: lib.mapAttrs (n: v: if lib.isList v then lib.concatMapStringsSep ":" toStr v else toStr v) (lib.filterAttrs (n: v: v != null) attrs); }; environment.profiles = lib.mkOption { Loading nixos/modules/config/system-environment.nix +3 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,9 @@ in list of strings. The latter is concatenated, interspersed with colon characters. Setting a variable to `null` does nothing. You can override a variable set by another module to `null` to unset it. Note, due to limitations in the PAM format values may not contain the `"` character. Loading nixos/tests/env.nix +10 −2 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import ./make-test-python.nix ({ pkgs, ...} : { maintainers = [ nequissimus ]; }; nodes.machine = { pkgs, ... }: nodes.machine = { pkgs, lib, ... }: lib.mkMerge [ { boot.kernelPackages = pkgs.linuxPackages; environment.etc.plainFile.text = '' Loading @@ -17,8 +17,15 @@ import ./make-test-python.nix ({ pkgs, ...} : { environment.sessionVariables = { TERMINFO_DIRS = "/run/current-system/sw/share/terminfo"; NIXCON = "awesome"; SHOULD_NOT_BE_SET = "oops"; }; } { environment.sessionVariables = { SHOULD_NOT_BE_SET = lib.mkForce null; }; } ]; testScript = '' machine.succeed('[ -L "/etc/plainFile" ]') Loading @@ -32,5 +39,6 @@ import ./make-test-python.nix ({ pkgs, ...} : { "echo ''${TERMINFO_DIRS}" ) assert "awesome" in machine.succeed("echo ''${NIXCON}") machine.fail("printenv SHOULD_NOT_BE_SET") ''; }) Loading
nixos/modules/config/shells-environment.nix +6 −2 Original line number Diff line number Diff line Loading @@ -34,14 +34,18 @@ in description = '' A set of environment variables used in the global environment. These variables will be set on shell initialisation (e.g. in /etc/profile). The value of each variable can be either a string or a list of strings. The latter is concatenated, interspersed with colon characters. Setting a variable to `null` does nothing. You can override a variable set by another module to `null` to unset it. ''; type = with lib.types; attrsOf (oneOf [ (listOf (oneOf [ int str path ])) int str path ]); type = with lib.types; attrsOf (nullOr (oneOf [ (listOf (oneOf [ int str path ])) int str path ])); apply = let toStr = v: if lib.isPath v then "${v}" else toString v; in lib.mapAttrs (n: v: if lib.isList v then lib.concatMapStringsSep ":" toStr v else toStr v); in attrs: lib.mapAttrs (n: v: if lib.isList v then lib.concatMapStringsSep ":" toStr v else toStr v) (lib.filterAttrs (n: v: v != null) attrs); }; environment.profiles = lib.mkOption { Loading
nixos/modules/config/system-environment.nix +3 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,9 @@ in list of strings. The latter is concatenated, interspersed with colon characters. Setting a variable to `null` does nothing. You can override a variable set by another module to `null` to unset it. Note, due to limitations in the PAM format values may not contain the `"` character. Loading
nixos/tests/env.nix +10 −2 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import ./make-test-python.nix ({ pkgs, ...} : { maintainers = [ nequissimus ]; }; nodes.machine = { pkgs, ... }: nodes.machine = { pkgs, lib, ... }: lib.mkMerge [ { boot.kernelPackages = pkgs.linuxPackages; environment.etc.plainFile.text = '' Loading @@ -17,8 +17,15 @@ import ./make-test-python.nix ({ pkgs, ...} : { environment.sessionVariables = { TERMINFO_DIRS = "/run/current-system/sw/share/terminfo"; NIXCON = "awesome"; SHOULD_NOT_BE_SET = "oops"; }; } { environment.sessionVariables = { SHOULD_NOT_BE_SET = lib.mkForce null; }; } ]; testScript = '' machine.succeed('[ -L "/etc/plainFile" ]') Loading @@ -32,5 +39,6 @@ import ./make-test-python.nix ({ pkgs, ...} : { "echo ''${TERMINFO_DIRS}" ) assert "awesome" in machine.succeed("echo ''${NIXCON}") machine.fail("printenv SHOULD_NOT_BE_SET") ''; })