From f8ed5f30c0d34714c4e82b221e083a83c0e5f0f5 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Wed, 10 Sep 2025 02:00:08 -0400 Subject: [PATCH] nixos/filesystems: Remove `default = "auto"` from `fsType` NixOS has traditionally enabled the `ext` family of file systems by default. Originally, when switching to systemd initrd, we wanted to transition to making this explicit so that initrds could be made without `ext`. The problem is that anyone with `fsType = "auto";` for an `ext` file system in initrd will fail to boot, which is not really an acceptable regression as we switch to systemd initrd by default. By removing `default = "auto"` from `fsType`, we rule out the vast majority of these regressions as eval errors, since most users of `fsType = "auto"` for ext file systems are using it because of the default value. In hindsight, this is probably what #225352 was really about. --- flake.nix | 1 + nixos/doc/manual/release-notes/rl-2605.section.md | 2 ++ nixos/modules/installer/cd-dvd/iso-image.nix | 1 + nixos/modules/system/activation/test.nix | 10 ++++++++-- nixos/modules/system/service/systemd/test.nix | 5 ++++- nixos/modules/tasks/filesystems.nix | 1 - nixos/modules/virtualisation/qemu-vm.nix | 1 + nixos/release.nix | 6 +++++- nixos/tests/appliance-repart-image-verity-store.nix | 1 + nixos/tests/early-mount-options.nix | 1 + nixos/tests/grow-partition.nix | 1 + nixos/tests/image-contents.nix | 5 ++++- nixos/tests/non-default-filesystems.nix | 2 ++ nixos/tests/qemu-vm-external-disk-image.nix | 1 + nixos/tests/systemd-initrd-luks-password.nix | 5 ++++- nixos/tests/systemd-initrd-luks-unl0kr.nix | 5 ++++- nixos/tests/vm-variant.nix | 5 ++++- pkgs/test/nixos-functions/default.nix | 5 ++++- 18 files changed, 48 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index beced0fef048..b8e348845bc8 100644 --- a/flake.nix +++ b/flake.nix @@ -144,6 +144,7 @@ nixpkgs.hostPlatform = "x86_64-linux"; boot.loader.grub.enable = false; fileSystems."/".device = "nodev"; + fileSystems."/".fsType = "none"; # See https://search.nixos.org/options?show=system.stateVersion&query=stateversion system.stateVersion = lib.trivial.release; # DON'T do this in real configs! } diff --git a/nixos/doc/manual/release-notes/rl-2605.section.md b/nixos/doc/manual/release-notes/rl-2605.section.md index 5220d49e71e2..cb652eefa050 100644 --- a/nixos/doc/manual/release-notes/rl-2605.section.md +++ b/nixos/doc/manual/release-notes/rl-2605.section.md @@ -135,6 +135,8 @@ - The packages `iw` and `wirelesstools` (`iwconfig`, `iwlist`, etc.) are no longer installed implicitly if wireless networking has been enabled. +- The `fileSystems..fsType` option no longer has a default value and must be specified by the user. The value `"auto"` still works as before, though its use is generally discouraged. + - `services.uptime` has been removed because the package it relies on does not exist anymore in nixpkgs. - `services.kubernetes.addons.dns.coredns` has been renamed to `services.kubernetes.addons.dns.corednsImage` and now expects a diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index cf96b1abe880..e1c9941c6c1d 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -796,6 +796,7 @@ in "/dev/disk/by-label/${config.isoImage.volumeID}" else "/dev/root"; + fsType = "iso9660"; neededForBoot = true; noCheck = true; }; diff --git a/nixos/modules/system/activation/test.nix b/nixos/modules/system/activation/test.nix index ca399e5aeb4a..7217859564e0 100644 --- a/nixos/modules/system/activation/test.nix +++ b/nixos/modules/system/activation/test.nix @@ -13,7 +13,10 @@ let text = "${expect.dev}"; }; documentation.enable = false; - fileSystems."/".device = "ignore-root-device"; + fileSystems."/" = { + device = "ignore-root-device"; + fsType = "none"; + }; boot.loader.grub.enable = false; # Don't do this in an actual config @@ -26,7 +29,10 @@ let system.forbiddenDependenciesRegexes = [ "-dev$" ]; system.extraDependencies = [ expect.dev ]; documentation.enable = false; - fileSystems."/".device = "ignore-root-device"; + fileSystems."/" = { + device = "ignore-root-device"; + fsType = "none"; + }; boot.loader.grub.enable = false; # Don't do this in an actual config diff --git a/nixos/modules/system/service/systemd/test.nix b/nixos/modules/system/service/systemd/test.nix index 17e38536b08d..abd192716b09 100644 --- a/nixos/modules/system/service/systemd/test.nix +++ b/nixos/modules/system/service/systemd/test.nix @@ -93,7 +93,10 @@ let # irrelevant stuff system.stateVersion = "25.05"; - fileSystems."/".device = "/test/dummy"; + fileSystems."/" = { + device = "/test/dummy"; + fsType = "auto"; + }; boot.loader.grub.enable = false; } ); diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix index 714f9d5f6d89..f84807613464 100644 --- a/nixos/modules/tasks/filesystems.nix +++ b/nixos/modules/tasks/filesystems.nix @@ -122,7 +122,6 @@ let }; fsType = mkOption { - default = "auto"; example = "ext3"; type = nonEmptyStr; description = '' diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 5f001e05aa47..83760a2bb4ed 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -1453,6 +1453,7 @@ in else { device = "/nix/.ro-store"; + fsType = "none"; options = [ "bind" ]; } ); diff --git a/nixos/release.nix b/nixos/release.nix index 3d750086cf4b..f89aa205977d 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -172,6 +172,7 @@ let { ... }: { fileSystems."/".device = mkDefault "/dev/sda1"; + fileSystems."/".fsType = mkDefault "auto"; boot.loader.grub.device = mkDefault "/dev/sda"; } ); @@ -476,7 +477,10 @@ rec { modules = singleton ( { ... }: { - fileSystems."/".device = mkDefault "/dev/sda1"; + fileSystems."/" = { + device = mkDefault "/dev/sda1"; + fsType = "ext4"; + }; boot.loader.grub.device = mkDefault "/dev/sda"; system.stateVersion = mkDefault lib.trivial.release; } diff --git a/nixos/tests/appliance-repart-image-verity-store.nix b/nixos/tests/appliance-repart-image-verity-store.nix index ef0fda4f780d..09a0c95703ed 100644 --- a/nixos/tests/appliance-repart-image-verity-store.nix +++ b/nixos/tests/appliance-repart-image-verity-store.nix @@ -32,6 +32,7 @@ # bind-mount the store "/nix/store" = { device = "/usr/nix/store"; + fsType = "none"; options = [ "bind" ]; }; }; diff --git a/nixos/tests/early-mount-options.nix b/nixos/tests/early-mount-options.nix index 5a54c2f38907..f92b37ee2f90 100644 --- a/nixos/tests/early-mount-options.nix +++ b/nixos/tests/early-mount-options.nix @@ -4,6 +4,7 @@ nodes.machine = { virtualisation.fileSystems."/var" = { + fsType = "none"; options = [ "bind" "nosuid" diff --git a/nixos/tests/grow-partition.nix b/nixos/tests/grow-partition.nix index 84ea1312a03e..48b4a9278026 100644 --- a/nixos/tests/grow-partition.nix +++ b/nixos/tests/grow-partition.nix @@ -30,6 +30,7 @@ let fileSystems = { "/".device = rootFsDevice; + "/".fsType = "ext4"; }; # Needed for installing bootloader diff --git a/nixos/tests/image-contents.nix b/nixos/tests/image-contents.nix index 1f2dce786eec..80bcfc57dea5 100644 --- a/nixos/tests/image-contents.nix +++ b/nixos/tests/image-contents.nix @@ -19,7 +19,10 @@ let ../modules/testing/test-instrumentation.nix ../modules/profiles/qemu-guest.nix { - fileSystems."/".device = "/dev/disk/by-label/nixos"; + fileSystems."/" = { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + }; boot.loader.grub.device = "/dev/vda"; boot.loader.timeout = 0; nixpkgs.pkgs = pkgs; diff --git a/nixos/tests/non-default-filesystems.nix b/nixos/tests/non-default-filesystems.nix index 11bf2070464f..d0aeb6bab4a8 100644 --- a/nixos/tests/non-default-filesystems.nix +++ b/nixos/tests/non-default-filesystems.nix @@ -18,6 +18,7 @@ with pkgs.lib; virtualisation.fileSystems."/test-bind-dir/bind" = { device = "/"; neededForBoot = true; + fsType = "none"; options = [ "bind" ]; }; @@ -25,6 +26,7 @@ with pkgs.lib; depends = [ "/nix/store" ]; device = builtins.toFile "empty" ""; neededForBoot = true; + fsType = "none"; options = [ "bind" ]; }; }; diff --git a/nixos/tests/qemu-vm-external-disk-image.nix b/nixos/tests/qemu-vm-external-disk-image.nix index b01cabbadb5d..5c12921f6c56 100644 --- a/nixos/tests/qemu-vm-external-disk-image.nix +++ b/nixos/tests/qemu-vm-external-disk-image.nix @@ -23,6 +23,7 @@ let fileSystems = { "/".device = rootFsDevice; + "/".fsType = "ext4"; }; system.switch.enable = true; diff --git a/nixos/tests/systemd-initrd-luks-password.nix b/nixos/tests/systemd-initrd-luks-password.nix index 4e059f514257..a77fe16ea453 100644 --- a/nixos/tests/systemd-initrd-luks-password.nix +++ b/nixos/tests/systemd-initrd-luks-password.nix @@ -32,7 +32,10 @@ }; virtualisation.rootDevice = "/dev/mapper/cryptroot"; # test mounting device unlocked in initrd after switching root - virtualisation.fileSystems."/cryptroot2".device = "/dev/mapper/cryptroot2"; + virtualisation.fileSystems."/cryptroot2" = { + device = "/dev/mapper/cryptroot2"; + fsType = "auto"; + }; }; }; diff --git a/nixos/tests/systemd-initrd-luks-unl0kr.nix b/nixos/tests/systemd-initrd-luks-unl0kr.nix index 74e74cd95be1..6844357a729f 100644 --- a/nixos/tests/systemd-initrd-luks-unl0kr.nix +++ b/nixos/tests/systemd-initrd-luks-unl0kr.nix @@ -75,7 +75,10 @@ in virtualisation.rootDevice = "/dev/mapper/cryptroot"; virtualisation.fileSystems."/".autoFormat = true; # test mounting device unlocked in initrd after switching root - virtualisation.fileSystems."/cryptroot2".device = "/dev/mapper/cryptroot2"; + virtualisation.fileSystems."/cryptroot2" = { + device = "/dev/mapper/cryptroot2"; + fsType = "auto"; + }; }; }; diff --git a/nixos/tests/vm-variant.nix b/nixos/tests/vm-variant.nix index cfd8ef50a46c..20caea6c0e1b 100644 --- a/nixos/tests/vm-variant.nix +++ b/nixos/tests/vm-variant.nix @@ -10,7 +10,10 @@ let modules = [ { system.stateVersion = "25.05"; - fileSystems."/".device = "/dev/null"; + fileSystems."/" = { + device = "/dev/null"; + fsType = "none"; + }; boot.loader.grub.device = "nodev"; nixpkgs.hostPlatform = pkgs.stdenv.hostPlatform.system; virtualisation.vmVariant.networking.hostName = "vm"; diff --git a/pkgs/test/nixos-functions/default.nix b/pkgs/test/nixos-functions/default.nix index 33d3342f3854..f6c73a712607 100644 --- a/pkgs/test/nixos-functions/default.nix +++ b/pkgs/test/nixos-functions/default.nix @@ -27,7 +27,10 @@ lib.optionalAttrs (stdenv.hostPlatform.isLinux) ( (pkgs.nixos { system.nixos = dummyVersioning; boot.loader.grub.enable = false; - fileSystems."/".device = "/dev/null"; + fileSystems."/" = { + device = "/dev/null"; + fsType = "none"; + }; system.stateVersion = lib.trivial.release; }).toplevel; }