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