···
+
{ config, lib, pkgs, ... }:
+
cfg = config.services.riak-cs;
+
enable = mkEnableOption "riak-cs";
+
default = pkgs.riak-cs;
+
defaultText = "pkgs.riak-cs";
+
example = literalExample "pkgs.riak-cs";
+
default = "riak-cs@127.0.0.1";
+
Name of the Erlang node.
+
anonymousUserCreation = mkOption {
+
Anonymous user creation.
+
default = "127.0.0.1:8087";
+
Name of riak hosting service.
+
default = "127.0.0.1:8080";
+
Name of Riak CS listening service.
+
stanchionHost = mkOption {
+
default = "127.0.0.1:8085";
+
Name of stanchion hosting service.
+
stanchionSsl = mkOption {
+
Tell stanchion to use SSL.
+
distributedCookie = mkOption {
+
Cookie for distributed node communication. All nodes in the
+
same cluster should use the same cookie or they will not be able to
+
default = "/var/db/riak-cs";
+
Data directory for Riak CS.
+
default = "/var/log/riak-cs";
+
Log directory for Riak CS.
+
extraConfig = mkOption {
+
Additional text to be appended to <filename>riak-cs.conf</filename>.
+
extraAdvancedConfig = mkOption {
+
Additional text to be appended to <filename>advanced.config</filename>.
+
config = mkIf cfg.enable {
+
environment.systemPackages = [ cfg.package ];
+
environment.etc."riak-cs/riak-cs.conf".text = ''
+
nodename = ${cfg.nodeName}
+
distributed_cookie = ${cfg.distributedCookie}
+
platform_log_dir = ${cfg.logDir}
+
riak_host = ${cfg.riakHost}
+
listener = ${cfg.listener}
+
stanchion_host = ${cfg.stanchionHost}
+
anonymous_user_creation = ${if cfg.anonymousUserCreation then "on" else "off"}
+
environment.etc."riak-cs/advanced.config".text = ''
+
${cfg.extraAdvancedConfig}
+
users.extraUsers.riak-cs = {
+
uid = config.ids.uids.riak-cs;
+
description = "Riak CS server user";
+
systemd.services.riak-cs = {
+
description = "Riak CS Server";
+
wantedBy = [ "multi-user.target" ];
+
after = [ "network.target" ];
+
pkgs.utillinux # for `logger`
+
environment.HOME = "${cfg.dataDir}";
+
environment.RIAK_CS_DATA_DIR = "${cfg.dataDir}";
+
environment.RIAK_CS_LOG_DIR = "${cfg.logDir}";
+
environment.RIAK_CS_ETC_DIR = "/etc/riak";
+
if ! test -e ${cfg.logDir}; then
+
mkdir -m 0755 -p ${cfg.logDir}
+
chown -R riak-cs ${cfg.logDir}
+
if ! test -e ${cfg.dataDir}; then
+
mkdir -m 0700 -p ${cfg.dataDir}
+
chown -R riak-cs ${cfg.dataDir}
+
ExecStart = "${cfg.package}/bin/riak-cs console";
+
ExecStop = "${cfg.package}/bin/riak-cs stop";
+
PermissionsStartOnly = true;
+
# Give Riak a decent amount of time to clean up.
+
unitConfig.RequiresMountsFor = [