1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.boot.bcache;
9in
10{
11 options.boot.bcache.enable = lib.mkEnableOption "bcache mount support" // {
12 default = true;
13 example = false;
14 };
15 options.boot.initrd.services.bcache.enable = lib.mkEnableOption "bcache support in the initrd" // {
16 description = ''
17 *This will only be used when systemd is used in stage 1.*
18
19 Whether to enable bcache support in the initrd.
20 '';
21 default = config.boot.initrd.systemd.enable && config.boot.bcache.enable;
22 defaultText = lib.literalExpression "config.boot.initrd.systemd.enable && config.boot.bcache.enable";
23 };
24
25 config = lib.mkIf cfg.enable {
26
27 environment.systemPackages = [ pkgs.bcache-tools ];
28
29 services.udev.packages = [ pkgs.bcache-tools ];
30
31 boot.initrd.extraUdevRulesCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
32 cp -v ${pkgs.bcache-tools}/lib/udev/rules.d/*.rules $out/
33 '';
34
35 boot.initrd.services.udev = lib.mkIf config.boot.initrd.services.bcache.enable {
36 packages = [ pkgs.bcache-tools ];
37 binPackages = [ pkgs.bcache-tools ];
38 };
39 };
40}