nixos/tasks/lvm: add dmeventd and lvmthin support
Introduce a pkgs.lvm2_dmeventd that contains dmeventd support, and enable if services.lvm.dmeventd.enable is true.
This commit is contained in:
parent
9f83907013
commit
1a1e7237de
@ -1,17 +1,70 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf (!config.boot.isContainer) {
|
||||
|
||||
environment.systemPackages = [ pkgs.lvm2 ];
|
||||
|
||||
services.udev.packages = [ pkgs.lvm2 ];
|
||||
|
||||
let
|
||||
cfg = config.services.lvm;
|
||||
in {
|
||||
options.services.lvm = {
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = if cfg.dmeventd.enable then pkgs.lvm2_dmeventd else pkgs.lvm2;
|
||||
internal = true;
|
||||
defaultText = "pkgs.lvm2";
|
||||
description = ''
|
||||
This option allows you to override the LVM package that's used on the system
|
||||
(udev rules, tmpfiles, systemd services).
|
||||
Defaults to pkgs.lvm2, or pkgs.lvm2_dmeventd if dmeventd is enabled.
|
||||
'';
|
||||
};
|
||||
dmeventd.enable = mkEnableOption "the LVM dmevent daemon";
|
||||
boot.thin.enable = mkEnableOption "support for booting from ThinLVs";
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
(mkIf (!config.boot.isContainer) {
|
||||
environment.etc."tmpfiles.d/lvm2.conf".source = "${cfg.package}/lib/tmpfiles.d/lvm2.conf";
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
systemd.packages = [ cfg.package ];
|
||||
|
||||
# TODO: update once https://github.com/NixOS/nixpkgs/pull/93006 was merged
|
||||
services.udev.packages = [ cfg.package.out ];
|
||||
})
|
||||
(mkIf cfg.dmeventd.enable {
|
||||
systemd.sockets."dm-event".wantedBy = [ "sockets.target" ];
|
||||
systemd.services."lvm2-monitor".wantedBy = [ "sysinit.target" ];
|
||||
|
||||
environment.etc."lvm/lvm.conf".text = ''
|
||||
dmeventd/executable = "${cfg.package}/bin/dmeventd"
|
||||
'';
|
||||
})
|
||||
(mkIf cfg.boot.thin.enable {
|
||||
boot.initrd = {
|
||||
kernelModules = [ "dm-snapshot" "dm-thin-pool" ];
|
||||
|
||||
extraUtilsCommands = ''
|
||||
copy_bin_and_libs ${pkgs.thin-provisioning-tools}/bin/pdata_tools
|
||||
copy_bin_and_libs ${pkgs.thin-provisioning-tools}/bin/thin_check
|
||||
'';
|
||||
};
|
||||
|
||||
environment.etc."lvm/lvm.conf".text = ''
|
||||
global/thin_check_executable = "${pkgs.thin-provisioning-tools}/bin/thin_check"
|
||||
'';
|
||||
})
|
||||
(mkIf (cfg.dmeventd.enable || cfg.boot.thin.enable) {
|
||||
boot.initrd.preLVMCommands = ''
|
||||
mkdir -p /etc/lvm
|
||||
cat << EOF >> /etc/lvm/lvm.conf
|
||||
${optionalString cfg.boot.thin.enable ''
|
||||
global/thin_check_executable = "$(command -v thin_check)"
|
||||
''}
|
||||
${optionalString cfg.dmeventd.enable ''
|
||||
dmeventd/executable = "$(command -v false)"
|
||||
activation/monitoring = 0
|
||||
''}
|
||||
EOF
|
||||
'';
|
||||
})
|
||||
];
|
||||
|
||||
}
|
||||
|
@ -16817,7 +16817,7 @@ in
|
||||
|
||||
directvnc = callPackage ../os-specific/linux/directvnc { };
|
||||
|
||||
dmraid = callPackage ../os-specific/linux/dmraid { };
|
||||
dmraid = callPackage ../os-specific/linux/dmraid { lvm2 = lvm2_dmeventd; };
|
||||
|
||||
drbd = callPackage ../os-specific/linux/drbd { };
|
||||
|
||||
@ -17520,6 +17520,10 @@ in
|
||||
lsscsi = callPackage ../os-specific/linux/lsscsi { };
|
||||
|
||||
lvm2 = callPackage ../os-specific/linux/lvm2 { };
|
||||
lvm2_dmeventd = callPackage ../os-specific/linux/lvm2 {
|
||||
enable_dmeventd = true;
|
||||
enable_cmdlib = true;
|
||||
};
|
||||
|
||||
mbpfan = callPackage ../os-specific/linux/mbpfan { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user