From 14859264a9aa21630e53fec0db2c40251c57b352 Mon Sep 17 00:00:00 2001 From: Evgeny Egorochkin Date: Tue, 31 May 2011 07:44:17 +0000 Subject: [PATCH] Virtuoso database service: packaged svn path=/nixos/trunk/; revision=27332 --- modules/misc/ids.nix | 2 + modules/module-list.nix | 1 + modules/services/databases/virtuoso.nix | 85 +++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 modules/services/databases/virtuoso.nix diff --git a/modules/misc/ids.nix b/modules/misc/ids.nix index ccfba68c4d72..02c9cefc3152 100644 --- a/modules/misc/ids.nix +++ b/modules/misc/ids.nix @@ -62,6 +62,7 @@ in git = 41; fourStore = 42; fourStoreEndpoint = 43; + virtuoso = 44; # When adding a uid, make sure it doesn't match an existing gid. @@ -107,6 +108,7 @@ in git = 41; fourStore = 42; fourStoreEndpoint = 43; + virtuoso = 44; # When adding a gid, make sure it doesn't match an existing uid. diff --git a/modules/module-list.nix b/modules/module-list.nix index f14a3ed09396..ffc42eb02782 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -56,6 +56,7 @@ ./services/databases/mysql.nix ./services/databases/openldap.nix ./services/databases/postgresql.nix + ./services/databases/virtuoso.nix ./services/games/ghost-one.nix ./services/hardware/acpid.nix ./services/hardware/bluetooth.nix diff --git a/modules/services/databases/virtuoso.nix b/modules/services/databases/virtuoso.nix new file mode 100644 index 000000000000..1bf6a1caf552 --- /dev/null +++ b/modules/services/databases/virtuoso.nix @@ -0,0 +1,85 @@ +{ config, pkgs, ... }: +let + cfg = config.services.virtuoso; + virtuosoUser = "virtuoso"; + stateDir = "/var/lib/virtuoso"; +in +with pkgs.lib; +{ + + ###### interface + + options = { + + services.virtuoso = { + + enable = mkOption { + default = false; + description = "Whether to enable Virtuoso Opensource database server."; + }; + + config = mkOption { + default = ""; + description = "Extra options to put into virtuoso configuration file."; + }; + + listenAddress = mkOption { + default = "1111"; + example = "myserver:1323"; + description = "ip:port or port to listen on."; + }; + + httpListenAddress = mkOption { + default = null; + example = "myserver:8080"; + description = "ip:port or port for virtuoso HTTP server to listen on."; + }; + + }; + + }; + + + ###### implementation + + config = mkIf cfg.enable { + + users.extraUsers = singleton + { name = virtuosoUser; + uid = config.ids.uids.virtuoso; + description = "virtuoso user"; + home = stateDir; + }; + + jobs.virtuoso = { + name = "virtuoso"; + startOn = "filesystem"; + + preStart = '' + mkdir -p ${stateDir} + chown ${virtuosoUser} ${stateDir} + ''; + + script = '' + cd ${stateDir} + ${pkgs.virtuoso}/bin/virtuoso-t +foreground +configfile ${pkgs.writeText "virtuoso.ini" cfg.config} + ''; + }; + + services.virtuoso.config = '' + [Database] + DatabaseFile=${stateDir}/x-virtuoso.db + TransactionFile=${stateDir}/x-virtuoso.trx + ErrorLogFile=${stateDir}/x-virtuoso.log + xa_persistent_file=${stateDir}/x-virtuoso.pxa + + [Parameters] + ServerPort=${cfg.listenAddress} + + [HTTPServer] + ${optionalString (cfg.httpListenAddress != null) "ServerPort=${cfg.httpListenAddress}"} + ''; + + }; + +}