Merge pull request #128032 from Artturin/add-swap-options

nixos/swap: add options option

authored by Robert Hensing and committed by GitHub 98352288 a6d966ae

+17 -1
+7
lib/types.nix
··· 287 merge = mergeEqualOption; 288 }; 289 290 strMatching = pattern: mkOptionType { 291 name = "strMatching ${escapeNixString pattern}"; 292 description = "string matching the pattern ${pattern}";
··· 287 merge = mergeEqualOption; 288 }; 289 290 + nonEmptyStr = mkOptionType { 291 + name = "nonEmptyStr"; 292 + description = "non-empty string"; 293 + check = x: str.check x && builtins.match "[ \t\n]*" x == null; 294 + inherit (str) merge; 295 + }; 296 + 297 strMatching = pattern: mkOptionType { 298 name = "strMatching ${escapeNixString pattern}"; 299 description = "string matching the pattern ${pattern}";
+9
nixos/modules/config/swap.nix
··· 127 ''; 128 }; 129 130 deviceName = mkOption { 131 type = types.str; 132 internal = true;
··· 127 ''; 128 }; 129 130 + options = mkOption { 131 + default = [ "defaults" ]; 132 + example = [ "nofail" ]; 133 + type = types.listOf types.nonEmptyStr; 134 + description = '' 135 + Options used to mount the swap. 136 + ''; 137 + }; 138 + 139 deviceName = mkOption { 140 type = types.str; 141 internal = true;
+1 -1
nixos/modules/tasks/filesystems.nix
··· 255 # https://wiki.archlinux.org/index.php/fstab#Filepath_spaces 256 escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string; 257 swapOptions = sw: concatStringsSep "," ( 258 - [ "defaults" ] 259 ++ optional (sw.priority != null) "pri=${toString sw.priority}" 260 ++ optional (sw.discardPolicy != null) "discard${optionalString (sw.discardPolicy != "both") "=${toString sw.discardPolicy}"}" 261 );
··· 255 # https://wiki.archlinux.org/index.php/fstab#Filepath_spaces 256 escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string; 257 swapOptions = sw: concatStringsSep "," ( 258 + sw.options 259 ++ optional (sw.priority != null) "pri=${toString sw.priority}" 260 ++ optional (sw.discardPolicy != null) "discard${optionalString (sw.discardPolicy != "both") "=${toString sw.discardPolicy}"}" 261 );