Skip to content

Commit

Permalink
nixos/nix.nix: Support new Nix 2.20 command syntax
Browse files Browse the repository at this point in the history
Otherwise it shows a deprecation warning, which is escalated to
an error. For context, see
NixOS#139075 (comment)
  • Loading branch information
roberth authored and tm-drtina committed Aug 13, 2024
1 parent 01a72ae commit f63db86
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nixos/modules/config/nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"}')
Expand Down

0 comments on commit f63db86

Please sign in to comment.