2023-10-09 19:29:22 +00:00
|
|
|
{ config, lib, pkgs, ... }: let
|
|
|
|
cfg = config.boot.bcache;
|
|
|
|
in {
|
2024-04-21 15:54:59 +00:00
|
|
|
options.boot.bcache.enable = lib.mkEnableOption "bcache mount support" // {
|
2023-10-09 19:29:22 +00:00
|
|
|
default = true;
|
|
|
|
example = false;
|
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
options.boot.initrd.services.bcache.enable = lib.mkEnableOption "bcache support in the initrd" // {
|
|
|
|
description = ''
|
2023-07-15 17:15:38 +00:00
|
|
|
*This will only be used when systemd is used in stage 1.*
|
|
|
|
|
|
|
|
Whether to enable bcache support in the initrd.
|
|
|
|
'';
|
2022-04-27 09:35:20 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
environment.systemPackages = [ pkgs.bcache-tools ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
services.udev.packages = [ pkgs.bcache-tools ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
boot.initrd.extraUdevRulesCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
|
|
|
|
cp -v ${pkgs.bcache-tools}/lib/udev/rules.d/*.rules $out/
|
|
|
|
'';
|
|
|
|
|
|
|
|
boot.initrd.services.udev = lib.mkIf config.boot.initrd.services.bcache.enable {
|
|
|
|
packages = [ pkgs.bcache-tools ];
|
|
|
|
binPackages = [ pkgs.bcache-tools ];
|
|
|
|
};
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|