summary refs log tree commit diff
path: root/nixos/modules/tasks
diff options
context:
space:
mode:
authorTomas Antonio Lopez <entropy.overseer@entropic.network>2020-12-28 00:09:42 +0900
committerTomas Antonio Lopez <entropy.overseer@entropic.network>2021-05-19 21:23:35 +0900
commitb922fa959b06179c712f20f2d3c8f71cffe95abb (patch)
tree9d085950bf39d44d39f0dfa19416496d25488095 /nixos/modules/tasks
parent4226837368068600e6afd11b5cbc6d586c7b5fa9 (diff)
downloadnixpkgs-b922fa959b06179c712f20f2d3c8f71cffe95abb.tar
nixpkgs-b922fa959b06179c712f20f2d3c8f71cffe95abb.tar.gz
nixpkgs-b922fa959b06179c712f20f2d3c8f71cffe95abb.tar.bz2
nixpkgs-b922fa959b06179c712f20f2d3c8f71cffe95abb.tar.lz
nixpkgs-b922fa959b06179c712f20f2d3c8f71cffe95abb.tar.xz
nixpkgs-b922fa959b06179c712f20f2d3c8f71cffe95abb.tar.zst
nixpkgs-b922fa959b06179c712f20f2d3c8f71cffe95abb.zip
nixos/swap: add discardPolicy option
Add option for activating discards on swap partitions (none, once, pages and both).
Diffstat (limited to 'nixos/modules/tasks')
-rw-r--r--nixos/modules/tasks/filesystems.nix7
1 files changed, 5 insertions, 2 deletions
diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix
index e468cb88003..85e3576d05d 100644
--- a/nixos/modules/tasks/filesystems.nix
+++ b/nixos/modules/tasks/filesystems.nix
@@ -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!
         #