@@ -0,0 +1,84 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ inherit (pkgs) glusterfs;
7+
8+ cfg = config.services.glusterfs;
9+
10+in
11+
12+{
13+
14+ ###### interface
15+
16+ options = {
17+
18+ services.glusterfs = {
19+
20+ enable = mkEnableOption "GlusterFS Daemon";
21+
22+ logLevel = mkOption {
23+ type = types.enum ["DEBUG" "INFO" "WARNING" "ERROR" "CRITICAL" "TRACE" "NONE"];
24+ description = "Log level used by the GlusterFS daemon";
25+ default = "INFO";
26+ };
27+
28+ extraFlags = mkOption {
29+ type = types.listOf types.str;
30+ description = "Extra flags passed to the GlusterFS daemon";
31+ default = [];
32+ };
33+ };
34+ };
35+
36+ ###### implementation
37+
38+ config = mkIf cfg.enable {
39+ environment.systemPackages = [ pkgs.glusterfs ];
40+
41+ services.rpcbind.enable = true;
42+
43+ systemd.services.glusterd = {
44+
45+ description = "GlusterFS, a clustered file-system server";
46+
47+ wantedBy = [ "multi-user.target" ];
48+
49+ requires = [ "rpcbind.service" ];
50+ after = [ "rpcbind.service" "network.target" "local-fs.target" ];
51+ before = [ "network-online.target" ];
52+
53+ preStart = ''
54+ install -m 0755 -d /var/log/glusterfs
55+ '';
56+
57+ serviceConfig = {
58+ Type="forking";
59+ PIDFile="/run/glusterd.pid";
60+ LimitNOFILE=65536;
61+ ExecStart="${glusterfs}/sbin/glusterd -p /run/glusterd.pid --log-level=${cfg.logLevel} ${toString cfg.extraFlags}";
62+ KillMode="process";
63+ };
64+ };
65+
66+ systemd.services.glustereventsd = {
67+
68+ description = "Gluster Events Notifier";
69+
70+ wantedBy = [ "multi-user.target" ];
71+
72+ after = [ "syslog.target" "network.target" ];
73+
74+ serviceConfig = {
75+ Type="simple";
76+ Environment="PYTHONPATH=${glusterfs}/usr/lib/python2.7/site-packages";
77+ PIDFile="/run/glustereventsd.pid";
78+ ExecStart="${glusterfs}/sbin/glustereventsd --pid-file /run/glustereventsd.pid";
79+ ExecReload="/bin/kill -SIGUSR2 $MAINPID";
80+ KillMode="control-group";
81+ };
82+ };
83+ };
84+}