1 # Support for DRBD, the Distributed Replicated Block Device.
3 { config, lib, pkgs, ... }:
7 let cfg = config.services.drbd; in
15 services.drbd.enable = mkOption {
18 description = lib.mdDoc ''
19 Whether to enable support for DRBD, the Distributed Replicated
24 services.drbd.config = mkOption {
27 description = lib.mdDoc ''
28 Contents of the {file}`drbd.conf` configuration file.
37 config = mkIf cfg.enable {
39 environment.systemPackages = [ pkgs.drbd ];
41 services.udev.packages = [ pkgs.drbd ];
43 boot.kernelModules = [ "drbd" ];
45 boot.extraModprobeConfig =
47 options drbd usermode_helper=/run/current-system/sw/bin/drbdadm
50 environment.etc."drbd.conf" =
51 { source = pkgs.writeText "drbd.conf" cfg.config; };
53 systemd.services.drbd = {
54 after = [ "systemd-udev.settle.service" "network.target" ];
55 wants = [ "systemd-udev.settle.service" ];
56 wantedBy = [ "multi-user.target" ];
58 ExecStart = "${pkgs.drbd}/sbin/drbdadm up all";
59 ExecStop = "${pkgs.drbd}/sbin/drbdadm down all";