2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.monetdb;
|
|
|
|
|
|
|
|
in {
|
|
|
|
meta.maintainers = with maintainers; [ StillerHarpo primeos ];
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.monetdb = {
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption "the MonetDB database server";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "monetdb" { };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "monetdb";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "User account under which MonetDB runs.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "monetdb";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Group under which MonetDB runs.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/monetdb";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Data directory for the dbfarm.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.ints.u16;
|
|
|
|
default = 50000;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Port to listen on.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
listenAddress = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "127.0.0.1";
|
|
|
|
example = "0.0.0.0";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Address to listen on.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
users.users.monetdb = mkIf (cfg.user == "monetdb") {
|
|
|
|
uid = config.ids.uids.monetdb;
|
|
|
|
group = cfg.group;
|
|
|
|
description = "MonetDB user";
|
|
|
|
home = cfg.dataDir;
|
|
|
|
createHome = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.monetdb = mkIf (cfg.group == "monetdb") {
|
|
|
|
gid = config.ids.gids.monetdb;
|
|
|
|
members = [ cfg.user ];
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
|
|
|
|
systemd.services.monetdb = {
|
|
|
|
description = "MonetDB database server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
path = [ cfg.package ];
|
|
|
|
unitConfig.RequiresMountsFor = "${cfg.dataDir}";
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
ExecStart = "${cfg.package}/bin/monetdbd start -n ${cfg.dataDir}";
|
|
|
|
ExecStop = "${cfg.package}/bin/monetdbd stop ${cfg.dataDir}";
|
|
|
|
};
|
|
|
|
preStart = ''
|
|
|
|
if [ ! -e ${cfg.dataDir}/.merovingian_properties ]; then
|
|
|
|
# Create the dbfarm (as cfg.user)
|
|
|
|
${cfg.package}/bin/monetdbd create ${cfg.dataDir}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Update the properties
|
|
|
|
${cfg.package}/bin/monetdbd set port=${toString cfg.port} ${cfg.dataDir}
|
|
|
|
${cfg.package}/bin/monetdbd set listenaddr=${cfg.listenAddress} ${cfg.dataDir}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|