mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-14 05:37:40 +03:00
Make environment variables overridable
This commit is contained in:
parent
b933b15d72
commit
ec2266b2e2
@ -25,7 +25,12 @@ in
|
||||
'';
|
||||
type = types.attrsOf (mkOptionType {
|
||||
name = "a string or a list of strings";
|
||||
check = x: builtins.isString x || isList x;
|
||||
merge = xs:
|
||||
let xs' = evalProperties xs; in
|
||||
if isList (head xs') then concatLists xs'
|
||||
else if length xs' > 1 then abort "variable in ‘environment.variables’ has multiple values"
|
||||
else if !builtins.isString (head xs') then abort "variable in ‘environment.variables’ does not have a string value"
|
||||
else head xs';
|
||||
});
|
||||
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
|
||||
};
|
||||
|
@ -8,6 +8,7 @@
|
||||
{ config, pkgs, ... }:
|
||||
{ swapDevices = pkgs.lib.mkOverride 0
|
||||
[ { device = "/root/swapfile"; size = 128; } ];
|
||||
environment.variables.EDITOR = pkgs.lib.mkOverride 0 "emacs";
|
||||
};
|
||||
|
||||
testScript =
|
||||
@ -52,6 +53,11 @@
|
||||
subtest "reboot-wtmp", sub {
|
||||
$machine->succeed("last | grep reboot >&2");
|
||||
};
|
||||
|
||||
# Test whether we can override environment variables.
|
||||
subtest "override-env-var", sub {
|
||||
$machine->succeed('[ "$EDITOR" = emacs ]');
|
||||
};
|
||||
'';
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user