From 4630ad4d26a0b5a8774c9121b2fd42d92bb81eb0 Mon Sep 17 00:00:00 2001 From: Mathijs Kwik Date: Mon, 13 May 2013 23:42:55 +0200 Subject: [PATCH] filesystems: add priority option for swap devices. Useful for setting up raid0-like load balancing for swap. By giving multiple swap devices the same prio. --- modules/config/swap.nix | 11 +++++++++++ modules/tasks/filesystems.nix | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/config/swap.nix b/modules/config/swap.nix index a0287c948af1..7d4654ae2877 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 a95bb0673a23..cc7f1f407420 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" )} '';