65 lines
1.9 KiB
Nix
65 lines
1.9 KiB
Nix
{pkgs, ...}:
|
|
|
|
let
|
|
# Import the inquisitor package
|
|
inquisitorSource = fetchFromGitHub {
|
|
owner = "Jaculabilis";
|
|
repo = "Inquisitor";
|
|
rev = "9001bd8f920cc120f38e998d63a8134969a00032";
|
|
sha256 = "0nx1dszvmn6a86jhj3c9607jqy0bmijjjz3jb3v5lsnpwwkjs5w6";
|
|
};
|
|
inquisitor = callPackage inquisitorSource {};
|
|
|
|
# Create the inquisitor config file in the nix store
|
|
inquisitorConfig = pkgs.writeTextFile "inquisitor.conf" ''
|
|
DataPath = /var/lib/inquisitor/data/
|
|
SourcePath = /var/lib/inquisitor/sources/
|
|
CachePath = /var/lib/inquisitor/cache/
|
|
Verbose = false
|
|
LogFile = /var/log/inquisitor.log
|
|
'';
|
|
in
|
|
{
|
|
# Create a user for the service
|
|
users.users.inquisitor = {
|
|
description = "Inquisitor service user";
|
|
isSystemUser = true;
|
|
packages = [ inquisitor ];
|
|
};
|
|
|
|
# TODO replace with wrapper that sets envvar
|
|
environment.systemPackages = [ inquisitor ];
|
|
|
|
# Set up the inquisitor service
|
|
systemd.services.inquisitor =
|
|
let
|
|
# Inquisitor needs some state set up to work properly
|
|
inquisitorSetup = pkgs.writeShellScriptBin "setup.sh" ''
|
|
mkdir -p /var/lib/inquisitor/data/inquisitor/
|
|
mkdir -p /var/lib/inquisitor/sources/
|
|
mkdir -p /var/lib/inquisitor/cache/
|
|
echo "{}" > /var/lib/inquisitor/data/inquisitor/state
|
|
'';
|
|
# Set up server invocation
|
|
#inquisitorRun = pkgs.writeShellScriptBin "run.sh" ''
|
|
# ${pkgs.gunicorn}/bin/gunicorn
|
|
#''; TODO
|
|
inquisitorRun = pkgs.writeShellScriptBin "run.sh" ''
|
|
${inquisitor}/bin/inquisitor run
|
|
'';
|
|
in {
|
|
description = "Inquisitor server";
|
|
environment = { INQUISITOR_CONFIG = $"{inquisitorConfig}"; }; # TODO gunicorn -e
|
|
preStart = "${inquisitorSetup}/bin/setup.sh";
|
|
script = $"${inquisitorRun}/bin/run.sh";
|
|
serviceConfig = {
|
|
User = "inquisitor";
|
|
Type = "simple";
|
|
WorkingDirectory = "/var/lib/inquisitor/";
|
|
};
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" ];
|
|
enable = true;
|
|
};
|
|
}
|