mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
nixos/nix: add workaround for https://github.com/NixOS/nix/issues/9487
Nix has a suprising behavior where if the option `extra-foo` is set before `foo`, then setting `foo` overwrites the setting for `extra-foo`. This is reported as https://github.com/NixOS/nix/issues/9487, and will likely not be fixed any time soon. This works around this issue by always putting `extra-*` settings after non-extra ones in the nixos-generated `/etc/nix.conf`.
This commit is contained in:
parent
cfc3698c31
commit
5b274d5f01
@ -14,8 +14,10 @@ let
|
|||||||
concatStringsSep
|
concatStringsSep
|
||||||
boolToString
|
boolToString
|
||||||
escape
|
escape
|
||||||
|
filterAttrs
|
||||||
floatToString
|
floatToString
|
||||||
getVersion
|
getVersion
|
||||||
|
hasPrefix
|
||||||
isBool
|
isBool
|
||||||
isDerivation
|
isDerivation
|
||||||
isFloat
|
isFloat
|
||||||
@ -95,14 +97,19 @@ let
|
|||||||
|
|
||||||
mkKeyValuePairs = attrs: concatStringsSep "\n" (mapAttrsToList mkKeyValue attrs);
|
mkKeyValuePairs = attrs: concatStringsSep "\n" (mapAttrsToList mkKeyValue attrs);
|
||||||
|
|
||||||
|
isExtra = key: hasPrefix "extra-" key;
|
||||||
|
|
||||||
in
|
in
|
||||||
pkgs.writeTextFile {
|
pkgs.writeTextFile {
|
||||||
name = "nix.conf";
|
name = "nix.conf";
|
||||||
|
# workaround for https://github.com/NixOS/nix/issues/9487
|
||||||
|
# extra-* settings must come after their non-extra counterpart
|
||||||
text = ''
|
text = ''
|
||||||
# WARNING: this file is generated from the nix.* options in
|
# WARNING: this file is generated from the nix.* options in
|
||||||
# your NixOS configuration, typically
|
# your NixOS configuration, typically
|
||||||
# /etc/nixos/configuration.nix. Do not edit it!
|
# /etc/nixos/configuration.nix. Do not edit it!
|
||||||
${mkKeyValuePairs cfg.settings}
|
${mkKeyValuePairs (filterAttrs (key: value: !(isExtra key)) cfg.settings)}
|
||||||
|
${mkKeyValuePairs (filterAttrs (key: value: isExtra key) cfg.settings)}
|
||||||
${cfg.extraOptions}
|
${cfg.extraOptions}
|
||||||
'';
|
'';
|
||||||
checkPhase = lib.optionalString cfg.checkConfig (
|
checkPhase = lib.optionalString cfg.checkConfig (
|
||||||
|
@ -596,6 +596,7 @@ in {
|
|||||||
nginx-variants = handleTest ./nginx-variants.nix {};
|
nginx-variants = handleTest ./nginx-variants.nix {};
|
||||||
nifi = handleTestOn ["x86_64-linux"] ./web-apps/nifi.nix {};
|
nifi = handleTestOn ["x86_64-linux"] ./web-apps/nifi.nix {};
|
||||||
nitter = handleTest ./nitter.nix {};
|
nitter = handleTest ./nitter.nix {};
|
||||||
|
nix-config = handleTest ./nix-config.nix {};
|
||||||
nix-ld = handleTest ./nix-ld.nix {};
|
nix-ld = handleTest ./nix-ld.nix {};
|
||||||
nix-serve = handleTest ./nix-serve.nix {};
|
nix-serve = handleTest ./nix-serve.nix {};
|
||||||
nix-serve-ssh = handleTest ./nix-serve-ssh.nix {};
|
nix-serve-ssh = handleTest ./nix-serve-ssh.nix {};
|
||||||
|
18
nixos/tests/nix-config.nix
Normal file
18
nixos/tests/nix-config.nix
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import ./make-test-python.nix ({ pkgs, ... }:
|
||||||
|
{
|
||||||
|
name = "nix-config";
|
||||||
|
nodes.machine = { pkgs, ... }: {
|
||||||
|
nix.settings = {
|
||||||
|
nix-path = [ "nonextra=/etc/value.nix" ];
|
||||||
|
extra-nix-path = [ "extra=/etc/value.nix" ];
|
||||||
|
};
|
||||||
|
environment.etc."value.nix".text = "42";
|
||||||
|
};
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
machine.wait_for_unit("nix-daemon.socket")
|
||||||
|
# regression test for the workaround for https://github.com/NixOS/nix/issues/9487
|
||||||
|
print(machine.succeed("nix-instantiate --find-file extra"))
|
||||||
|
print(machine.succeed("nix-instantiate --find-file nonextra"))
|
||||||
|
'';
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user