at 24.11-pre 2.6 kB view raw
1{ config, lib, pkgs, utils, ... }: 2let 3 requiredStratisFilesystems = lib.attrsets.filterAttrs (_: x: utils.fsNeededForBoot x && x.stratis.poolUuid != null) config.fileSystems; 4in 5{ 6 options = {}; 7 config = lib.mkIf (requiredStratisFilesystems != {}) { 8 assertions = [ 9 { 10 assertion = config.boot.initrd.systemd.enable; 11 message = "stratis root fs requires systemd stage 1"; 12 } 13 ]; 14 boot.initrd = { 15 systemd = { 16 storePaths = [ 17 "${pkgs.stratisd}/lib/udev/stratis-base32-decode" 18 "${pkgs.stratisd}/lib/udev/stratis-str-cmp" 19 "${pkgs.lvm2.bin}/bin/dmsetup" 20 "${pkgs.stratisd}/libexec/stratisd-min" 21 "${pkgs.stratisd.initrd}/bin/stratis-rootfs-setup" 22 ]; 23 packages = [pkgs.stratisd.initrd]; 24 extraBin = { 25 thin_check = "${pkgs."thin-provisioning-tools"}/bin/thin_check"; 26 thin_repair = "${pkgs."thin-provisioning-tools"}/bin/thin_repair"; 27 thin_metadata_size = "${pkgs."thin-provisioning-tools"}/bin/thin_metadata_size"; 28 stratis-min = "${pkgs.stratisd}/bin/stratis-min"; 29 }; 30 services = 31 lib.attrsets.mapAttrs' ( 32 mountPoint: fileSystem: { 33 name = "stratis-setup-${fileSystem.stratis.poolUuid}"; 34 value = { 35 description = "setup for Stratis root filesystem"; 36 unitConfig.DefaultDependencies = "no"; 37 conflicts = [ "shutdown.target" "initrd-switch-root.target" ]; 38 onFailure = [ "emergency.target" ]; 39 unitConfig.OnFailureJobMode = "isolate"; 40 wants = [ "stratisd-min.service" "plymouth-start.service" ]; 41 wantedBy = [ "initrd.target" ]; 42 after = [ "paths.target" "plymouth-start.service" "stratisd-min.service" ]; 43 before = [ "initrd.target" "shutdown.target" "initrd-switch-root.target" ]; 44 environment.STRATIS_ROOTFS_UUID = fileSystem.stratis.poolUuid; 45 serviceConfig = { 46 Type = "oneshot"; 47 ExecStart = "${pkgs.stratisd.initrd}/bin/stratis-rootfs-setup"; 48 RemainAfterExit = "yes"; 49 }; 50 }; 51 } 52 ) requiredStratisFilesystems; 53 }; 54 availableKernelModules = [ "dm-thin-pool" "dm-crypt" ] ++ [ "aes" "aes_generic" "blowfish" "twofish" 55 "serpent" "cbc" "xts" "lrw" "sha1" "sha256" "sha512" 56 "af_alg" "algif_skcipher" 57 ]; 58 services.udev.packages = [ 59 pkgs.stratisd.initrd 60 pkgs.lvm2 61 ]; 62 }; 63 }; 64}