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 ./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;

View File

@ -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 <literal>none</literal>,
<literal>rgb</literal>, <literal>bgr</literal>,
@ -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 <literal>none</literal>,
<literal>default</literal>, <literal>light</literal>, or

View File

@ -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 <literal>hard_open</literal>, 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).

View File

@ -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);
};

View File

@ -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);
};

View File

@ -41,7 +41,7 @@ in
dates = mkOption {
default = "*:0/15";
type = types.string;
type = types.str;
description = ''
Specification (in the format described by
<citerefentry><refentrytitle>systemd.time</refentrytitle>
@ -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.
'';

View File

@ -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.";
};

View File

@ -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.";

View File

@ -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.";
};

View File

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

View File

@ -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.";
};
};

View File

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

View File

@ -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 "/".

View File

@ -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.";
};
};

View File

@ -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).";
};

View File

@ -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.";
};

View File

@ -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 = ''

View File

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