mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-03 14:22:35 +03:00
* Add a module for DRBD.
svn path=/nixos/trunk/; revision=30202
This commit is contained in:
parent
0309f02fc5
commit
aac71e8f95
3 changed files with 79 additions and 1 deletions
77
modules/services/network-filesystems/drbd.nix
Normal file
77
modules/services/network-filesystems/drbd.nix
Normal file
|
@ -0,0 +1,77 @@
|
|||
# Support for DRBD, the Distributed Replicated Block Device.
|
||||
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
with pkgs.lib;
|
||||
|
||||
let cfg = config.services.drbd; in
|
||||
|
||||
{
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
services.drbd.enable = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Whether to enable support for DRBD, the Distributed Replicated
|
||||
Block Device.
|
||||
'';
|
||||
};
|
||||
|
||||
services.drbd.config = mkOption {
|
||||
default = "";
|
||||
type = types.string;
|
||||
description = ''
|
||||
Contents of the <filename>drbd.conf</filename> configuration file.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = [ pkgs.drbd ];
|
||||
|
||||
services.udev.packages = [ pkgs.drbd ];
|
||||
|
||||
boot.kernelModules = [ "drbd" ];
|
||||
|
||||
boot.extraModprobeConfig =
|
||||
''
|
||||
options drbd usermode_helper=/var/run/current-system/sw/sbin/drbdadm
|
||||
'';
|
||||
|
||||
environment.etc = singleton
|
||||
{ source = pkgs.writeText "drbd.conf" cfg.config;
|
||||
target = "drbd.conf";
|
||||
};
|
||||
|
||||
jobs.drbd_up =
|
||||
{ name = "drbd-up";
|
||||
startOn = "stopped udevtrigger or ip-up";
|
||||
task = true;
|
||||
script =
|
||||
''
|
||||
${pkgs.drbd}/sbin/drbdadm up all
|
||||
'';
|
||||
};
|
||||
|
||||
jobs.drbd_down =
|
||||
{ name = "drbd-down";
|
||||
startOn = "starting shutdown";
|
||||
task = true;
|
||||
script =
|
||||
''
|
||||
${pkgs.drbd}/sbin/drbdadm down all
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue