Merge pull request #301827 from kampka/forbiddenDependenciesRegex

nixos/top-level: Turn `system.forbiddenDependenciesRegex` into a list

Artturin 5ce6ea92 5aa69d78

Changed files
+16 -15
nixos
doc
manual
release-notes
modules
profiles
system
activation
+2
nixos/doc/manual/release-notes/rl-2405.section.md
···
"mysecret"` becomes `services.aria2.rpcSecretFile = "/path/to/secret_file"`
where the file `secret_file` contains the string `mysecret`.
- `openssh`, `openssh_hpn` and `openssh_gssapi` are now compiled without support for the DSA signature algorithm as it is being deprecated upstream. Users still relying on DSA keys should consider upgrading
to another signature algorithm. However, for the time being it is possible to restore DSA key support using `override` to set `dsaKeysSupport = true`.
···
"mysecret"` becomes `services.aria2.rpcSecretFile = "/path/to/secret_file"`
where the file `secret_file` contains the string `mysecret`.
+
- The `system.forbiddenDependenciesRegex` option has been renamed to `system.forbiddenDependenciesRegexes` and now has the type of `listOf string` instead of `string` to accept multiple regexes.
+
- `openssh`, `openssh_hpn` and `openssh_gssapi` are now compiled without support for the DSA signature algorithm as it is being deprecated upstream. Users still relying on DSA keys should consider upgrading
to another signature algorithm. However, for the time being it is possible to restore DSA key support using `override` to set `dsaKeysSupport = true`.
+1 -1
nixos/modules/profiles/perlless.nix
···
# Check that the system does not contain a Nix store path that contains the
# string "perl".
-
system.forbiddenDependenciesRegex = "perl";
}
···
# Check that the system does not contain a Nix store path that contains the
# string "perl".
+
system.forbiddenDependenciesRegexes = ["perl"];
}
+2 -2
nixos/modules/system/activation/test.nix
···
}:
let
node-forbiddenDependencies-fail = nixos ({ ... }: {
-
system.forbiddenDependenciesRegex = "-dev$";
environment.etc."dev-dependency" = {
text = "${expect.dev}";
};
···
boot.loader.grub.enable = false;
});
node-forbiddenDependencies-succeed = nixos ({ ... }: {
-
system.forbiddenDependenciesRegex = "-dev$";
system.extraDependencies = [ expect.dev ];
documentation.enable = false;
fileSystems."/".device = "ignore-root-device";
···
}:
let
node-forbiddenDependencies-fail = nixos ({ ... }: {
+
system.forbiddenDependenciesRegexes = ["-dev$"];
environment.etc."dev-dependency" = {
text = "${expect.dev}";
};
···
boot.loader.grub.enable = false;
});
node-forbiddenDependencies-succeed = nixos ({ ... }: {
+
system.forbiddenDependenciesRegexes = ["-dev$"];
system.extraDependencies = [ expect.dev ];
documentation.enable = false;
fileSystems."/".device = "ignore-root-device";
+11 -12
nixos/modules/system/activation/top-level.nix
···
../build.nix
(mkRemovedOptionModule [ "nesting" "clone" ] "Use `specialisation.«name» = { inheritParentConfig = true; configuration = { ... }; }` instead.")
(mkRemovedOptionModule [ "nesting" "children" ] "Use `specialisation.«name».configuration = { ... }` instead.")
];
options = {
···
'';
};
-
system.forbiddenDependenciesRegex = mkOption {
-
default = "";
-
example = "-dev$";
-
type = types.str;
description = ''
-
A POSIX Extended Regular Expression that matches store paths that
should not appear in the system closure, with the exception of {option}`system.extraDependencies`, which is not checked.
'';
};
···
"$out/configuration.nix"
'' +
optionalString
-
(config.system.forbiddenDependenciesRegex != "")
-
''
-
if [[ $forbiddenDependenciesRegex != "" && -n $closureInfo ]]; then
-
if forbiddenPaths="$(grep -E -- "$forbiddenDependenciesRegex" $closureInfo/store-paths)"; then
echo -e "System closure $out contains the following disallowed paths:\n$forbiddenPaths"
exit 1
fi
fi
-
'';
system.systemBuilderArgs = {
···
# option, as opposed to `system.extraDependencies`.
passedChecks = concatStringsSep " " config.system.checks;
}
-
// lib.optionalAttrs (config.system.forbiddenDependenciesRegex != "") {
-
inherit (config.system) forbiddenDependenciesRegex;
closureInfo = pkgs.closureInfo { rootPaths = [
# override to avoid infinite recursion (and to allow using extraDependencies to add forbidden dependencies)
(config.system.build.toplevel.overrideAttrs (_: { extraDependencies = []; closureInfo = null; }))
···
../build.nix
(mkRemovedOptionModule [ "nesting" "clone" ] "Use `specialisation.«name» = { inheritParentConfig = true; configuration = { ... }; }` instead.")
(mkRemovedOptionModule [ "nesting" "children" ] "Use `specialisation.«name».configuration = { ... }` instead.")
+
(mkRenamedOptionModule [ "system" "forbiddenDependenciesRegex" ] [ "system" "forbiddenDependenciesRegexes" ])
];
options = {
···
'';
};
+
system.forbiddenDependenciesRegexes = mkOption {
+
default = [];
+
example = ["-dev$"];
+
type = types.listOf types.str;
description = ''
+
POSIX Extended Regular Expressions that match store paths that
should not appear in the system closure, with the exception of {option}`system.extraDependencies`, which is not checked.
'';
};
···
"$out/configuration.nix"
'' +
optionalString
+
(config.system.forbiddenDependenciesRegexes != []) (lib.concatStringsSep "\n" (map (regex: ''
+
if [[ ${regex} != "" && -n $closureInfo ]]; then
+
if forbiddenPaths="$(grep -E -- "${regex}" $closureInfo/store-paths)"; then
echo -e "System closure $out contains the following disallowed paths:\n$forbiddenPaths"
exit 1
fi
fi
+
'') config.system.forbiddenDependenciesRegexes));
system.systemBuilderArgs = {
···
# option, as opposed to `system.extraDependencies`.
passedChecks = concatStringsSep " " config.system.checks;
}
+
// lib.optionalAttrs (config.system.forbiddenDependenciesRegexes != []) {
closureInfo = pkgs.closureInfo { rootPaths = [
# override to avoid infinite recursion (and to allow using extraDependencies to add forbidden dependencies)
(config.system.build.toplevel.overrideAttrs (_: { extraDependencies = []; closureInfo = null; }))