2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-04-15 17:10:17 +01:00
|
|
|
let
|
|
|
|
cfg = config.services.fourStoreEndpoint;
|
|
|
|
endpointUser = "fourstorehttp";
|
2018-03-01 19:38:53 +00:00
|
|
|
run = "${pkgs.su}/bin/su -s ${pkgs.runtimeShell} ${endpointUser} -c";
|
2011-04-15 17:10:17 +01:00
|
|
|
in
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2011-04-15 17:10:17 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2011-04-15 17:10:17 +01:00
|
|
|
services.fourStoreEndpoint = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2011-04-15 17:10:17 +01: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 17:30:23 +00:00
|
|
|
default = null;
|
2011-04-15 17:10:17 +01:00
|
|
|
description = "IP address to listen on.";
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
2013-10-30 17:30:23 +00:00
|
|
|
default = 8080;
|
2011-04-15 17:10:17 +01: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 17:30:23 +00:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
assertions = singleton
|
|
|
|
{ assertion = cfg.enable -> cfg.database != "";
|
|
|
|
message = "Must specify 4Store database name";
|
|
|
|
};
|
2011-04-15 17:10:17 +01:00
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.users = singleton
|
2011-04-15 17:10:17 +01:00
|
|
|
{ name = endpointUser;
|
2014-04-29 09:51:42 +01:00
|
|
|
uid = config.ids.uids.fourstorehttp;
|
2011-04-15 17:10:17 +01:00
|
|
|
description = "4Store SPARQL endpoint user";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.avahi.enable = true;
|
|
|
|
|
2016-01-06 06:50:18 +00:00
|
|
|
systemd.services."4store-endpoint" = {
|
2016-09-10 17:03:59 +01:00
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
2016-01-06 06:50:18 +00:00
|
|
|
script = ''
|
2013-10-30 17:30:23 +00: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 17:10:17 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2013-10-30 17:30:23 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2011-04-15 17:10:17 +01:00
|
|
|
}
|