summary refs log tree commit diff
path: root/nixos/modules/tasks
diff options
context:
space:
mode:
authorWill Fancher <elvishjerricco@gmail.com>2023-05-29 16:14:55 -0400
committerWill Fancher <elvishjerricco@gmail.com>2023-06-04 22:57:22 -0400
commitb497502357c0f944c839e645097f44a7c3279971 (patch)
tree8e14ac025d8ba5e156986d9d2307351e3590684d /nixos/modules/tasks
parent5176a4f11356a338331d82e63563f8510b67317d (diff)
downloadnixpkgs-b497502357c0f944c839e645097f44a7c3279971.tar
nixpkgs-b497502357c0f944c839e645097f44a7c3279971.tar.gz
nixpkgs-b497502357c0f944c839e645097f44a7c3279971.tar.bz2
nixpkgs-b497502357c0f944c839e645097f44a7c3279971.tar.lz
nixpkgs-b497502357c0f944c839e645097f44a7c3279971.tar.xz
nixpkgs-b497502357c0f944c839e645097f44a7c3279971.tar.zst
nixpkgs-b497502357c0f944c839e645097f44a7c3279971.zip
nixos: Use systemd-growfs for autoResize
Diffstat (limited to 'nixos/modules/tasks')
-rw-r--r--nixos/modules/tasks/filesystems.nix23
-rw-r--r--nixos/modules/tasks/filesystems/f2fs.nix5
2 files changed, 15 insertions, 13 deletions
diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix
index 3f8f9b6c80d..7cb2ca23fa4 100644
--- a/nixos/modules/tasks/filesystems.nix
+++ b/nixos/modules/tasks/filesystems.nix
@@ -137,7 +137,7 @@ let
     };
 
     config.options = mkMerge [
-      (mkIf config.autoResize [ "x-nixos.autoresize" ])
+      (mkIf config.autoResize [ "x-systemd.growfs" ])
       (mkIf config.autoFormat [ "x-systemd.makefs" ])
       (mkIf (utils.fsNeededForBoot config) [ "x-initrd.mount" ])
     ];
@@ -187,22 +187,20 @@ let
       skipCheck = fs: fs.noCheck || fs.device == "none" || builtins.elem fs.fsType fsToSkipCheck || isBindMount fs;
       # https://wiki.archlinux.org/index.php/fstab#Filepath_spaces
       escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string;
-    in fstabFileSystems: { rootPrefix ? "", extraOpts ? (fs: []) }: concatMapStrings (fs:
+    in fstabFileSystems: { rootPrefix ? "" }: concatMapStrings (fs:
       (optionalString (isBindMount fs) (escape rootPrefix))
       + (if fs.device != null then escape fs.device
          else if fs.label != null then "/dev/disk/by-label/${escape fs.label}"
          else throw "No device specified for mount point ‘${fs.mountPoint}’.")
       + " " + escape fs.mountPoint
       + " " + fs.fsType
-      + " " + escape (builtins.concatStringsSep "," (fs.options ++ (extraOpts fs)))
+      + " " + escape (builtins.concatStringsSep "," fs.options)
       + " 0 " + (if skipCheck fs then "0" else if fs.mountPoint == "/" then "1" else "2")
       + "\n"
     ) fstabFileSystems;
 
     initrdFstab = pkgs.writeText "initrd-fstab" (makeFstabEntries (filter utils.fsNeededForBoot fileSystems) {
       rootPrefix = "/sysroot";
-      extraOpts = fs:
-        (optional fs.autoResize "x-systemd.growfs");
     });
 
 in
@@ -304,7 +302,13 @@ in
 
     assertions = let
       ls = sep: concatMapStringsSep sep (x: x.mountPoint);
-      notAutoResizable = fs: fs.autoResize && !(hasPrefix "ext" fs.fsType || fs.fsType == "f2fs");
+      resizableFSes = [
+        "ext3"
+        "ext4"
+        "btrfs"
+        "xfs"
+      ];
+      notAutoResizable = fs: fs.autoResize && !(builtins.elem fs.fsType resizableFSes);
     in [
       { assertion = ! (fileSystems' ? cycle);
         message = "The ‘fileSystems’ option can't be topologically sorted: mountpoint dependency path ${ls " -> " fileSystems'.cycle} loops to ${ls ", " fileSystems'.loops}";
@@ -312,8 +316,11 @@ in
       { assertion = ! (any notAutoResizable fileSystems);
         message = let
           fs = head (filter notAutoResizable fileSystems);
-        in
-          "Mountpoint '${fs.mountPoint}': 'autoResize = true' is not supported for 'fsType = \"${fs.fsType}\"':${optionalString (fs.fsType == "auto") " fsType has to be explicitly set and"} only the ext filesystems and f2fs support it.";
+        in ''
+          Mountpoint '${fs.mountPoint}': 'autoResize = true' is not supported for 'fsType = "${fs.fsType}"'
+          ${optionalString (fs.fsType == "auto") "fsType has to be explicitly set and"}
+          only the following support it: ${lib.concatStringsSep ", " resizableFSes}.
+        '';
       }
       {
         assertion = ! (any (fs: fs.formatOptions != null) fileSystems);
diff --git a/nixos/modules/tasks/filesystems/f2fs.nix b/nixos/modules/tasks/filesystems/f2fs.nix
index 1d52861aa39..035784f43df 100644
--- a/nixos/modules/tasks/filesystems/f2fs.nix
+++ b/nixos/modules/tasks/filesystems/f2fs.nix
@@ -15,11 +15,6 @@ in
 
     boot.initrd.extraUtilsCommands = mkIf (inInitrd && !config.boot.initrd.systemd.enable) ''
       copy_bin_and_libs ${pkgs.f2fs-tools}/sbin/fsck.f2fs
-      ${optionalString (any (fs: fs.autoResize) fileSystems) ''
-        # We need f2fs-tools' tools to resize filesystems
-        copy_bin_and_libs ${pkgs.f2fs-tools}/sbin/resize.f2fs
-      ''}
-
     '';
   };
 }