diff --git a/lib/types.nix b/lib/types.nix index 73d59309e91b..715da842ac01 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -1456,12 +1456,6 @@ let nestedTypes.finalType = finalType; }; - # A list of attrnames is coerced into an attrset of bools by - # setting the values to true. - attrNamesToTrue = coercedTo (types.listOf types.str) ( - enabledList: lib.genAttrs enabledList (_attrName: true) - ) (types.attrsOf types.bool); - # Augment the given type with an additional type check function. addCheck = elemType: check: elemType // { check = x: elemType.check x && check x; }; diff --git a/nixos/doc/manual/development/option-types.section.md b/nixos/doc/manual/development/option-types.section.md index 8539da71a214..c0add330b72e 100644 --- a/nixos/doc/manual/development/option-types.section.md +++ b/nixos/doc/manual/development/option-types.section.md @@ -135,29 +135,6 @@ merging is handled. problems. ::: -`types.attrNamesToTrue` - -: Either a list of attribute names, or an attribute set of - booleans. A list will be coerced into an attribute set with those - names, whose values are set to `true`. This is useful when it is - convenient to be able to write definitions as a simple list, but - still need to be able to override and disable individual values. - - ::: {#ex-types-attrNamesToTrue .example} - ### `types.attrNamesToTrue` - ``` - { - foo = [ "bar" ]; - } - ``` - - ``` - { - foo.bar = true; - } - ``` - ::: - `types.pkgs` : A type for the top level Nixpkgs package set. diff --git a/nixos/modules/system/boot/kernel.nix b/nixos/modules/system/boot/kernel.nix index 1d8f65ad28d3..c5a2f5933b48 100644 --- a/nixos/modules/system/boot/kernel.nix +++ b/nixos/modules/system/boot/kernel.nix @@ -25,6 +25,12 @@ let ${concatStringsSep "\n" config.boot.kernelModules} ''; + # A list of attrnames is coerced into an attrset of bools by + # setting the values to true. + attrNamesToTrue = types.coercedTo (types.listOf types.str) ( + enabledList: lib.genAttrs enabledList (_attrName: true) + ) (types.attrsOf types.bool); + in { @@ -196,7 +202,7 @@ in }; boot.kernelModules = mkOption { - type = types.attrNamesToTrue; + type = attrNamesToTrue; default = { }; description = '' The set of kernel modules to be loaded in the second stage of @@ -211,7 +217,7 @@ in }; boot.initrd.availableKernelModules = mkOption { - type = types.attrNamesToTrue; + type = attrNamesToTrue; default = { }; example = [ "sata_nv" @@ -238,7 +244,7 @@ in }; boot.initrd.kernelModules = mkOption { - type = types.attrNamesToTrue; + type = attrNamesToTrue; default = { }; description = '' Set of modules that are always loaded by the initrd. diff --git a/nixos/modules/system/boot/modprobe.nix b/nixos/modules/system/boot/modprobe.nix index b38e78c3222a..18c34f547c85 100644 --- a/nixos/modules/system/boot/modprobe.nix +++ b/nixos/modules/system/boot/modprobe.nix @@ -7,6 +7,16 @@ with lib; +let + + # A list of attrnames is coerced into an attrset of bools by + # setting the values to true. + attrNamesToTrue = types.coercedTo (types.listOf types.str) ( + enabledList: lib.genAttrs enabledList (_attrName: true) + ) (types.attrsOf types.bool); + +in + { ###### interface @@ -25,7 +35,7 @@ with lib; }; boot.blacklistedKernelModules = mkOption { - type = types.attrNamesToTrue; + type = attrNamesToTrue; default = { }; example = [ "cirrusfb" diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix index b28a902a7c54..c9588f65b506 100644 --- a/nixos/modules/tasks/filesystems.nix +++ b/nixos/modules/tasks/filesystems.nix @@ -13,6 +13,12 @@ let # https://wiki.archlinux.org/index.php/fstab#Filepath_spaces escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string; + # A list of attrnames is coerced into an attrset of bools by + # setting the values to true. + attrNamesToTrue = types.coercedTo (types.listOf types.str) ( + enabledList: lib.genAttrs enabledList (_attrName: true) + ) (types.attrsOf types.bool); + addCheckDesc = desc: elemType: check: types.addCheck elemType check // { description = "${elemType.description} (with check: ${desc})"; }; @@ -326,7 +332,7 @@ in zfs = lib.mkForce false; } ''; - type = types.attrNamesToTrue; + type = attrNamesToTrue; description = '' Names of supported filesystem types, or an attribute set of file system types and their state. The set form may be used together with `lib.mkForce` to