mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 14:54:29 +01:00
nixos/nix-daemon: optionally (on by default) check nix.conf can be read
* checks using package providing the nix-daemon that we'll be using * made optional (unlike some other config checks) "just in case": since this requires running the new Nix on the builder, this won't work in a few (AFAIK very uncommon) situations such as cross-compiling NixOS or using `include` directives in nix.conf This does rely on Nix2 but not by the builder. Since we only offer Nix2+ in-tree this should be fine, and may otherwise be required anyway.
This commit is contained in:
parent
e815efb824
commit
fa1d1eec6e
1 changed files with 13 additions and 2 deletions
|
@ -33,7 +33,7 @@ let
|
|||
sh = pkgs.runtimeShell;
|
||||
binshDeps = pkgs.writeReferencesToFile sh;
|
||||
in
|
||||
pkgs.runCommand "nix.conf" { extraOptions = cfg.extraOptions; } ''
|
||||
pkgs.runCommand "nix.conf" { extraOptions = cfg.extraOptions; } (''
|
||||
${optionalString (!isNix20) ''
|
||||
extraPaths=$(for i in $(cat ${binshDeps}); do if test -d $i; then echo $i; fi; done)
|
||||
''}
|
||||
|
@ -62,7 +62,11 @@ let
|
|||
''}
|
||||
$extraOptions
|
||||
END
|
||||
'';
|
||||
'' + optionalString cfg.checkConfig ''
|
||||
echo "Checking that Nix can read nix.conf..."
|
||||
ln -s $out ./nix.conf
|
||||
NIX_CONF_DIR=$PWD ${cfg.package}/bin/nix show-config >/dev/null
|
||||
'');
|
||||
|
||||
in
|
||||
|
||||
|
@ -349,6 +353,13 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
checkConfig = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
If enabled (the default), checks that Nix can parse the generated nix.conf.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue