···
1
+
{ config, lib, pkgs, ... }:
7
+
cfg = config.services.riak-cs;
17
+
services.riak-cs = {
19
+
enable = mkEnableOption "riak-cs";
21
+
package = mkOption {
22
+
type = types.package;
23
+
default = pkgs.riak-cs;
24
+
defaultText = "pkgs.riak-cs";
25
+
example = literalExample "pkgs.riak-cs";
27
+
Riak package to use.
31
+
nodeName = mkOption {
33
+
default = "riak-cs@127.0.0.1";
35
+
Name of the Erlang node.
39
+
anonymousUserCreation = mkOption {
43
+
Anonymous user creation.
47
+
riakHost = mkOption {
49
+
default = "127.0.0.1:8087";
51
+
Name of riak hosting service.
55
+
listener = mkOption {
57
+
default = "127.0.0.1:8080";
59
+
Name of Riak CS listening service.
63
+
stanchionHost = mkOption {
65
+
default = "127.0.0.1:8085";
67
+
Name of stanchion hosting service.
71
+
stanchionSsl = mkOption {
75
+
Tell stanchion to use SSL.
79
+
distributedCookie = mkOption {
83
+
Cookie for distributed node communication. All nodes in the
84
+
same cluster should use the same cookie or they will not be able to
89
+
dataDir = mkOption {
91
+
default = "/var/db/riak-cs";
93
+
Data directory for Riak CS.
99
+
default = "/var/log/riak-cs";
101
+
Log directory for Riak CS.
105
+
extraConfig = mkOption {
106
+
type = types.lines;
109
+
Additional text to be appended to <filename>riak-cs.conf</filename>.
113
+
extraAdvancedConfig = mkOption {
114
+
type = types.lines;
117
+
Additional text to be appended to <filename>advanced.config</filename>.
124
+
###### implementation
126
+
config = mkIf cfg.enable {
128
+
environment.systemPackages = [ cfg.package ];
129
+
environment.etc."riak-cs/riak-cs.conf".text = ''
130
+
nodename = ${cfg.nodeName}
131
+
distributed_cookie = ${cfg.distributedCookie}
133
+
platform_log_dir = ${cfg.logDir}
135
+
riak_host = ${cfg.riakHost}
136
+
listener = ${cfg.listener}
137
+
stanchion_host = ${cfg.stanchionHost}
139
+
anonymous_user_creation = ${if cfg.anonymousUserCreation then "on" else "off"}
144
+
environment.etc."riak-cs/advanced.config".text = ''
145
+
${cfg.extraAdvancedConfig}
148
+
users.extraUsers.riak-cs = {
150
+
uid = config.ids.uids.riak-cs;
152
+
description = "Riak CS server user";
155
+
systemd.services.riak-cs = {
156
+
description = "Riak CS Server";
158
+
wantedBy = [ "multi-user.target" ];
159
+
after = [ "network.target" ];
162
+
pkgs.utillinux # for `logger`
166
+
environment.HOME = "${cfg.dataDir}";
167
+
environment.RIAK_CS_DATA_DIR = "${cfg.dataDir}";
168
+
environment.RIAK_CS_LOG_DIR = "${cfg.logDir}";
169
+
environment.RIAK_CS_ETC_DIR = "/etc/riak";
172
+
if ! test -e ${cfg.logDir}; then
173
+
mkdir -m 0755 -p ${cfg.logDir}
174
+
chown -R riak-cs ${cfg.logDir}
177
+
if ! test -e ${cfg.dataDir}; then
178
+
mkdir -m 0700 -p ${cfg.dataDir}
179
+
chown -R riak-cs ${cfg.dataDir}
184
+
ExecStart = "${cfg.package}/bin/riak-cs console";
185
+
ExecStop = "${cfg.package}/bin/riak-cs stop";
186
+
StandardInput = "tty";
189
+
PermissionsStartOnly = true;
190
+
# Give Riak a decent amount of time to clean up.
191
+
TimeoutStopSec = 120;
192
+
LimitNOFILE = 65536;
195
+
unitConfig.RequiresMountsFor = [