nixpkgs/nixos/tests/nix-config.nix
Guillaume Girol 5b274d5f01 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`.
2024-03-03 17:03:46 +01:00

19 lines
590 B
Nix

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"))
'';
})