diff --git a/lib/types.nix b/lib/types.nix
index a7f9bf1946e6..7276f9af9fee 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -6,7 +6,7 @@ with import ./attrsets.nix;
with import ./options.nix;
with import ./trivial.nix;
with import ./strings.nix;
-with {inherit (import ./modules.nix) mergeDefinitions; };
+with {inherit (import ./modules.nix) mergeDefinitions filterOverrides; };
rec {
@@ -166,6 +166,23 @@ rec {
substSubModules = m: loaOf (elemType.substSubModules m);
};
+ # List or element of ...
+ loeOf = elemType: mkOptionType {
+ name = "element or list of ${elemType.name}s";
+ check = x: isList x || elemType.check x;
+ merge = loc: defs:
+ let
+ defs' = filterOverrides defs;
+ res = (head defs').value;
+ in
+ if isList res then concatLists (getValues defs')
+ else if lessThan 1 (length defs') then
+ throw "The option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}."
+ else if !isString res then
+ throw "The option `${showOption loc}' does not have a string value, in ${showFiles (getFiles defs)}."
+ else res;
+ };
+
uniq = elemType: mkOptionType {
inherit (elemType) name check;
merge = mergeOneOption;
diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix
index 922a9cf961df..be6662decea6 100644
--- a/nixos/modules/config/fonts/fontconfig.nix
+++ b/nixos/modules/config/fonts/fontconfig.nix
@@ -108,10 +108,8 @@ with lib;
subpixel = {
rgba = mkOption {
- type = types.string // {
- check = flip elem ["rgb" "bgr" "vrgb" "vbgr" "none"];
- };
default = "rgb";
+ type = types.enum ["rgb" "bgr" "vrgb" "vbgr" "none"];
description = ''
Subpixel order, one of none,
rgb, bgr,
@@ -120,10 +118,8 @@ with lib;
};
lcdfilter = mkOption {
- type = types.str // {
- check = flip elem ["none" "default" "light" "legacy"];
- };
default = "default";
+ type = types.enum ["none" "default" "light" "legacy"];
description = ''
FreeType LCD filter, one of none,
default, light, or
diff --git a/nixos/modules/config/ldap.nix b/nixos/modules/config/ldap.nix
index 1a01533c585b..c87996df8855 100644
--- a/nixos/modules/config/ldap.nix
+++ b/nixos/modules/config/ldap.nix
@@ -108,7 +108,7 @@ in
extraConfig = mkOption {
default = "";
- type = types.string;
+ type = types.lines;
description = ''
Extra configuration options that will be added verbatim at
the end of the nslcd configuration file (nslcd.conf).
@@ -120,7 +120,7 @@ in
distinguishedName = mkOption {
default = "";
example = "cn=admin,dc=example,dc=com";
- type = types.string;
+ type = types.str;
description = ''
The distinguished name to bind to the LDAP server with. If this
is not specified, an anonymous bind will be done.
@@ -129,7 +129,7 @@ in
password = mkOption {
default = "/etc/ldap/bind.password";
- type = types.string;
+ type = types.str;
description = ''
The path to a file containing the credentials to use when binding
to the LDAP server (if not binding anonymously).
@@ -149,7 +149,7 @@ in
policy = mkOption {
default = "hard_open";
- type = types.string;
+ type = types.enum [ "hard_open" "hard_init" "soft" ];
description = ''
Specifies the policy to use for reconnecting to an unavailable
LDAP server. The default is hard_open, which
@@ -168,7 +168,7 @@ in
extraConfig = mkOption {
default = "";
- type = types.string;
+ type = types.lines;
description = ''
Extra configuration options that will be added verbatim at
the end of the ldap configuration file (ldap.conf).
diff --git a/nixos/modules/config/shells-environment.nix b/nixos/modules/config/shells-environment.nix
index bff0b2991323..533280890a70 100644
--- a/nixos/modules/config/shells-environment.nix
+++ b/nixos/modules/config/shells-environment.nix
@@ -41,20 +41,7 @@ in
strings. The latter is concatenated, interspersed with colon
characters.
'';
- type = types.attrsOf (mkOptionType {
- name = "a string or a list of strings";
- merge = loc: defs:
- let
- defs' = filterOverrides defs;
- res = (head defs').value;
- in
- if isList res then concatLists (getValues defs')
- else if lessThan 1 (length defs') then
- throw "The option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}."
- else if !isString res then
- throw "The option `${showOption loc}' does not have a string value, in ${showFiles (getFiles defs)}."
- else res;
- });
+ type = types.attrsOf (types.loeOf types.str);
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
};
diff --git a/nixos/modules/config/system-environment.nix b/nixos/modules/config/system-environment.nix
index 3ab32f00fd1d..3362400326d2 100644
--- a/nixos/modules/config/system-environment.nix
+++ b/nixos/modules/config/system-environment.nix
@@ -23,20 +23,7 @@ in
strings. The latter is concatenated, interspersed with colon
characters.
'';
- type = types.attrsOf (mkOptionType {
- name = "a string or a list of strings";
- merge = loc: defs:
- let
- defs' = filterOverrides defs;
- res = (head defs').value;
- in
- if isList res then concatLists (getValues defs')
- else if lessThan 1 (length defs') then
- throw "The option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}."
- else if !isString res then
- throw "The option `${showOption loc}' does not have a string value, in ${showFiles (getFiles defs)}."
- else res;
- });
+ type = types.attrsOf (types.loeOf types.str);
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
};
diff --git a/nixos/modules/programs/venus.nix b/nixos/modules/programs/venus.nix
index 3b5ae07e82f7..ca3188b18199 100644
--- a/nixos/modules/programs/venus.nix
+++ b/nixos/modules/programs/venus.nix
@@ -41,7 +41,7 @@ in
dates = mkOption {
default = "*:0/15";
- type = types.string;
+ type = types.str;
description = ''
Specification (in the format described by
systemd.time
@@ -52,7 +52,7 @@ in
user = mkOption {
default = "root";
- type = types.string;
+ type = types.str;
description = ''
User for running venus script.
'';
@@ -60,7 +60,7 @@ in
group = mkOption {
default = "root";
- type = types.string;
+ type = types.str;
description = ''
Group for running venus script.
'';
@@ -68,7 +68,7 @@ in
name = mkOption {
default = "NixOS Planet";
- type = types.string;
+ type = types.str;
description = ''
Your planet's name.
'';
@@ -76,7 +76,7 @@ in
link = mkOption {
default = "http://planet.nixos.org";
- type = types.string;
+ type = types.str;
description = ''
Link to the main page.
'';
@@ -84,7 +84,7 @@ in
ownerName = mkOption {
default = "Rok Garbas";
- type = types.string;
+ type = types.str;
description = ''
Your name.
'';
@@ -92,7 +92,7 @@ in
ownerEmail = mkOption {
default = "some@example.com";
- type = types.string;
+ type = types.str;
description = ''
Your e-mail address.
'';
diff --git a/nixos/modules/programs/wvdial.nix b/nixos/modules/programs/wvdial.nix
index 8e7d0e51a4e0..1ed929ed4afa 100644
--- a/nixos/modules/programs/wvdial.nix
+++ b/nixos/modules/programs/wvdial.nix
@@ -24,7 +24,7 @@ in
dialerDefaults = mkOption {
default = "";
- type = types.string;
+ type = types.str;
example = ''Init1 = AT+CGDCONT=1,"IP","internet.t-mobile"'';
description = ''
Contents of the "Dialer Defaults" section of
@@ -40,7 +40,7 @@ in
persist
noauth
'';
- type = types.string;
+ type = types.str;
description = "Default ppp settings for wvdial.";
};
diff --git a/nixos/modules/programs/xfs_quota.nix b/nixos/modules/programs/xfs_quota.nix
index d30a85922cff..90b6304fa999 100644
--- a/nixos/modules/programs/xfs_quota.nix
+++ b/nixos/modules/programs/xfs_quota.nix
@@ -32,25 +32,25 @@ in
};
fileSystem = mkOption {
- type = types.string;
+ type = types.str;
description = "XFS filesystem hosting the xfs_quota project.";
default = "/";
};
path = mkOption {
- type = types.string;
+ type = types.str;
description = "Project directory.";
};
sizeSoftLimit = mkOption {
- type = types.nullOr types.string;
+ type = types.nullOr types.str;
default = null;
example = "30g";
description = "Soft limit of the project size";
};
sizeHardLimit = mkOption {
- type = types.nullOr types.string;
+ type = types.nullOr types.str;
default = null;
example = "50g";
description = "Hard limit of the project size.";
diff --git a/nixos/modules/security/pam.nix b/nixos/modules/security/pam.nix
index 474b93b4984d..88760574cbc6 100644
--- a/nixos/modules/security/pam.nix
+++ b/nixos/modules/security/pam.nix
@@ -419,7 +419,7 @@ in
users.motd = mkOption {
default = null;
example = "Today is Sweetmorn, the 4th day of The Aftermath in the YOLD 3178.";
- type = types.nullOr types.string;
+ type = types.nullOr types.lines;
description = "Message of the day shown to users when they log in.";
};
diff --git a/nixos/modules/security/prey.nix b/nixos/modules/security/prey.nix
index d7d438103a2c..1c643f2e1a57 100644
--- a/nixos/modules/security/prey.nix
+++ b/nixos/modules/security/prey.nix
@@ -24,7 +24,7 @@ in {
};
deviceKey = mkOption {
- type = types.string;
+ type = types.str;
description = ''
Device key obtained by visiting
@@ -33,7 +33,7 @@ in {
};
apiKey = mkOption {
- type = types.string;
+ type = types.str;
description = ''
API key obtained from
.
diff --git a/nixos/modules/services/monitoring/smartd.nix b/nixos/modules/services/monitoring/smartd.nix
index 61ba16123252..1017005226b2 100644
--- a/nixos/modules/services/monitoring/smartd.nix
+++ b/nixos/modules/services/monitoring/smartd.nix
@@ -119,7 +119,7 @@ in
recipient = mkOption {
default = "root";
- type = types.string;
+ type = types.str;
description = "Recipient of the notification messages.";
};
@@ -153,7 +153,7 @@ in
display = mkOption {
default = ":${toString config.services.xserver.display}";
- type = types.string;
+ type = types.str;
description = "DISPLAY to send X11 notifications to.";
};
};
diff --git a/nixos/modules/system/boot/loader/efi.nix b/nixos/modules/system/boot/loader/efi.nix
index 241cfc7e836d..726634e664d7 100644
--- a/nixos/modules/system/boot/loader/efi.nix
+++ b/nixos/modules/system/boot/loader/efi.nix
@@ -15,7 +15,7 @@ with lib;
efiSysMountPoint = mkOption {
default = "/boot";
- type = types.string;
+ type = types.str;
description = "Where the EFI System Partition is mounted.";
};
diff --git a/nixos/modules/system/boot/luksroot.nix b/nixos/modules/system/boot/luksroot.nix
index 1b4f0d401e6d..4a14ff1879c9 100644
--- a/nixos/modules/system/boot/luksroot.nix
+++ b/nixos/modules/system/boot/luksroot.nix
@@ -242,20 +242,20 @@ in
name = mkOption {
example = "luksroot";
- type = types.string;
+ type = types.str;
description = "Named to be used for the generated device in /dev/mapper.";
};
device = mkOption {
example = "/dev/sda2";
- type = types.string;
+ type = types.str;
description = "Path of the underlying block device.";
};
header = mkOption {
default = null;
example = "/root/header.img";
- type = types.nullOr types.string;
+ type = types.nullOr types.str;
description = ''
The name of the file or block device that
should be used as header for the encrypted device.
@@ -265,7 +265,7 @@ in
keyFile = mkOption {
default = null;
example = "/dev/sdb1";
- type = types.nullOr types.string;
+ type = types.nullOr types.str;
description = ''
The name of the file (can be a raw device or a partition) that
should be used as the decryption key for the encrypted device. If
@@ -349,7 +349,7 @@ in
ramfsMountPoint = mkOption {
default = "/crypt-ramfs";
- type = types.string;
+ type = types.str;
description = "Path where the ramfs used to update the LUKS key will be mounted during early boot.";
};
@@ -369,19 +369,19 @@ in
fsType = mkOption {
default = "vfat";
- type = types.string;
+ type = types.str;
description = "The filesystem of the unencrypted device.";
};
mountPoint = mkOption {
default = "/crypt-storage";
- type = types.string;
+ type = types.str;
description = "Path where the unencrypted device will be mounted during early boot.";
};
path = mkOption {
default = "/crypt-storage/default";
- type = types.string;
+ type = types.str;
description = ''
Absolute path of the salt on the unencrypted device with
that device's root directory as "/".
diff --git a/nixos/modules/tasks/encrypted-devices.nix b/nixos/modules/tasks/encrypted-devices.nix
index 0370e36fbec2..8b5dd22fd380 100644
--- a/nixos/modules/tasks/encrypted-devices.nix
+++ b/nixos/modules/tasks/encrypted-devices.nix
@@ -22,21 +22,21 @@ let
blkDev = mkOption {
default = null;
example = "/dev/sda1";
- type = types.uniq (types.nullOr types.string);
+ type = types.nullOr types.str;
description = "Location of the backing encrypted device.";
};
label = mkOption {
default = null;
example = "rootfs";
- type = types.uniq (types.nullOr types.string);
+ type = types.nullOr types.str;
description = "Label of the backing encrypted device.";
};
keyFile = mkOption {
default = null;
example = "/root/.swapkey";
- type = types.uniq (types.nullOr types.string);
+ type = types.nullOr types.str;
description = "File system location of keyfile.";
};
};
diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix
index ce21d9fe7621..ce9e3555b6cd 100644
--- a/nixos/modules/tasks/filesystems.nix
+++ b/nixos/modules/tasks/filesystems.nix
@@ -22,14 +22,14 @@ let
device = mkOption {
default = null;
example = "/dev/sda";
- type = types.uniq (types.nullOr types.string);
+ type = types.nullOr types.str;
description = "Location of the device.";
};
label = mkOption {
default = null;
example = "root-partition";
- type = types.uniq (types.nullOr types.string);
+ type = types.nullOr types.str;
description = "Label of the device (if any).";
};
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix
index a967fc77e686..9931c977e8f0 100644
--- a/nixos/modules/tasks/network-interfaces.nix
+++ b/nixos/modules/tasks/network-interfaces.nix
@@ -499,7 +499,7 @@ in
interface = mkOption {
example = "enp4s0";
- type = types.string;
+ type = types.str;
description = "The interface the macvlan will transmit packets through.";
};
@@ -605,7 +605,7 @@ in
interface = mkOption {
example = "enp4s0";
- type = types.string;
+ type = types.str;
description = "The interface the vlan will transmit packets through.";
};
diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix
index 8d12c5a57fd9..02cf1fe46a55 100644
--- a/nixos/modules/virtualisation/containers.nix
+++ b/nixos/modules/virtualisation/containers.nix
@@ -108,7 +108,7 @@ in
};
hostAddress = mkOption {
- type = types.nullOr types.string;
+ type = types.nullOr types.str;
default = null;
example = "10.231.136.1";
description = ''
@@ -117,7 +117,7 @@ in
};
localAddress = mkOption {
- type = types.nullOr types.string;
+ type = types.nullOr types.str;
default = null;
example = "10.231.136.2";
description = ''
diff --git a/nixos/modules/virtualisation/docker.nix b/nixos/modules/virtualisation/docker.nix
index ba078cc0a11f..0115b972e80d 100644
--- a/nixos/modules/virtualisation/docker.nix
+++ b/nixos/modules/virtualisation/docker.nix
@@ -67,7 +67,7 @@ in
postStart =
mkOption {
- type = types.string;
+ type = types.lines;
default = ''
while ! [ -e /var/run/docker.sock ]; do
sleep 0.1