nixos/swap: add discardPolicy option
Add option for activating discards on swap partitions (none, once, pages and both).
This commit is contained in:
parent
4226837368
commit
b922fa959b
@ -114,6 +114,19 @@ let
|
||||
'';
|
||||
};
|
||||
|
||||
discardPolicy = mkOption {
|
||||
default = null;
|
||||
example = "once";
|
||||
type = types.nullOr (types.enum ["once" "pages" "both" ]);
|
||||
description = ''
|
||||
Specify the discard policy for the swap device. If "once", then the
|
||||
whole swap space is discarded at swapon invocation. If "pages",
|
||||
asynchronous discard on freed pages is performed, before returning to
|
||||
the available pages pool. With "both", both policies are activated.
|
||||
See swapon(8) for more information.
|
||||
'';
|
||||
};
|
||||
|
||||
deviceName = mkOption {
|
||||
type = types.str;
|
||||
internal = true;
|
||||
|
@ -238,8 +238,11 @@ in
|
||||
skipCheck = fs: fs.noCheck || fs.device == "none" || builtins.elem fs.fsType fsToSkipCheck;
|
||||
# https://wiki.archlinux.org/index.php/fstab#Filepath_spaces
|
||||
escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string;
|
||||
swapOptions = sw: "defaults"
|
||||
+ optionalString (sw.priority != null) ",pri=${toString sw.priority}";
|
||||
swapOptions = sw: concatStringsSep "," (
|
||||
[ "defaults" ]
|
||||
++ optional (sw.priority != null) "pri=${toString sw.priority}"
|
||||
++ optional (sw.discardPolicy != null) "discard${optionalString (sw.discardPolicy != "both") "=${toString sw.discardPolicy}"}"
|
||||
);
|
||||
in ''
|
||||
# This is a generated file. Do not edit!
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user