2022-08-25 15:44:57 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
invtracker,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
port = 19689;
|
|
|
|
configFile = builtins.toFile "config.xml" ''
|
2022-08-14 13:23:50 +00:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<config>
|
|
|
|
<server host="127.0.0.1" port="${toString port}" />
|
2022-08-14 19:34:56 +00:00
|
|
|
<database url="jdbc:sqlite:test.db" />
|
2022-08-14 13:23:50 +00:00
|
|
|
</config>
|
|
|
|
'';
|
2022-08-25 15:44:57 +00:00
|
|
|
in {
|
|
|
|
systemd.services.invtracker = {
|
|
|
|
enable = true;
|
|
|
|
description = "InvTracker";
|
|
|
|
script = "${invtracker.packages.${pkgs.system}.invtracker-server}/bin/server ${configFile}";
|
|
|
|
serviceConfig = {
|
|
|
|
User = "invtracker";
|
|
|
|
Group = "invtracker";
|
|
|
|
WorkingDirectory = "/var/lib/invtracker";
|
|
|
|
Restart = "always";
|
2022-08-14 13:23:50 +00:00
|
|
|
};
|
2022-08-25 15:44:57 +00:00
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
environment = {
|
|
|
|
JAVA_HOME = "${pkgs.openjdk_headless}";
|
2022-08-14 13:23:50 +00:00
|
|
|
};
|
2022-08-25 15:44:57 +00:00
|
|
|
};
|
2022-08-26 15:28:14 +00:00
|
|
|
services.caddy.virtualHosts."invtracker.chir.rs" = {
|
|
|
|
useACMEHost = "chir.rs";
|
|
|
|
extraConfig = ''
|
|
|
|
import baseConfig
|
|
|
|
|
2022-08-28 14:10:30 +00:00
|
|
|
handle_path /assets/* {
|
|
|
|
root * ${invtracker.packages.${pkgs.system}.invtracker-web}/assets
|
|
|
|
file_server {
|
|
|
|
precompressed zstd br gzip
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handle_path /web/* {
|
2022-08-26 15:28:14 +00:00
|
|
|
root * ${invtracker.packages.${pkgs.system}.invtracker-web}
|
2022-08-28 14:10:30 +00:00
|
|
|
file_server {
|
|
|
|
precompressed zstd br gzip
|
|
|
|
}
|
|
|
|
try_files {path} /index.html
|
2022-08-26 15:28:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handle {
|
|
|
|
reverse_proxy http://localhost:${toString port}
|
|
|
|
}
|
|
|
|
'';
|
2022-08-25 15:44:57 +00:00
|
|
|
};
|
|
|
|
users.users.invtracker = {
|
|
|
|
description = "InvTracker";
|
|
|
|
home = "/var/lib/invtracker";
|
|
|
|
useDefaultShell = true;
|
|
|
|
group = "invtracker";
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
users.groups.invtracker = {};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '/var/lib/invtracker' 0750 invtracker invtracker - -"
|
|
|
|
"d '/var/lib/invtracker/media' 0750 invtracker invtracker - -"
|
|
|
|
];
|
|
|
|
}
|