nixos/bcachefs: add boot.bcachefs.package (#442667)

authored by

Masum Reza and committed by
GitHub
85068ca3 57ae4042

+15 -10
+15 -10
nixos/modules/tasks/filesystems/bcachefs.nix
··· 7 7 }: 8 8 9 9 let 10 + cfg = config.boot.bcachefs; 10 11 cfgScrub = config.services.bcachefs.autoScrub; 11 12 12 13 bootFs = lib.filterAttrs ( ··· 146 147 unitConfig.DefaultDependencies = false; 147 148 serviceConfig = { 148 149 Type = "oneshot"; 149 - ExecCondition = "${pkgs.bcachefs-tools}/bin/bcachefs unlock -c \"${device}\""; 150 + ExecCondition = "${cfg.package}/bin/bcachefs unlock -c \"${device}\""; 150 151 Restart = "on-failure"; 151 152 RestartMode = "direct"; 152 153 # Ideally, this service would lock the key on stop. ··· 155 156 }; 156 157 script = 157 158 let 158 - unlock = ''${pkgs.bcachefs-tools}/bin/bcachefs unlock "${device}"''; 159 + unlock = ''${cfg.package}/bin/bcachefs unlock "${device}"''; 159 160 unlockInteractively = ''${config.boot.initrd.systemd.package}/bin/systemd-ask-password --timeout=0 "enter passphrase for ${name}" | exec ${unlock}''; 160 161 in 161 162 if useClevis fs then ··· 196 197 in 197 198 198 199 { 200 + options.boot.bcachefs.package = lib.mkPackageOption pkgs "bcachefs-tools" { } // { 201 + description = "Configured Bcachefs userspace package."; 202 + }; 203 + 199 204 options.services.bcachefs.autoScrub = { 200 205 enable = lib.mkEnableOption "regular bcachefs scrub"; 201 206 ··· 227 232 { 228 233 inherit assertions; 229 234 # needed for systemd-remount-fs 230 - system.fsPackages = [ pkgs.bcachefs-tools ]; 231 - services.udev.packages = [ pkgs.bcachefs-tools ]; 235 + system.fsPackages = [ cfg.package ]; 236 + services.udev.packages = [ cfg.package ]; 232 237 233 238 systemd = { 234 - packages = [ pkgs.bcachefs-tools ]; 239 + packages = [ cfg.package ]; 235 240 services = lib.mapAttrs' (mkUnits "") ( 236 241 lib.filterAttrs (n: fs: (fs.fsType == "bcachefs") && (!utils.fsNeededForBoot fs)) config.fileSystems 237 242 ); ··· 253 258 ]; 254 259 boot.initrd.systemd.extraBin = { 255 260 # do we need this? boot/systemd.nix:566 & boot/systemd/initrd.nix:357 256 - "bcachefs" = "${pkgs.bcachefs-tools}/bin/bcachefs"; 257 - "mount.bcachefs" = "${pkgs.bcachefs-tools}/bin/mount.bcachefs"; 261 + "bcachefs" = "${cfg.package}/bin/bcachefs"; 262 + "mount.bcachefs" = "${cfg.package}/bin/mount.bcachefs"; 258 263 }; 259 264 boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) '' 260 - copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/bcachefs 261 - copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/mount.bcachefs 265 + copy_bin_and_libs ${cfg.package}/bin/bcachefs 266 + copy_bin_and_libs ${cfg.package}/bin/mount.bcachefs 262 267 ''; 263 268 boot.initrd.extraUtilsCommandsTest = lib.mkIf (!config.boot.initrd.systemd.enable) '' 264 269 $out/bin/bcachefs version ··· 348 353 "sleep.target" 349 354 ]; 350 355 351 - script = "${lib.getExe pkgs.bcachefs-tools} data scrub ${fs}"; 356 + script = "${lib.getExe cfg.package} data scrub ${fs}"; 352 357 353 358 serviceConfig = { 354 359 Type = "oneshot";