mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
Merge eda9c7b705 into 0562fef070
This commit is contained in:
commit
14f4b95e5e
6 changed files with 94 additions and 2 deletions
|
|
@ -103,6 +103,7 @@ let
|
||||||
${mkKeyValuePairs cfg.settings}
|
${mkKeyValuePairs cfg.settings}
|
||||||
${cfg.extraOptions}
|
${cfg.extraOptions}
|
||||||
'';
|
'';
|
||||||
|
passthru.doCheck = cfg.checkConfig;
|
||||||
checkPhase =
|
checkPhase =
|
||||||
if pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform then
|
if pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform then
|
||||||
''
|
''
|
||||||
|
|
@ -120,7 +121,8 @@ let
|
||||||
NIX_CONF_DIR=$PWD \
|
NIX_CONF_DIR=$PWD \
|
||||||
${cfg.package}/bin/nix ${showCommand} ${optionalString (isNixAtLeast "2.3pre") "--no-net --option experimental-features nix-command"} \
|
${cfg.package}/bin/nix ${showCommand} ${optionalString (isNixAtLeast "2.3pre") "--no-net --option experimental-features nix-command"} \
|
||||||
|& sed -e 's/^warning:/error:/' \
|
|& sed -e 's/^warning:/error:/' \
|
||||||
| (! grep '${if cfg.checkConfig then "^error:" else "^error: unknown setting"}')
|
| ${if cfg.allowUnknownSettings then "grep -v '^error: unknown setting'" else "cat"} \
|
||||||
|
| (! grep '^error:')
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
@ -294,7 +296,16 @@ in
|
||||||
default = true;
|
default = true;
|
||||||
description = ''
|
description = ''
|
||||||
If enabled (the default), checks for data type mismatches and that Nix
|
If enabled (the default), checks for data type mismatches and that Nix
|
||||||
can parse the generated nix.conf.
|
can parse the generated {file}`nix.conf`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
allowUnknownSettings = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
If enabled, unknown setting errors will be allowed when checking the
|
||||||
|
generated {file}`nix.conf`. This has no effect if {option}`checkConfig` is false.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# WARNING: this file is generated from the nix.settings option in
|
||||||
|
# your Home Manager configuration at $XDG_CONFIG_HOME/nix/nix.conf.
|
||||||
|
# Do not edit it!
|
||||||
|
and-another-one = hello
|
||||||
|
some-arbitrary-setting = true
|
||||||
|
|
||||||
33
tests/modules/misc/nix/allow-unknown-settings.nix
Normal file
33
tests/modules/misc/nix/allow-unknown-settings.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
nix = {
|
||||||
|
package = config.lib.test.mkStubPackage {
|
||||||
|
version = lib.getVersion pkgs.nixVersions.stable;
|
||||||
|
buildScript = ''
|
||||||
|
target=$out/bin/nix
|
||||||
|
mkdir -p "$(dirname "$target")"
|
||||||
|
|
||||||
|
echo -n "true" > "$target"
|
||||||
|
|
||||||
|
chmod +x "$target"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
some-arbitrary-setting = true;
|
||||||
|
and-another-one = "hello";
|
||||||
|
};
|
||||||
|
checkConfig = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileContent \
|
||||||
|
home-files/.config/nix/nix.conf \
|
||||||
|
${./allow-unknown-settings-expected.conf}
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -5,4 +5,6 @@
|
||||||
nix-keep-old-nix-path = ./keep-old-nix-path.nix;
|
nix-keep-old-nix-path = ./keep-old-nix-path.nix;
|
||||||
nix-example-channels = ./example-channels.nix;
|
nix-example-channels = ./example-channels.nix;
|
||||||
nix-example-channels-xdg = ./example-channels-xdg.nix;
|
nix-example-channels-xdg = ./example-channels-xdg.nix;
|
||||||
|
nix-skip-check-settings = ./skip-check-settings.nix;
|
||||||
|
nix-allow-unknown-settings = ./allow-unknown-settings.nix;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
7
tests/modules/misc/nix/skip-check-settings-expected.conf
Normal file
7
tests/modules/misc/nix/skip-check-settings-expected.conf
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# WARNING: this file is generated from the nix.settings option in
|
||||||
|
# your Home Manager configuration at $XDG_CONFIG_HOME/nix/nix.conf.
|
||||||
|
# Do not edit it!
|
||||||
|
|
||||||
|
some! nonsense {
|
||||||
|
which should fail validation
|
||||||
|
|
||||||
33
tests/modules/misc/nix/skip-check-settings.nix
Normal file
33
tests/modules/misc/nix/skip-check-settings.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
nix = {
|
||||||
|
package = config.lib.test.mkStubPackage {
|
||||||
|
version = lib.getVersion pkgs.nixVersions.stable;
|
||||||
|
buildScript = ''
|
||||||
|
target=$out/bin/nix
|
||||||
|
mkdir -p "$(dirname "$target")"
|
||||||
|
|
||||||
|
echo -n "true" > "$target"
|
||||||
|
|
||||||
|
chmod +x "$target"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraOptions = ''
|
||||||
|
some! nonsense {
|
||||||
|
which should fail validation
|
||||||
|
'';
|
||||||
|
checkConfig = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileContent \
|
||||||
|
home-files/.config/nix/nix.conf \
|
||||||
|
${./skip-check-settings-expected.conf}
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue