Skip to content

Commit

Permalink
Merge pull request #796 from stephank/fix/couchdb
Browse files Browse the repository at this point in the history
CouchDB service fixes
  • Loading branch information
domenkozar authored Aug 22, 2023
2 parents d78e4fe + 100f639 commit c357695
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions src/modules/services/couchdb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ let
baseDir = config.env.DEVENV_STATE + "/couchdb";
startScript = pkgs.writeShellScriptBin "start-couchdb" ''
set -euo pipefail
if [[ ! -d "${baseDir}" ]]; then
mkdir -p "${baseDir}"
touch ${baseDir}/couchdb.uri
fi
mkdir -p '${baseDir}'
touch '${baseDir}/couchdb.uri'
touch '${baseDir}/couchdb.ini'
if ! test -e ${baseDir}/.erlang.cookie; then
touch ${baseDir}/.erlang.cookie
chmod 600 ${baseDir}/.erlang.cookie
dd if=/dev/random bs=16 count=1 | base64 > ${baseDir}/.erlang.cookie
if [[ ! -e '${baseDir}/.erlang.cookie' ]]; then
touch '${baseDir}/.erlang.cookie'
chmod 600 '${baseDir}/.erlang.cookie'
dd if=/dev/random bs=16 count=1 status=none | base64 > ${baseDir}/.erlang.cookie
fi
exec ${cfg.package}/bin/couchdb
Expand Down Expand Up @@ -58,7 +57,7 @@ in
CouchDB installation.
'';
};
options.couchdb.viewIndexDir = lib.mkOption {
options.couchdb.view_index_dir = lib.mkOption {
type = lib.types.path;
default = baseDir;
description = ''
Expand All @@ -67,7 +66,7 @@ in
(couchdb by default).
'';
};
options.couchdb.uriFile = lib.mkOption {
options.couchdb.uri_file = lib.mkOption {
type = lib.types.path;
default = "${baseDir}/couchdb.uri";
description = ''
Expand All @@ -79,7 +78,7 @@ in
'';
};

options.chttpd.bindAddress = lib.mkOption {
options.chttpd.bind_address = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = lib.mdDoc ''
Expand All @@ -94,14 +93,6 @@ in
Defined the port number to listen.
'';
};

options.chttpd.logFile = lib.mkOption {
type = lib.types.path;
default = "${baseDir}/couchdb.log";
description = lib.mdDoc ''
Specifies the location of file for logging output.
'';
};
};
description = ''
CouchDB configuration.
Expand All @@ -116,16 +107,15 @@ in
couchdb = {
database_dir = baseDir;
single_node = true;
viewIndexDir = baseDir;
uriFile = "${baseDir}/couchdb.uri";
view_index_dir = baseDir;
uri_file = "${baseDir}/couchdb.uri";
};
admins = {
"admin_username" = "pass";
};
chttpd = {
bindAddress = "127.0.0.1";
bind_address = "127.0.0.1";
port = 5984;
logFile = "${baseDir}/couchdb.log";
};
}
'';
Expand All @@ -138,19 +128,18 @@ in
couchdb = {
database_dir = baseDir;
single_node = true;
viewIndexDir = baseDir;
uriFile = "${baseDir}/couchdb.uri";
view_index_dir = baseDir;
uri_file = "${baseDir}/couchdb.uri";
};
admins = {
admin = "admin";
};
chttpd = {
bindAddress = "127.0.0.1";
bind_address = "127.0.0.1";
port = 5984;
logFile = "${baseDir}/couchdb.log";
};
};
env.ERL_FLAGS = "-couch_ini ${configFile}";
env.ERL_FLAGS = "-couch_ini ${cfg.package}/etc/default.ini ${configFile} '${baseDir}/couchdb.ini'";
processes.couchdb.exec = "${startScript}/bin/start-couchdb";
};
}

0 comments on commit c357695

Please sign in to comment.