about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-12-01 12:14:21 +0100
committerRobert Hensing <robert@roberthensing.nl>2023-12-01 12:14:21 +0100
commit2d0f4a7ec19082248094eb04a35c93c94b1d35d5 (patch)
treeec0d7fbfb3ba06455fe2a7ef29337e2c584a555e /nixos/modules
parentf1750de0bb49961a0622fad1d804e8974556881d (diff)
downloadnixlib-2d0f4a7ec19082248094eb04a35c93c94b1d35d5.tar
nixlib-2d0f4a7ec19082248094eb04a35c93c94b1d35d5.tar.gz
nixlib-2d0f4a7ec19082248094eb04a35c93c94b1d35d5.tar.bz2
nixlib-2d0f4a7ec19082248094eb04a35c93c94b1d35d5.tar.lz
nixlib-2d0f4a7ec19082248094eb04a35c93c94b1d35d5.tar.xz
nixlib-2d0f4a7ec19082248094eb04a35c93c94b1d35d5.tar.zst
nixlib-2d0f4a7ec19082248094eb04a35c93c94b1d35d5.zip
nixos/nix.nix: Support new Nix 2.20 command syntax
Otherwise it shows a deprecation warning, which is escalated to
an error. For context, see
https://github.com/NixOS/nixpkgs/pull/139075#discussion_r733615550
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/config/nix.nix8
1 files changed, 6 insertions, 2 deletions
diff --git a/nixos/modules/config/nix.nix b/nixos/modules/config/nix.nix
index cee4f54db0cb..2769d8b25ef6 100644
--- a/nixos/modules/config/nix.nix
+++ b/nixos/modules/config/nix.nix
@@ -109,13 +109,17 @@ let
         if pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform then ''
           echo "Ignoring validation for cross-compilation"
         ''
-        else ''
+        else
+        let
+          showCommand = if isNixAtLeast "2.20pre" then "config show" else "show-config";
+        in
+        ''
           echo "Validating generated nix.conf"
           ln -s $out ./nix.conf
           set -e
           set +o pipefail
           NIX_CONF_DIR=$PWD \
-            ${cfg.package}/bin/nix show-config ${optionalString (isNixAtLeast "2.3pre") "--no-net"} \
+            ${cfg.package}/bin/nix ${showCommand} ${optionalString (isNixAtLeast "2.3pre") "--no-net"} \
               ${optionalString (isNixAtLeast "2.4pre") "--option experimental-features nix-command"} \
             |& sed -e 's/^warning:/error:/' \
             | (! grep '${if cfg.checkAllErrors then "^error:" else "^error: unknown setting"}')