diff options
author | Sandro <sandro.jaeckel@gmail.com> | 2021-06-15 14:40:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-15 14:40:21 +0200 |
commit | 2b49e4e735c6a7199760df1470fed2a6c7ff4e0c (patch) | |
tree | 40b69c8f266b8b0846a51cd1e05478bcc9b3aab8 | |
parent | b74fb39d95d343f255cc7578c84c3781e161f442 (diff) | |
parent | b922fa959b06179c712f20f2d3c8f71cffe95abb (diff) | |
download | nixpkgs-2b49e4e735c6a7199760df1470fed2a6c7ff4e0c.tar nixpkgs-2b49e4e735c6a7199760df1470fed2a6c7ff4e0c.tar.gz nixpkgs-2b49e4e735c6a7199760df1470fed2a6c7ff4e0c.tar.bz2 nixpkgs-2b49e4e735c6a7199760df1470fed2a6c7ff4e0c.tar.lz nixpkgs-2b49e4e735c6a7199760df1470fed2a6c7ff4e0c.tar.xz nixpkgs-2b49e4e735c6a7199760df1470fed2a6c7ff4e0c.tar.zst nixpkgs-2b49e4e735c6a7199760df1470fed2a6c7ff4e0c.zip |
Merge pull request #107728 from nessdoor/master
-rw-r--r-- | nixos/modules/config/swap.nix | 13 | ||||
-rw-r--r-- | nixos/modules/tasks/filesystems.nix | 7 |
2 files changed, 18 insertions, 2 deletions
diff --git a/nixos/modules/config/swap.nix b/nixos/modules/config/swap.nix index 59bc9e9d11e..a37b46b8c46 100644 --- a/nixos/modules/config/swap.nix +++ b/nixos/modules/config/swap.nix @@ -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; diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix index 2949c82df8f..d274a38a270 100644 --- a/nixos/modules/tasks/filesystems.nix +++ b/nixos/modules/tasks/filesystems.nix @@ -254,8 +254,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! # |