From 80a1336bb9e958564b26e2b6e43fe22004cb4a4e Mon Sep 17 00:00:00 2001 From: oxalica Date: Tue, 23 Feb 2021 00:56:27 +0800 Subject: [PATCH] nixos/filesystems: always write mount options for swap devices According to fstab(5), unlike last two fields `fs_freq` and `fs_passno`, the 4-th field `fs_mntops` is NOT optional, though it works when omitted. For best-practice and easier to be parsed by other programs, we should always write `defaults` as default mount options for swap devices. --- nixos/modules/tasks/filesystems.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix index a9b5b134d88..e468cb88003 100644 --- a/nixos/modules/tasks/filesystems.nix +++ b/nixos/modules/tasks/filesystems.nix @@ -22,8 +22,6 @@ let # their assertions too (attrValues config.fileSystems); - prioOption = prio: optionalString (prio != null) " pri=${toString prio}"; - specialFSTypes = [ "proc" "sysfs" "tmpfs" "ramfs" "devtmpfs" "devpts" ]; coreFileSystemOpts = { name, config, ... }: { @@ -240,6 +238,8 @@ 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}"; in '' # This is a generated file. Do not edit! # @@ -262,7 +262,7 @@ in # Swap devices. ${flip concatMapStrings config.swapDevices (sw: - "${sw.realDevice} none swap${prioOption sw.priority}\n" + "${sw.realDevice} none swap ${swapOptions sw}\n" )} '';