about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-23 18:22:26 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-23 20:08:22 +0200
commit8f4c5b05d5639c1577ce92c9e42a5d59b8be4cda (patch)
tree73bac7d9a21a4e95f74d462faf7cfdcd2bc78c55
parentb5d5afd99a7ff24de036885364f7a7bbe90dd405 (diff)
downloadnixlib-8f4c5b05d5639c1577ce92c9e42a5d59b8be4cda.tar
nixlib-8f4c5b05d5639c1577ce92c9e42a5d59b8be4cda.tar.gz
nixlib-8f4c5b05d5639c1577ce92c9e42a5d59b8be4cda.tar.bz2
nixlib-8f4c5b05d5639c1577ce92c9e42a5d59b8be4cda.tar.lz
nixlib-8f4c5b05d5639c1577ce92c9e42a5d59b8be4cda.tar.xz
nixlib-8f4c5b05d5639c1577ce92c9e42a5d59b8be4cda.tar.zst
nixlib-8f4c5b05d5639c1577ce92c9e42a5d59b8be4cda.zip
Add a way to define obsolete options that have no replacement
-rw-r--r--nixos/lib/eval-config.nix3
-rw-r--r--nixos/modules/rename.nix16
-rw-r--r--nixos/modules/system/boot/loader/grub/grub.nix6
-rw-r--r--nixos/modules/system/boot/luksroot.nix8
4 files changed, 20 insertions, 13 deletions
diff --git a/nixos/lib/eval-config.nix b/nixos/lib/eval-config.nix
index 72ba66cdbac4..cd543c958ff6 100644
--- a/nixos/lib/eval-config.nix
+++ b/nixos/lib/eval-config.nix
@@ -66,7 +66,6 @@ rec {
   # Optionally check wether all config values have corresponding
   # option declarations.
   config =
-    let doCheck = optionDefinitions.environment.checkConfigurationOptions; in
-    assert doCheck -> pkgs.lib.checkModule "" systemModule;
+    assert optionDefinitions.environment.checkConfigurationOptions -> pkgs.lib.checkModule "" systemModule;
     systemModule.config;
 }
diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix
index 3e3f6dd10c10..ca3bdc08a8d8 100644
--- a/nixos/modules/rename.nix
+++ b/nixos/modules/rename.nix
@@ -30,7 +30,8 @@ let
     zipAttrsWith (n: v:
       if tail v != [] then
         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
           abort "Cannot rename an option to multiple options."
         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 ([]
 
 # usage example:
@@ -108,4 +118,8 @@ in zipModules ([]
 # !!! this hardcodes bash, could we detect from config which shell is actually used?
 ++ 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.
diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix
index c7c1f675c778..48d16b1c520e 100644
--- a/nixos/modules/system/boot/loader/grub/grub.nix
+++ b/nixos/modules/system/boot/loader/grub/grub.nix
@@ -86,12 +86,6 @@ in
         '';
       };
 
-      # !!! How can we mark options as obsolete?
-      bootDevice = mkOption {
-        default = "";
-        description = "Obsolete.";
-      };
-
       configurationName = mkOption {
         default = "";
         example = "Stable 2.6.21";
diff --git a/nixos/modules/system/boot/luksroot.nix b/nixos/modules/system/boot/luksroot.nix
index 29f5eb4fd771..ba357f5d2de3 100644
--- a/nixos/modules/system/boot/luksroot.nix
+++ b/nixos/modules/system/boot/luksroot.nix
@@ -44,12 +44,9 @@ in
 {
 
   options = {
-    boot.initrd.luks.enable = mkOption {
-      default = false;
-      description = "Obsolete.";
-    };
 
     boot.initrd.luks.mitigateDMAAttacks = mkOption {
+      type = types.bool;
       default = true;
       description = ''
         Unless enabled, encryption keys can be easily recovered by an attacker with physical
@@ -62,6 +59,7 @@ in
     };
 
     boot.initrd.luks.cryptoModules = mkOption {
+      type = types.listOf types.string;
       default =
         [ "aes" "aes_generic" "blowfish" "twofish"
           "serpent" "cbc" "xts" "lrw" "sha1" "sha256" "sha512"
@@ -142,7 +140,9 @@ in
         };
 
       };
+
     };
+
   };
 
   config = mkIf (luks.devices != []) {