summary refs log tree commit diff
path: root/nixos/modules/services/misc/nix-daemon.nix
diff options
context:
space:
mode:
authorWill Dietz <w@wdtz.org>2018-04-24 09:19:45 -0500
committerWill Dietz <w@wdtz.org>2018-04-24 10:16:57 -0500
commitfa1d1eec6e5ef9f248416bec9df10ee2c9ed0e15 (patch)
tree41fa1c401bb9079b4b075e0b24bb8593e5912b0e /nixos/modules/services/misc/nix-daemon.nix
parente815efb8249d581b0bd6284a2b9ea98c7782c3ff (diff)
downloadnixpkgs-fa1d1eec6e5ef9f248416bec9df10ee2c9ed0e15.tar
nixpkgs-fa1d1eec6e5ef9f248416bec9df10ee2c9ed0e15.tar.gz
nixpkgs-fa1d1eec6e5ef9f248416bec9df10ee2c9ed0e15.tar.bz2
nixpkgs-fa1d1eec6e5ef9f248416bec9df10ee2c9ed0e15.tar.lz
nixpkgs-fa1d1eec6e5ef9f248416bec9df10ee2c9ed0e15.tar.xz
nixpkgs-fa1d1eec6e5ef9f248416bec9df10ee2c9ed0e15.tar.zst
nixpkgs-fa1d1eec6e5ef9f248416bec9df10ee2c9ed0e15.zip
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.
Diffstat (limited to 'nixos/modules/services/misc/nix-daemon.nix')
-rw-r--r--nixos/modules/services/misc/nix-daemon.nix15
1 files changed, 13 insertions, 2 deletions
diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix
index f2d34560a71..9c428d7a422 100644
--- a/nixos/modules/services/misc/nix-daemon.nix
+++ b/nixos/modules/services/misc/nix-daemon.nix
@@ -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.
+        '';
+      };
     };
 
   };