1 { config, lib, pkgs, ... }:
6 cfg = config.services.monetdb;
9 meta.maintainers = with maintainers; [ StillerHarpo ];
15 enable = mkEnableOption "the MonetDB database server";
17 package = mkPackageOption pkgs "monetdb" { };
22 description = "User account under which MonetDB runs.";
28 description = "Group under which MonetDB runs.";
33 default = "/var/lib/monetdb";
34 description = "Data directory for the dbfarm.";
38 type = types.ints.u16;
40 description = "Port to listen on.";
43 listenAddress = mkOption {
45 default = "127.0.0.1";
47 description = "Address to listen on.";
53 config = mkIf cfg.enable {
55 users.users.monetdb = mkIf (cfg.user == "monetdb") {
56 uid = config.ids.uids.monetdb;
58 description = "MonetDB user";
63 users.groups.monetdb = mkIf (cfg.group == "monetdb") {
64 gid = config.ids.gids.monetdb;
65 members = [ cfg.user ];
68 environment.systemPackages = [ cfg.package ];
70 systemd.services.monetdb = {
71 description = "MonetDB database server";
72 wantedBy = [ "multi-user.target" ];
73 after = [ "network.target" ];
74 path = [ cfg.package ];
75 unitConfig.RequiresMountsFor = "${cfg.dataDir}";
79 ExecStart = "${cfg.package}/bin/monetdbd start -n ${cfg.dataDir}";
80 ExecStop = "${cfg.package}/bin/monetdbd stop ${cfg.dataDir}";
83 if [ ! -e ${cfg.dataDir}/.merovingian_properties ]; then
84 # Create the dbfarm (as cfg.user)
85 ${cfg.package}/bin/monetdbd create ${cfg.dataDir}
88 # Update the properties
89 ${cfg.package}/bin/monetdbd set port=${toString cfg.port} ${cfg.dataDir}
90 ${cfg.package}/bin/monetdbd set listenaddr=${cfg.listenAddress} ${cfg.dataDir}