From f33900124c23c4eca5831b9b5eb32ea5894375ce Mon Sep 17 00:00:00 2001 From: Ramses Date: Sat, 3 Feb 2024 11:14:20 +0100 Subject: [PATCH] nix: fix generation of nix.conf for nix >= 2.20 (cherry picked from commit 880d9bc2110f7cae59698f715b8ca42cdc53670c) --- modules/misc/nix.nix | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/modules/misc/nix.nix b/modules/misc/nix.nix index 9e2491436..a4456946e 100644 --- a/modules/misc/nix.nix +++ b/modules/misc/nix.nix @@ -52,22 +52,26 @@ let checkPhase = if pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform then '' echo "Ignoring validation for cross-compilation" - '' else '' - 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 --option experimental-features nix-command" - } \ - |& sed -e 's/^warning:/error:/' \ - | (! grep '${ - if cfg.checkConfig then "^error:" else "^error: unknown setting" - }') - set -o pipefail - ''; + '' 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 ${showCommand} ${ + optionalString (isNixAtLeast "2.3pre") + "--no-net --option experimental-features nix-command" + } \ + |& sed -e 's/^warning:/error:/' \ + | (! grep '${ + if cfg.checkConfig then "^error:" else "^error: unknown setting" + }') + set -o pipefail + ''; }; semanticConfType = with types;