Add a way to define obsolete options that have no replacement

This commit is contained in:
Eelco Dolstra 2013-10-23 18:22:26 +02:00
parent b5d5afd99a
commit 8f4c5b05d5
4 changed files with 20 additions and 13 deletions

View File

@ -66,7 +66,6 @@ rec {
# Optionally check wether all config values have corresponding # Optionally check wether all config values have corresponding
# option declarations. # option declarations.
config = config =
let doCheck = optionDefinitions.environment.checkConfigurationOptions; in assert optionDefinitions.environment.checkConfigurationOptions -> pkgs.lib.checkModule "" systemModule;
assert doCheck -> pkgs.lib.checkModule "" systemModule;
systemModule.config; systemModule.config;
} }

View File

@ -30,7 +30,8 @@ let
zipAttrsWith (n: v: zipAttrsWith (n: v:
if tail v != [] then if tail v != [] then
if n == "_type" then (head v) if n == "_type" then (head v)
else if n == "extraConfigs" then (concatLists v) else if n == "extraConfigs" then concatLists v
else if n == "warnings" then concatLists v
else if n == "description" || n == "apply" then else if n == "description" || n == "apply" then
abort "Cannot rename an option to multiple options." abort "Cannot rename an option to multiple options."
else zipModules v else zipModules v
@ -62,6 +63,15 @@ let
} }
]; ];
obsolete' = option: let option' = splitString "." option; in singleton
{ options = setAttrByPath option' (mkOption {
default = null;
visible = false;
});
config.warnings = optional (getAttrFromPath option' config != null)
"The option `${option}' set in your configuration no longer has any effect; please remove it.";
};
in zipModules ([] in zipModules ([]
# usage example: # usage example:
@ -108,4 +118,8 @@ in zipModules ([]
# !!! this hardcodes bash, could we detect from config which shell is actually used? # !!! this hardcodes bash, could we detect from config which shell is actually used?
++ rename obsolete "environment.promptInit" "programs.bash.promptInit" ++ rename obsolete "environment.promptInit" "programs.bash.promptInit"
# Options that are obsolete and have no replacement.
++ obsolete' "boot.loader.grub.bootDevice"
++ obsolete' "boot.initrd.luks.enable"
) # do not add renaming after this. ) # do not add renaming after this.

View File

@ -86,12 +86,6 @@ in
''; '';
}; };
# !!! How can we mark options as obsolete?
bootDevice = mkOption {
default = "";
description = "Obsolete.";
};
configurationName = mkOption { configurationName = mkOption {
default = ""; default = "";
example = "Stable 2.6.21"; example = "Stable 2.6.21";

View File

@ -44,12 +44,9 @@ in
{ {
options = { options = {
boot.initrd.luks.enable = mkOption {
default = false;
description = "Obsolete.";
};
boot.initrd.luks.mitigateDMAAttacks = mkOption { boot.initrd.luks.mitigateDMAAttacks = mkOption {
type = types.bool;
default = true; default = true;
description = '' description = ''
Unless enabled, encryption keys can be easily recovered by an attacker with physical Unless enabled, encryption keys can be easily recovered by an attacker with physical
@ -62,6 +59,7 @@ in
}; };
boot.initrd.luks.cryptoModules = mkOption { boot.initrd.luks.cryptoModules = mkOption {
type = types.listOf types.string;
default = default =
[ "aes" "aes_generic" "blowfish" "twofish" [ "aes" "aes_generic" "blowfish" "twofish"
"serpent" "cbc" "xts" "lrw" "sha1" "sha256" "sha512" "serpent" "cbc" "xts" "lrw" "sha1" "sha256" "sha512"
@ -142,7 +140,9 @@ in
}; };
}; };
}; };
}; };
config = mkIf (luks.devices != []) { config = mkIf (luks.devices != []) {