Merge pull request #9925 from oxij/nixos-cleanups-and-fixes

nixos types: cleanups and fixes
This commit is contained in:
Jaka Hudoklin 2015-09-19 00:28:49 +02:00
commit e0881324ac
18 changed files with 64 additions and 77 deletions

View File

@ -6,7 +6,7 @@ with import ./attrsets.nix;
with import ./options.nix; with import ./options.nix;
with import ./trivial.nix; with import ./trivial.nix;
with import ./strings.nix; with import ./strings.nix;
with {inherit (import ./modules.nix) mergeDefinitions; }; with {inherit (import ./modules.nix) mergeDefinitions filterOverrides; };
rec { rec {
@ -166,6 +166,23 @@ rec {
substSubModules = m: loaOf (elemType.substSubModules m); 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 { uniq = elemType: mkOptionType {
inherit (elemType) name check; inherit (elemType) name check;
merge = mergeOneOption; merge = mergeOneOption;

View File

@ -108,10 +108,8 @@ with lib;
subpixel = { subpixel = {
rgba = mkOption { rgba = mkOption {
type = types.string // {
check = flip elem ["rgb" "bgr" "vrgb" "vbgr" "none"];
};
default = "rgb"; default = "rgb";
type = types.enum ["rgb" "bgr" "vrgb" "vbgr" "none"];
description = '' description = ''
Subpixel order, one of <literal>none</literal>, Subpixel order, one of <literal>none</literal>,
<literal>rgb</literal>, <literal>bgr</literal>, <literal>rgb</literal>, <literal>bgr</literal>,
@ -120,10 +118,8 @@ with lib;
}; };
lcdfilter = mkOption { lcdfilter = mkOption {
type = types.str // {
check = flip elem ["none" "default" "light" "legacy"];
};
default = "default"; default = "default";
type = types.enum ["none" "default" "light" "legacy"];
description = '' description = ''
FreeType LCD filter, one of <literal>none</literal>, FreeType LCD filter, one of <literal>none</literal>,
<literal>default</literal>, <literal>light</literal>, or <literal>default</literal>, <literal>light</literal>, or

View File

@ -108,7 +108,7 @@ in
extraConfig = mkOption { extraConfig = mkOption {
default = ""; default = "";
type = types.string; type = types.lines;
description = '' description = ''
Extra configuration options that will be added verbatim at Extra configuration options that will be added verbatim at
the end of the nslcd configuration file (nslcd.conf). the end of the nslcd configuration file (nslcd.conf).
@ -120,7 +120,7 @@ in
distinguishedName = mkOption { distinguishedName = mkOption {
default = ""; default = "";
example = "cn=admin,dc=example,dc=com"; example = "cn=admin,dc=example,dc=com";
type = types.string; type = types.str;
description = '' description = ''
The distinguished name to bind to the LDAP server with. If this The distinguished name to bind to the LDAP server with. If this
is not specified, an anonymous bind will be done. is not specified, an anonymous bind will be done.
@ -129,7 +129,7 @@ in
password = mkOption { password = mkOption {
default = "/etc/ldap/bind.password"; default = "/etc/ldap/bind.password";
type = types.string; type = types.str;
description = '' description = ''
The path to a file containing the credentials to use when binding The path to a file containing the credentials to use when binding
to the LDAP server (if not binding anonymously). to the LDAP server (if not binding anonymously).
@ -149,7 +149,7 @@ in
policy = mkOption { policy = mkOption {
default = "hard_open"; default = "hard_open";
type = types.string; type = types.enum [ "hard_open" "hard_init" "soft" ];
description = '' description = ''
Specifies the policy to use for reconnecting to an unavailable Specifies the policy to use for reconnecting to an unavailable
LDAP server. The default is <literal>hard_open</literal>, which LDAP server. The default is <literal>hard_open</literal>, which
@ -168,7 +168,7 @@ in
extraConfig = mkOption { extraConfig = mkOption {
default = ""; default = "";
type = types.string; type = types.lines;
description = '' description = ''
Extra configuration options that will be added verbatim at Extra configuration options that will be added verbatim at
the end of the ldap configuration file (ldap.conf). the end of the ldap configuration file (ldap.conf).

View File

@ -41,20 +41,7 @@ in
strings. The latter is concatenated, interspersed with colon strings. The latter is concatenated, interspersed with colon
characters. characters.
''; '';
type = types.attrsOf (mkOptionType { type = types.attrsOf (types.loeOf types.str);
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;
});
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v); apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
}; };

View File

@ -23,20 +23,7 @@ in
strings. The latter is concatenated, interspersed with colon strings. The latter is concatenated, interspersed with colon
characters. characters.
''; '';
type = types.attrsOf (mkOptionType { type = types.attrsOf (types.loeOf types.str);
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;
});
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v); apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
}; };

View File

@ -41,7 +41,7 @@ in
dates = mkOption { dates = mkOption {
default = "*:0/15"; default = "*:0/15";
type = types.string; type = types.str;
description = '' description = ''
Specification (in the format described by Specification (in the format described by
<citerefentry><refentrytitle>systemd.time</refentrytitle> <citerefentry><refentrytitle>systemd.time</refentrytitle>
@ -52,7 +52,7 @@ in
user = mkOption { user = mkOption {
default = "root"; default = "root";
type = types.string; type = types.str;
description = '' description = ''
User for running venus script. User for running venus script.
''; '';
@ -60,7 +60,7 @@ in
group = mkOption { group = mkOption {
default = "root"; default = "root";
type = types.string; type = types.str;
description = '' description = ''
Group for running venus script. Group for running venus script.
''; '';
@ -68,7 +68,7 @@ in
name = mkOption { name = mkOption {
default = "NixOS Planet"; default = "NixOS Planet";
type = types.string; type = types.str;
description = '' description = ''
Your planet's name. Your planet's name.
''; '';
@ -76,7 +76,7 @@ in
link = mkOption { link = mkOption {
default = "http://planet.nixos.org"; default = "http://planet.nixos.org";
type = types.string; type = types.str;
description = '' description = ''
Link to the main page. Link to the main page.
''; '';
@ -84,7 +84,7 @@ in
ownerName = mkOption { ownerName = mkOption {
default = "Rok Garbas"; default = "Rok Garbas";
type = types.string; type = types.str;
description = '' description = ''
Your name. Your name.
''; '';
@ -92,7 +92,7 @@ in
ownerEmail = mkOption { ownerEmail = mkOption {
default = "some@example.com"; default = "some@example.com";
type = types.string; type = types.str;
description = '' description = ''
Your e-mail address. Your e-mail address.
''; '';

View File

@ -24,7 +24,7 @@ in
dialerDefaults = mkOption { dialerDefaults = mkOption {
default = ""; default = "";
type = types.string; type = types.str;
example = ''Init1 = AT+CGDCONT=1,"IP","internet.t-mobile"''; example = ''Init1 = AT+CGDCONT=1,"IP","internet.t-mobile"'';
description = '' description = ''
Contents of the "Dialer Defaults" section of Contents of the "Dialer Defaults" section of
@ -40,7 +40,7 @@ in
persist persist
noauth noauth
''; '';
type = types.string; type = types.str;
description = "Default ppp settings for wvdial."; description = "Default ppp settings for wvdial.";
}; };

View File

@ -32,25 +32,25 @@ in
}; };
fileSystem = mkOption { fileSystem = mkOption {
type = types.string; type = types.str;
description = "XFS filesystem hosting the xfs_quota project."; description = "XFS filesystem hosting the xfs_quota project.";
default = "/"; default = "/";
}; };
path = mkOption { path = mkOption {
type = types.string; type = types.str;
description = "Project directory."; description = "Project directory.";
}; };
sizeSoftLimit = mkOption { sizeSoftLimit = mkOption {
type = types.nullOr types.string; type = types.nullOr types.str;
default = null; default = null;
example = "30g"; example = "30g";
description = "Soft limit of the project size"; description = "Soft limit of the project size";
}; };
sizeHardLimit = mkOption { sizeHardLimit = mkOption {
type = types.nullOr types.string; type = types.nullOr types.str;
default = null; default = null;
example = "50g"; example = "50g";
description = "Hard limit of the project size."; description = "Hard limit of the project size.";

View File

@ -419,7 +419,7 @@ in
users.motd = mkOption { users.motd = mkOption {
default = null; default = null;
example = "Today is Sweetmorn, the 4th day of The Aftermath in the YOLD 3178."; 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."; description = "Message of the day shown to users when they log in.";
}; };

View File

@ -24,7 +24,7 @@ in {
}; };
deviceKey = mkOption { deviceKey = mkOption {
type = types.string; type = types.str;
description = '' description = ''
<literal>Device key</literal> obtained by visiting <literal>Device key</literal> obtained by visiting
<link xlink:href="https://panel.preyproject.com/devices" /> <link xlink:href="https://panel.preyproject.com/devices" />
@ -33,7 +33,7 @@ in {
}; };
apiKey = mkOption { apiKey = mkOption {
type = types.string; type = types.str;
description = '' description = ''
<literal>API key</literal> obtained from <literal>API key</literal> obtained from
<link xlink:href="https://panel.preyproject.com/profile" />. <link xlink:href="https://panel.preyproject.com/profile" />.

View File

@ -119,7 +119,7 @@ in
recipient = mkOption { recipient = mkOption {
default = "root"; default = "root";
type = types.string; type = types.str;
description = "Recipient of the notification messages."; description = "Recipient of the notification messages.";
}; };
@ -153,7 +153,7 @@ in
display = mkOption { display = mkOption {
default = ":${toString config.services.xserver.display}"; default = ":${toString config.services.xserver.display}";
type = types.string; type = types.str;
description = "DISPLAY to send X11 notifications to."; description = "DISPLAY to send X11 notifications to.";
}; };
}; };

View File

@ -15,7 +15,7 @@ with lib;
efiSysMountPoint = mkOption { efiSysMountPoint = mkOption {
default = "/boot"; default = "/boot";
type = types.string; type = types.str;
description = "Where the EFI System Partition is mounted."; description = "Where the EFI System Partition is mounted.";
}; };

View File

@ -242,20 +242,20 @@ in
name = mkOption { name = mkOption {
example = "luksroot"; example = "luksroot";
type = types.string; type = types.str;
description = "Named to be used for the generated device in /dev/mapper."; description = "Named to be used for the generated device in /dev/mapper.";
}; };
device = mkOption { device = mkOption {
example = "/dev/sda2"; example = "/dev/sda2";
type = types.string; type = types.str;
description = "Path of the underlying block device."; description = "Path of the underlying block device.";
}; };
header = mkOption { header = mkOption {
default = null; default = null;
example = "/root/header.img"; example = "/root/header.img";
type = types.nullOr types.string; type = types.nullOr types.str;
description = '' description = ''
The name of the file or block device that The name of the file or block device that
should be used as header for the encrypted device. should be used as header for the encrypted device.
@ -265,7 +265,7 @@ in
keyFile = mkOption { keyFile = mkOption {
default = null; default = null;
example = "/dev/sdb1"; example = "/dev/sdb1";
type = types.nullOr types.string; type = types.nullOr types.str;
description = '' description = ''
The name of the file (can be a raw device or a partition) that 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 should be used as the decryption key for the encrypted device. If
@ -349,7 +349,7 @@ in
ramfsMountPoint = mkOption { ramfsMountPoint = mkOption {
default = "/crypt-ramfs"; 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."; description = "Path where the ramfs used to update the LUKS key will be mounted during early boot.";
}; };
@ -369,19 +369,19 @@ in
fsType = mkOption { fsType = mkOption {
default = "vfat"; default = "vfat";
type = types.string; type = types.str;
description = "The filesystem of the unencrypted device."; description = "The filesystem of the unencrypted device.";
}; };
mountPoint = mkOption { mountPoint = mkOption {
default = "/crypt-storage"; default = "/crypt-storage";
type = types.string; type = types.str;
description = "Path where the unencrypted device will be mounted during early boot."; description = "Path where the unencrypted device will be mounted during early boot.";
}; };
path = mkOption { path = mkOption {
default = "/crypt-storage/default"; default = "/crypt-storage/default";
type = types.string; type = types.str;
description = '' description = ''
Absolute path of the salt on the unencrypted device with Absolute path of the salt on the unencrypted device with
that device's root directory as "/". that device's root directory as "/".

View File

@ -22,21 +22,21 @@ let
blkDev = mkOption { blkDev = mkOption {
default = null; default = null;
example = "/dev/sda1"; example = "/dev/sda1";
type = types.uniq (types.nullOr types.string); type = types.nullOr types.str;
description = "Location of the backing encrypted device."; description = "Location of the backing encrypted device.";
}; };
label = mkOption { label = mkOption {
default = null; default = null;
example = "rootfs"; example = "rootfs";
type = types.uniq (types.nullOr types.string); type = types.nullOr types.str;
description = "Label of the backing encrypted device."; description = "Label of the backing encrypted device.";
}; };
keyFile = mkOption { keyFile = mkOption {
default = null; default = null;
example = "/root/.swapkey"; example = "/root/.swapkey";
type = types.uniq (types.nullOr types.string); type = types.nullOr types.str;
description = "File system location of keyfile."; description = "File system location of keyfile.";
}; };
}; };

View File

@ -22,14 +22,14 @@ let
device = mkOption { device = mkOption {
default = null; default = null;
example = "/dev/sda"; example = "/dev/sda";
type = types.uniq (types.nullOr types.string); type = types.nullOr types.str;
description = "Location of the device."; description = "Location of the device.";
}; };
label = mkOption { label = mkOption {
default = null; default = null;
example = "root-partition"; example = "root-partition";
type = types.uniq (types.nullOr types.string); type = types.nullOr types.str;
description = "Label of the device (if any)."; description = "Label of the device (if any).";
}; };

View File

@ -499,7 +499,7 @@ in
interface = mkOption { interface = mkOption {
example = "enp4s0"; example = "enp4s0";
type = types.string; type = types.str;
description = "The interface the macvlan will transmit packets through."; description = "The interface the macvlan will transmit packets through.";
}; };
@ -605,7 +605,7 @@ in
interface = mkOption { interface = mkOption {
example = "enp4s0"; example = "enp4s0";
type = types.string; type = types.str;
description = "The interface the vlan will transmit packets through."; description = "The interface the vlan will transmit packets through.";
}; };

View File

@ -108,7 +108,7 @@ in
}; };
hostAddress = mkOption { hostAddress = mkOption {
type = types.nullOr types.string; type = types.nullOr types.str;
default = null; default = null;
example = "10.231.136.1"; example = "10.231.136.1";
description = '' description = ''
@ -117,7 +117,7 @@ in
}; };
localAddress = mkOption { localAddress = mkOption {
type = types.nullOr types.string; type = types.nullOr types.str;
default = null; default = null;
example = "10.231.136.2"; example = "10.231.136.2";
description = '' description = ''

View File

@ -67,7 +67,7 @@ in
postStart = postStart =
mkOption { mkOption {
type = types.string; type = types.lines;
default = '' default = ''
while ! [ -e /var/run/docker.sock ]; do while ! [ -e /var/run/docker.sock ]; do
sleep 0.1 sleep 0.1