summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorGeorge Kollias <georgioskollias@gmail.com>2014-04-01 20:20:33 +0300
committerGeorge Kollias <georgioskollias@gmail.com>2014-04-01 20:20:33 +0300
commit0ded8e6de3da16e9c84ec7f4e5c382565585e04b (patch)
tree66ce646a9df95b4402db93f32706bf1196a079e7 /nixos
parent75fb34eb6d5355a156f60ccfb07712c2fa922294 (diff)
downloadnixpkgs-0ded8e6de3da16e9c84ec7f4e5c382565585e04b.tar
nixpkgs-0ded8e6de3da16e9c84ec7f4e5c382565585e04b.tar.gz
nixpkgs-0ded8e6de3da16e9c84ec7f4e5c382565585e04b.tar.bz2
nixpkgs-0ded8e6de3da16e9c84ec7f4e5c382565585e04b.tar.lz
nixpkgs-0ded8e6de3da16e9c84ec7f4e5c382565585e04b.tar.xz
nixpkgs-0ded8e6de3da16e9c84ec7f4e5c382565585e04b.tar.zst
nixpkgs-0ded8e6de3da16e9c84ec7f4e5c382565585e04b.zip
Added MonetDB NixOS module.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/misc/ids.nix2
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/databases/monetdb.nix88
3 files changed, 91 insertions, 0 deletions
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index 9c413e36d56..ddf3b6bc509 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -123,6 +123,7 @@
       ngircd = 112;
       btsync = 113;
       minecraft = 114;
+      monetdb = 115;
 
       # When adding a uid, make sure it doesn't match an existing gid.
 
@@ -221,6 +222,7 @@
       jenkins = 109;
       systemd-journal-gateway = 110;
       notbit = 111;
+      monetdb = 112;
 
       # When adding a gid, make sure it doesn't match an existing uid.
 
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 652a99e7c5a..1b5ffd9740d 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -95,6 +95,7 @@
   ./services/databases/openldap.nix
   ./services/databases/postgresql.nix
   ./services/databases/virtuoso.nix
+  ./services/databases/monetdb.nix
   ./services/games/ghost-one.nix
   ./services/games/minecraft-server.nix
   ./services/hardware/acpid.nix
diff --git a/nixos/modules/services/databases/monetdb.nix b/nixos/modules/services/databases/monetdb.nix
new file mode 100644
index 00000000000..9d3059c7f45
--- /dev/null
+++ b/nixos/modules/services/databases/monetdb.nix
@@ -0,0 +1,88 @@
+{ config, pkgs, ... }:
+let
+  cfg = config.services.monetdb;
+  monetdbUser = "monetdb";
+in
+with pkgs.lib;
+{
+
+  ###### interface
+
+  options = {
+
+    services.monetdb = {
+
+      enable = mkOption {
+        type = types.bool;
+        default = false;
+        description = "Whether to enable MonetDB database server.";
+      };
+
+      package = mkOption {
+        type = types.path;
+        description = "MonetDB package to use.";
+      };
+
+      dbfarmDir = mkOption {
+        type = types.path;
+        default = "/var/lib/monetdb";
+        description = ''
+          Specifies location of Monetdb dbfarm (keeps database and auxiliary files).
+        '';
+      };
+
+      port = mkOption {
+        default = "50000";
+        example = "50000";
+        description = "Port to listen on.";
+      };
+    };
+
+  };
+
+
+  ###### implementation
+
+  config = mkIf cfg.enable {
+
+    users.extraUsers.monetdb = 
+      { name = monetdbUser;
+        uid = config.ids.uids.monetdb;
+        description = "monetdb user";
+        home = cfg.dbfarmDir;
+      };
+
+    users.extraGroups.monetdb.gid = config.ids.gids.monetdb;
+
+    environment.systemPackages = [ cfg.package ];
+
+    systemd.services.monetdb =
+      { description = "MonetDB Server";
+
+        wantedBy = [ "multi-user.target" ];
+
+        after = [ "network.target" ];
+
+        path = [ cfg.package ];
+
+        preStart =
+          ''
+            # Initialise the database.
+            if ! test -e ${cfg.dbfarmDir}/.merovingian_properties; then
+                mkdir -m 0700 -p ${cfg.dbfarmDir}
+                chown -R ${monetdbUser} ${cfg.dbfarmDir}
+                ${cfg.package}/bin/monetdbd create ${cfg.dbfarmDir}
+                ${cfg.package}/bin/monetdbd set port=${cfg.port} ${cfg.dbfarmDir}
+            fi
+          '';
+
+        serviceConfig.ExecStart = "${cfg.package}/bin/monetdbd start -n ${cfg.dbfarmDir}";
+
+        serviceConfig.ExecStop = "${cfg.package}/bin/monetdbd stop ${cfg.dbfarmDir}";
+
+        unitConfig.RequiresMountsFor = "${cfg.dbfarmDir}";
+      };
+
+  };
+
+}