nixpkgs/nixos/modules/tasks/bcache.nix
Sergei Trofimovich 566e32dd42 nixos/bcache: add a boot.bcache.enable kill switch
My system does not use `bcache` and I sould prever my `systemPackages`
not to have bcache tools.

The change does not change the default but proviced usual `enable` knob.
2023-09-10 14:26:53 +01:00

31 lines
968 B
Nix

{ config, lib, pkgs, ... }: let
cfg = config.boot.bcache;
in {
options.boot.bcache.enable = lib.mkEnableOption (lib.mdDoc "bcache mount support") // {
default = true;
example = false;
};
options.boot.initrd.services.bcache.enable = lib.mkEnableOption (lib.mdDoc "bcache support in the initrd") // {
description = lib.mdDoc ''
*This will only be used when systemd is used in stage 1.*
Whether to enable bcache support in the initrd.
'';
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.bcache-tools ];
services.udev.packages = [ pkgs.bcache-tools ];
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 ];
};
};
}