Author: egorochkin
Date: Fri Apr 15 16:10:13 2011
New Revision: 26852
URL: https://svn.nixos.org/websvn/nix/?rev=26852&sc=1
Log:
4store database service: packaged
Added:
nixos/trunk/modules/services/databases/4store.nix
Modified:
nixos/trunk/modules/misc/ids.nix
nixos/trunk/modules/module-list.nix
Modified: nixos/trunk/modules/misc/ids.nix
==============================================================================
--- nixos/trunk/modules/misc/ids.nix Fri Apr 15 13:39:44 2011 (r26851)
+++ nixos/trunk/modules/misc/ids.nix Fri Apr 15 16:10:13 2011 (r26852)
@@ -60,6 +60,7 @@
kdm = 39;
ghostOne = 40;
git = 41;
+ fourStore = 42;
# When adding a uid, make sure it doesn't match an existing gid.
nixbld = 30000; # start of range of uids
@@ -102,6 +103,7 @@
osgi = 34;
ghostOne = 40;
git = 41;
+ fourStore = 42;
# When adding a gid, make sure it doesn't match an existing uid.
users = 100;
Modified: nixos/trunk/modules/module-list.nix
==============================================================================
--- nixos/trunk/modules/module-list.nix Fri Apr 15 13:39:44 2011 (r26851)
+++ nixos/trunk/modules/module-list.nix Fri Apr 15 16:10:13 2011 (r26852)
@@ -51,6 +51,7 @@
./services/backup/mysql-backup.nix
./services/backup/postgresql-backup.nix
./services/backup/sitecopy-backup.nix
+ ./services/databases/4store.nix
./services/databases/mysql.nix
./services/databases/postgresql.nix
./services/databases/openldap.nix
Added: nixos/trunk/modules/services/databases/4store.nix
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ nixos/trunk/modules/services/databases/4store.nix Fri Apr 15 16:10:13
2011 (r26852)
@@ -0,0 +1,71 @@
+{ config, pkgs, ... }:
+let
+ cfg = config.services.fourStore;
+ stateDir = "/var/lib/4store";
+ fourStoreUser = "fourstore";
+ run = "${pkgs.su}/bin/su -s ${pkgs.stdenv.shell} ${fourStoreUser}";
+in
+with pkgs.lib;
+{
+
+ ###### interface
+
+ options = {
+
+ services.fourStore = {
+
+ enable = mkOption {
+ default = false;
+ description = "Whether to enable 4Store RDF database server.";
+ };
+
+ database = mkOption {
+ default = "";
+ description = "RDF database name. If it doesn't exist, it will be
created. Databases are stored in ${stateDir}.";
+ };
+
+ options = mkOption {
+ default = "";
+ description = "Extra CLI options to pass to 4Store.";
+ };
+
+ };
+
+ };
+
+
+ ###### implementation
+
+ config = mkIf cfg.enable (
+ mkAssert (cfg.enable -> cfg.database != "")
+ "Must specify database name" {
+
+ users.extraUsers = singleton
+ { name = fourStoreUser;
+ uid = config.ids.uids.fourStore;
+ description = "4Store database user";
+ home = stateDir;
+ };
+
+ services.avahi.enable = true;
+
+ jobs.fourStore = {
+ name = "4store";
+ startOn = "filesystem";
+
+ preStart = ''
+ mkdir -p ${stateDir}/
+ chown ${fourStoreUser} ${stateDir}
+ if ! test -e "${stateDir}/${cfg.database}"; then
+ ${run} -c '${pkgs.rdf4store}/bin/4s-backend-setup ${cfg.database}'
+ fi
+ '';
+
+ exec = ''
+ ${run} -c '${pkgs.rdf4store}/bin/4s-backend -D ${cfg.options}
${cfg.database}'
+ '';
+ };
+
+ });
+
+}
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits