2020-04-24 23:36:52 +00:00
|
|
|
# Support for DRBD, the Distributed Replicated Block Device.
|
|
|
|
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let cfg = config.services.drbd; in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.drbd.enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to enable support for DRBD, the Distributed Replicated
|
|
|
|
Block Device.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
services.drbd.config = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Contents of the {file}`drbd.conf` configuration file.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.drbd ];
|
|
|
|
|
|
|
|
services.udev.packages = [ pkgs.drbd ];
|
|
|
|
|
|
|
|
boot.kernelModules = [ "drbd" ];
|
|
|
|
|
|
|
|
boot.extraModprobeConfig =
|
|
|
|
''
|
|
|
|
options drbd usermode_helper=/run/current-system/sw/bin/drbdadm
|
|
|
|
'';
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
environment.etc."drbd.conf" =
|
2020-04-24 23:36:52 +00:00
|
|
|
{ source = pkgs.writeText "drbd.conf" cfg.config; };
|
|
|
|
|
|
|
|
systemd.services.drbd = {
|
|
|
|
after = [ "systemd-udev.settle.service" "network.target" ];
|
|
|
|
wants = [ "systemd-udev.settle.service" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2021-12-06 16:07:01 +00:00
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.drbd}/sbin/drbdadm up all";
|
|
|
|
ExecStop = "${pkgs.drbd}/sbin/drbdadm down all";
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|