2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-05-31 09:44:17 +02:00
|
|
|
let
|
|
|
|
cfg = config.services.virtuoso;
|
|
|
|
virtuosoUser = "virtuoso";
|
|
|
|
stateDir = "/var/lib/virtuoso";
|
|
|
|
in
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2011-05-31 09:44:17 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2011-05-31 09:44:17 +02:00
|
|
|
services.virtuoso = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2020-04-20 20:05:26 +02:00
|
|
|
enable = mkEnableOption "Virtuoso Opensource database server";
|
2011-05-31 09:44:17 +02:00
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
default = "";
|
2011-05-31 16:56:56 +02:00
|
|
|
description = "Extra options to put into Virtuoso configuration file.";
|
2011-05-31 09:44:17 +02:00
|
|
|
};
|
|
|
|
|
2011-06-04 12:53:07 +02:00
|
|
|
parameters = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = "Extra options to put into [Parameters] section of Virtuoso configuration file.";
|
|
|
|
};
|
|
|
|
|
2011-05-31 09:44:17 +02:00
|
|
|
listenAddress = mkOption {
|
2016-01-06 07:50:18 +01:00
|
|
|
default = "1111";
|
|
|
|
example = "myserver:1323";
|
2011-05-31 09:44:17 +02:00
|
|
|
description = "ip:port or port to listen on.";
|
|
|
|
};
|
|
|
|
|
|
|
|
httpListenAddress = mkOption {
|
2016-01-06 07:50:18 +01:00
|
|
|
default = null;
|
|
|
|
example = "myserver:8080";
|
2011-05-31 16:56:56 +02:00
|
|
|
description = "ip:port or port for Virtuoso HTTP server to listen on.";
|
2011-05-31 09:44:17 +02:00
|
|
|
};
|
|
|
|
|
2011-05-31 16:56:56 +02:00
|
|
|
dirsAllowed = mkOption {
|
2016-01-06 07:50:18 +01:00
|
|
|
default = null;
|
|
|
|
example = "/www, /home/";
|
2011-05-31 16:56:56 +02:00
|
|
|
description = "A list of directories Virtuoso is allowed to access";
|
|
|
|
};
|
2011-05-31 09:44:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2019-09-14 19:51:29 +02:00
|
|
|
users.users.${virtuosoUser} =
|
|
|
|
{ uid = config.ids.uids.virtuoso;
|
2011-05-31 09:44:17 +02:00
|
|
|
description = "virtuoso user";
|
|
|
|
home = stateDir;
|
|
|
|
};
|
|
|
|
|
2016-01-06 07:50:18 +01:00
|
|
|
systemd.services.virtuoso = {
|
2016-09-10 18:03:59 +02:00
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2011-05-31 09:44:17 +02:00
|
|
|
|
|
|
|
preStart = ''
|
2016-01-06 07:50:18 +01:00
|
|
|
mkdir -p ${stateDir}
|
|
|
|
chown ${virtuosoUser} ${stateDir}
|
2011-05-31 09:44:17 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
script = ''
|
2016-01-06 07:50:18 +01:00
|
|
|
cd ${stateDir}
|
|
|
|
${pkgs.virtuoso}/bin/virtuoso-t +foreground +configfile ${pkgs.writeText "virtuoso.ini" cfg.config}
|
2011-05-31 09:44:17 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
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}
|
2011-05-31 11:56:55 +02:00
|
|
|
RunAs=${virtuosoUser}
|
2011-05-31 16:56:56 +02:00
|
|
|
${optionalString (cfg.dirsAllowed != null) "DirsAllowed=${cfg.dirsAllowed}"}
|
2011-06-04 12:53:07 +02:00
|
|
|
${cfg.parameters}
|
2011-05-31 09:44:17 +02:00
|
|
|
|
|
|
|
[HTTPServer]
|
|
|
|
${optionalString (cfg.httpListenAddress != null) "ServerPort=${cfg.httpListenAddress}"}
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2011-05-31 09:44:17 +02:00
|
|
|
}
|