From 0d896304de6875b630ff6426cd82781ae9149ad6 Mon Sep 17 00:00:00 2001 From: "Jan B." Date: Tue, 9 Sep 2025 10:38:01 +0200 Subject: [PATCH 1/2] nixos/installer: add option to change fileystem during sd-image creation enables the usage of different filesystems besides EXT4 for the root partition on the sd-card (e.g. BTRFS, XFS, ...) --- nixos/modules/installer/sd-card/sd-image.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nixos/modules/installer/sd-card/sd-image.nix b/nixos/modules/installer/sd-card/sd-image.nix index 7a2e271c4dde..c43f1642cdec 100644 --- a/nixos/modules/installer/sd-card/sd-image.nix +++ b/nixos/modules/installer/sd-card/sd-image.nix @@ -21,7 +21,7 @@ with lib; let - rootfsImage = pkgs.callPackage ../../../lib/make-ext4-fs.nix ( + rootfsImage = pkgs.callPackage config.sdImage.rootFilesystemCreator ( { inherit (config.sdImage) storePaths; compressImage = config.sdImage.compressImage; @@ -128,6 +128,20 @@ in ''; }; + rootFilesystemCreator = mkOption { + type = types.oneOf [ + types.package + types.path + ]; + default = ../../../lib/make-ext4-fs.nix; + example = '' + nixpkgs/nixos/lib/make-btrfs-fs.nix + ''; + description = '' + The filesystem creator used for the root partition. + ''; + }; + firmwareSize = mkOption { type = types.int; # As of 2019-08-18 the Raspberry pi firmware + u-boot takes ~18MiB From f5ae72b1c1049ab6e112b78a04e4b198201745c4 Mon Sep 17 00:00:00 2001 From: "Jan B." Date: Fri, 12 Sep 2025 14:01:46 +0200 Subject: [PATCH 2/2] nixos/installer: add option to override the root filesystem image creator itself allows overriding the process how the filesystem image is created which the resulting sd-card image will use. --- nixos/modules/installer/sd-card/sd-image.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nixos/modules/installer/sd-card/sd-image.nix b/nixos/modules/installer/sd-card/sd-image.nix index c43f1642cdec..b3251f9c6e1d 100644 --- a/nixos/modules/installer/sd-card/sd-image.nix +++ b/nixos/modules/installer/sd-card/sd-image.nix @@ -142,6 +142,15 @@ in ''; }; + rootFilesystemImage = mkOption { + type = types.package; + default = rootfsImage; + description = '' + The finished root partition image with all custom fileystem modifications. + Used to override the filesystem creator itself. + ''; + }; + firmwareSize = mkOption { type = types.int; # As of 2019-08-18 the Raspberry pi firmware + u-boot takes ~18MiB @@ -268,11 +277,11 @@ in echo "file sd-image $img" >> $out/nix-support/hydra-build-products fi - root_fs=${rootfsImage} + root_fs=${config.sdImage.rootFilesystemImage} ${lib.optionalString config.sdImage.compressImage '' root_fs=./root-fs.img echo "Decompressing rootfs image" - zstd -d --no-progress "${rootfsImage}" -o $root_fs + zstd -d --no-progress "${config.sdImage.rootFilesystemImage}" -o $root_fs ''} # Gap in front of the first partition, in MiB