diff --git a/modules/config/swap.nix b/modules/config/swap.nix index a0287c948af..7d4654ae287 100644 --- a/modules/config/swap.nix +++ b/modules/config/swap.nix @@ -58,6 +58,17 @@ with utils; ''; }; + priority = mkOption { + default = null; + example = 2048; + type = types.nullOr types.int; + description = '' + Specify the priority of the swap device. Priority is a value between 0 and 32767. + Higher numbers indicate higher priority. + null lets the kernel choose a priority, which will show up as a negative value. + ''; + }; + }; config = { diff --git a/modules/tasks/filesystems.nix b/modules/tasks/filesystems.nix index a95bb0673a2..cc7f1f40742 100644 --- a/modules/tasks/filesystems.nix +++ b/modules/tasks/filesystems.nix @@ -7,6 +7,8 @@ let fileSystems = attrValues config.fileSystems; + prioOption = prio: optionalString (prio !=null) " pri=${toString prio}"; + fileSystemOpts = { name, ... }: { options = { @@ -167,7 +169,7 @@ in # Swap devices. ${flip concatMapStrings config.swapDevices (sw: - "${sw.device} none swap\n" + "${sw.device} none swap${prioOption sw.priority}\n" )} '';