2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-04-15 18:10:17 +02:00
|
|
|
let
|
|
|
|
cfg = config.services.fourStoreEndpoint;
|
|
|
|
endpointUser = "fourstorehttp";
|
|
|
|
run = "${pkgs.su}/bin/su -s ${pkgs.stdenv.shell} ${endpointUser} -c";
|
|
|
|
in
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2011-04-15 18:10:17 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2011-04-15 18:10:17 +02:00
|
|
|
services.fourStoreEndpoint = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2011-04-15 18:10:17 +02:00
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable 4Store SPARQL endpoint.";
|
|
|
|
};
|
|
|
|
|
|
|
|
database = mkOption {
|
|
|
|
default = config.services.fourStore.database;
|
|
|
|
description = "RDF database name to expose via the endpoint. Defaults to local 4Store database name.";
|
|
|
|
};
|
|
|
|
|
|
|
|
listenAddress = mkOption {
|
2013-10-30 18:30:23 +01:00
|
|
|
default = null;
|
2011-04-15 18:10:17 +02:00
|
|
|
description = "IP address to listen on.";
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
2013-10-30 18:30:23 +01:00
|
|
|
default = 8080;
|
2011-04-15 18:10:17 +02:00
|
|
|
description = "port to listen on.";
|
|
|
|
};
|
|
|
|
|
|
|
|
options = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = "Extra CLI options to pass to 4Store's 4s-httpd process.";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2013-10-30 18:30:23 +01:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
assertions = singleton
|
|
|
|
{ assertion = cfg.enable -> cfg.database != "";
|
|
|
|
message = "Must specify 4Store database name";
|
|
|
|
};
|
2011-04-15 18:10:17 +02:00
|
|
|
|
|
|
|
users.extraUsers = singleton
|
|
|
|
{ name = endpointUser;
|
2014-04-29 10:51:42 +02:00
|
|
|
uid = config.ids.uids.fourstorehttp;
|
2011-04-15 18:10:17 +02:00
|
|
|
description = "4Store SPARQL endpoint user";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.avahi.enable = true;
|
|
|
|
|
|
|
|
jobs.fourStoreEndpoint = {
|
|
|
|
name = "4store-endpoint";
|
2014-11-16 16:04:31 +01:00
|
|
|
startOn = "ip-up";
|
2011-04-15 18:10:17 +02:00
|
|
|
|
|
|
|
exec = ''
|
2013-10-30 18:30:23 +01:00
|
|
|
${run} '${pkgs.rdf4store}/bin/4s-httpd -D ${cfg.options} ${if cfg.listenAddress!=null then "-H ${cfg.listenAddress}" else "" } -p ${toString cfg.port} ${cfg.database}'
|
2011-04-15 18:10:17 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2013-10-30 18:30:23 +01:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2011-04-15 18:10:17 +02:00
|
|
|
}
|