diff --git a/lib/options.nix b/lib/options.nix
index 480837fd1cf1..d649d1160a0a 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -66,6 +66,9 @@ rec {
then head list
else throw "Cannot merge values.";
+
+ /* Obsolete, will remove soon. Specify an option type or apply
+ function instead. */
mergeTypedOption = typeName: predicate: merge: list:
if all predicate list then merge list
else throw "Expect a ${typeName}.";
diff --git a/lib/types.nix b/lib/types.nix
index 07a6cc69fdca..3c21e34879cf 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -71,6 +71,12 @@ rec {
merge = lib.concatStringsSep "\n";
};
+ commas = mkOptionType {
+ name = "string";
+ check = builtins.isString;
+ merge = lib.concatStringsSep ",";
+ };
+
envVar = mkOptionType {
name = "environment variable";
inherit (string) check;
diff --git a/nixos/modules/config/nsswitch.nix b/nixos/modules/config/nsswitch.nix
index ad62b5597be8..2e2125d44f7b 100644
--- a/nixos/modules/config/nsswitch.nix
+++ b/nixos/modules/config/nsswitch.nix
@@ -16,6 +16,7 @@ in
# NSS modules. Hacky!
system.nssModules = mkOption {
+ type = types.listOf types.path;
internal = true;
default = [];
description = ''
@@ -23,7 +24,6 @@ in
several DNS resolution methods to be specified via
/etc/nsswitch.conf.
'';
- merge = mergeListOption;
apply = list:
{
inherit list;
diff --git a/nixos/modules/hardware/pcmcia.nix b/nixos/modules/hardware/pcmcia.nix
index 0dba59734ca7..dea04ac753c6 100644
--- a/nixos/modules/hardware/pcmcia.nix
+++ b/nixos/modules/hardware/pcmcia.nix
@@ -18,16 +18,16 @@ in
hardware.pcmcia = {
enable = mkOption {
+ type = types.bool;
default = false;
- merge = mergeEnableOption;
description = ''
Enable this option to support PCMCIA card.
'';
};
firmware = mkOption {
+ type = types.listOf types.path;
default = [];
- merge = mergeListOption;
description = ''
List of firmware used to handle specific PCMCIA card.
'';
diff --git a/nixos/modules/misc/assertions.nix b/nixos/modules/misc/assertions.nix
index 229f8f278608..5fb88308b776 100644
--- a/nixos/modules/misc/assertions.nix
+++ b/nixos/modules/misc/assertions.nix
@@ -15,10 +15,10 @@ in
options = {
assertions = mkOption {
+ type = types.listOf types.unspecified;
internal = true;
default = [];
example = [ { assertion = false; message = "you can't enable this for that reason"; } ];
- merge = pkgs.lib.mergeListOption;
description = ''
This option allows modules to express conditions that must
hold for the evaluation of the system configuration to
diff --git a/nixos/modules/security/apparmor.nix b/nixos/modules/security/apparmor.nix
index d4aa0598dd3d..b9f151590028 100644
--- a/nixos/modules/security/apparmor.nix
+++ b/nixos/modules/security/apparmor.nix
@@ -15,6 +15,7 @@ with pkgs.lib;
security.apparmor = {
enable = mkOption {
+ type = types.bool;
default = false;
description = ''
Enable AppArmor application security system. Enable only if
@@ -23,8 +24,8 @@ with pkgs.lib;
};
profiles = mkOption {
+ type = types.listOf types.path;
default = [];
- merge = mergeListOption;
description = ''
List of file names of AppArmor profiles.
'';
diff --git a/nixos/modules/services/audio/alsa.nix b/nixos/modules/services/audio/alsa.nix
index 6c53ef46ab91..d021b8bd3ba9 100644
--- a/nixos/modules/services/audio/alsa.nix
+++ b/nixos/modules/services/audio/alsa.nix
@@ -20,14 +20,15 @@ in
sound = {
enable = mkOption {
+ type = types.bool;
default = true;
description = ''
Whether to enable ALSA sound.
'';
- merge = mergeEnableOption;
};
enableOSSEmulation = mkOption {
+ type = types.bool;
default = true;
description = ''
Whether to enable ALSA OSS emulation (with certain cards sound mixing may not work!).
diff --git a/nixos/modules/services/hardware/udev.nix b/nixos/modules/services/hardware/udev.nix
index 37dba8ce71dc..75f01fbc5a95 100644
--- a/nixos/modules/services/hardware/udev.nix
+++ b/nixos/modules/services/hardware/udev.nix
@@ -126,8 +126,8 @@ in
services.udev = {
packages = mkOption {
+ type = types.listOf types.path;
default = [];
- merge = mergeListOption;
description = ''
List of packages containing udev rules.
All files found in
@@ -138,8 +138,8 @@ in
};
path = mkOption {
+ type = types.listOf types.path;
default = [];
- merge = mergeListOption;
description = ''
Packages added to the PATH environment variable when
executing programs from Udev rules.
@@ -162,9 +162,9 @@ in
};
hardware.firmware = mkOption {
+ type = types.listOf types.path;
default = [];
example = [ "/root/my-firmware" ];
- merge = mergeListOption;
description = ''
List of directories containing firmware files. Such files
will be loaded automatically if the kernel asks for them
diff --git a/nixos/modules/services/logging/logstash.nix b/nixos/modules/services/logging/logstash.nix
index 2f0eea505267..79bdf4f7bbca 100644
--- a/nixos/modules/services/logging/logstash.nix
+++ b/nixos/modules/services/logging/logstash.nix
@@ -99,7 +99,7 @@ in
mkHash functions, which take a string representation of a float and an
attrset, respectively.
'';
- merge = mergeConfigs;
+ apply = mergeConfigs;
};
filterConfig = mkOption {
@@ -109,7 +109,7 @@ in
representing a logstash configuration's filter section.
See inputConfig description for details.
'';
- merge = mergeConfigs;
+ apply = mergeConfigs;
};
outputConfig = mkOption {
@@ -119,7 +119,7 @@ in
representing a logstash configuration's output section.
See inputConfig description for details.
'';
- merge = mergeConfigs;
+ apply = mergeConfigs;
};
};
};
diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix
index e98f63f68863..d78c7fe2822e 100644
--- a/nixos/modules/services/misc/nix-daemon.nix
+++ b/nixos/modules/services/misc/nix-daemon.nix
@@ -56,8 +56,8 @@ in
options = {
environment.nix = mkOption {
+ type = types.path;
default = pkgs.nix;
- merge = mergeOneOption;
description = ''
This option specifies the Nix package instance to use throughout the system.
'';
diff --git a/nixos/modules/services/monitoring/smartd.nix b/nixos/modules/services/monitoring/smartd.nix
index de07dc0dbaa6..b0619a161751 100644
--- a/nixos/modules/services/monitoring/smartd.nix
+++ b/nixos/modules/services/monitoring/smartd.nix
@@ -20,8 +20,8 @@ let
default = "";
example = "-d sat";
type = types.string;
- merge = pkgs.lib.concatStringsSep " ";
- description = "Options that determine how smartd monitors the device";
+ apply = pkgs.lib.concatStringsSep " ";
+ description = "Options that determine how smartd monitors the device.";
};
};
diff --git a/nixos/modules/services/networking/networkmanager.nix b/nixos/modules/services/networking/networkmanager.nix
index 1d5682f5f3fb..ad6f9858aaf6 100644
--- a/nixos/modules/services/networking/networkmanager.nix
+++ b/nixos/modules/services/networking/networkmanager.nix
@@ -64,8 +64,8 @@ in {
networking.networkmanager = {
enable = mkOption {
+ type = types.bool;
default = false;
- merge = mergeEnableOption;
description = ''
Whether to use NetworkManager to obtain an IP address and other
configuration for all network interfaces that are not manually
@@ -76,11 +76,11 @@ in {
};
packages = mkOption {
+ type = types.listOf types.path;
default = [ ];
description = ''
Extra packages that provide NetworkManager plugins.
'';
- merge = mergeListOption;
apply = list: [ networkmanager modemmanager wpa_supplicant ] ++ list;
};
diff --git a/nixos/modules/services/system/dbus.nix b/nixos/modules/services/system/dbus.nix
index 196fa40c551f..40d0853d19d5 100644
--- a/nixos/modules/services/system/dbus.nix
+++ b/nixos/modules/services/system/dbus.nix
@@ -68,12 +68,12 @@ in
services.dbus = {
enable = mkOption {
+ type = types.bool;
default = true;
description = ''
Whether to start the D-Bus message bus daemon, which is
required by many other system services and applications.
'';
- merge = pkgs.lib.mergeEnableOption;
};
packages = mkOption {
diff --git a/nixos/modules/services/x11/desktop-managers/default.nix b/nixos/modules/services/x11/desktop-managers/default.nix
index 0fea74d5ba73..3578d702b285 100644
--- a/nixos/modules/services/x11/desktop-managers/default.nix
+++ b/nixos/modules/services/x11/desktop-managers/default.nix
@@ -50,10 +50,10 @@ in
};
default = mkOption {
+ type = types.uniq types.string;
default = "";
example = "none";
description = "Default desktop manager loaded if none have been chosen.";
- merge = mergeOneOption;
apply = defaultDM:
if defaultDM == "" && cfg.session.list != [] then
(head cfg.session.list).name
diff --git a/nixos/modules/services/x11/window-managers/default.nix b/nixos/modules/services/x11/window-managers/default.nix
index c201b789ae48..e856a9e20798 100644
--- a/nixos/modules/services/x11/window-managers/default.nix
+++ b/nixos/modules/services/x11/window-managers/default.nix
@@ -40,10 +40,10 @@ in
};
default = mkOption {
+ type = types.uniq types.string;
default = "none";
example = "wmii";
description = "Default window manager loaded if none have been chosen.";
- merge = mergeOneOption;
apply = defaultWM:
if any (w: w.name == defaultWM) cfg.session then
defaultWM
diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix
index a04914bedaf7..7b1c7d611d35 100644
--- a/nixos/modules/system/activation/top-level.nix
+++ b/nixos/modules/system/activation/top-level.nix
@@ -172,9 +172,9 @@ in
};
system.extraSystemBuilderCmds = mkOption {
+ type = types.lines;
internal = true;
default = "";
- merge = concatStringsSep "\n";
description = ''
This code will be added to the builder creating the system store path.
'';
diff --git a/nixos/modules/system/boot/kernel.nix b/nixos/modules/system/boot/kernel.nix
index 0a3368ae4167..4cea6279e507 100644
--- a/nixos/modules/system/boot/kernel.nix
+++ b/nixos/modules/system/boot/kernel.nix
@@ -117,6 +117,7 @@ in
};
system.modulesTree = mkOption {
+ type = types.listOf types.path;
internal = true;
default = [];
description = ''
@@ -124,7 +125,6 @@ in
built outside of the kernel. Combine these into a single tree of
symlinks because modprobe only supports one directory.
'';
- merge = mergeListOption;
# Convert the list of path to only one path.
apply = pkgs.aggregateModules;
};
diff --git a/nixos/modules/system/boot/systemd-unit-options.nix b/nixos/modules/system/boot/systemd-unit-options.nix
index 5c1fe34572ca..d18c5d864174 100644
--- a/nixos/modules/system/boot/systemd-unit-options.nix
+++ b/nixos/modules/system/boot/systemd-unit-options.nix
@@ -319,8 +319,7 @@ rec {
options = mkOption {
default = "";
example = "noatime";
- type = types.string;
- merge = concatStringsSep ",";
+ type = types.commas;
description = "Options used to mount the file system.";
};
diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix
index 6e3d019ea939..2b4fe582c372 100644
--- a/nixos/modules/tasks/filesystems.nix
+++ b/nixos/modules/tasks/filesystems.nix
@@ -43,8 +43,7 @@ let
options = mkOption {
default = "defaults,relatime";
example = "data=journal";
- type = types.string;
- merge = pkgs.lib.concatStringsSep ",";
+ type = types.commas;
description = "Options used to mount the file system.";
};
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix
index 0177d6396dfa..0767c3db1fec 100644
--- a/nixos/modules/tasks/network-interfaces.nix
+++ b/nixos/modules/tasks/network-interfaces.nix
@@ -220,8 +220,8 @@ in
};
networking.useDHCP = mkOption {
+ type = types.bool;
default = true;
- merge = mergeEnableOption;
description = ''
Whether to use DHCP to obtain an IP address and other
configuration for all network interfaces that are not manually