Merge pull request #128032 from Artturin/add-swap-options
nixos/swap: add options option
This commit is contained in:
commit
98352288bd
|
@ -287,6 +287,13 @@ rec {
|
||||||
merge = mergeEqualOption;
|
merge = mergeEqualOption;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nonEmptyStr = mkOptionType {
|
||||||
|
name = "nonEmptyStr";
|
||||||
|
description = "non-empty string";
|
||||||
|
check = x: str.check x && builtins.match "[ \t\n]*" x == null;
|
||||||
|
inherit (str) merge;
|
||||||
|
};
|
||||||
|
|
||||||
strMatching = pattern: mkOptionType {
|
strMatching = pattern: mkOptionType {
|
||||||
name = "strMatching ${escapeNixString pattern}";
|
name = "strMatching ${escapeNixString pattern}";
|
||||||
description = "string matching the pattern ${pattern}";
|
description = "string matching the pattern ${pattern}";
|
||||||
|
|
|
@ -127,6 +127,15 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
options = mkOption {
|
||||||
|
default = [ "defaults" ];
|
||||||
|
example = [ "nofail" ];
|
||||||
|
type = types.listOf types.nonEmptyStr;
|
||||||
|
description = ''
|
||||||
|
Options used to mount the swap.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
deviceName = mkOption {
|
deviceName = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
internal = true;
|
internal = true;
|
||||||
|
|
|
@ -255,7 +255,7 @@ in
|
||||||
# https://wiki.archlinux.org/index.php/fstab#Filepath_spaces
|
# https://wiki.archlinux.org/index.php/fstab#Filepath_spaces
|
||||||
escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string;
|
escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string;
|
||||||
swapOptions = sw: concatStringsSep "," (
|
swapOptions = sw: concatStringsSep "," (
|
||||||
[ "defaults" ]
|
sw.options
|
||||||
++ optional (sw.priority != null) "pri=${toString sw.priority}"
|
++ optional (sw.priority != null) "pri=${toString sw.priority}"
|
||||||
++ optional (sw.discardPolicy != null) "discard${optionalString (sw.discardPolicy != "both") "=${toString sw.discardPolicy}"}"
|
++ optional (sw.discardPolicy != null) "discard${optionalString (sw.discardPolicy != "both") "=${toString sw.discardPolicy}"}"
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue