2023-12-05 17:51:52 +01:00
|
|
|
{ pkgs, ... }:
|
2023-11-05 00:03:20 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
spaceapidSrc = builtins.fetchGit {
|
2024-01-15 03:25:48 +01:00
|
|
|
url = "https://git.hamburg.ccc.de/CCCHH/spaceapid.git";
|
2023-11-05 00:03:20 +01:00
|
|
|
ref = "main";
|
2024-01-15 23:39:09 +01:00
|
|
|
rev = "cf9678d7126e1951f9e4aabaa30d7350eb76973b";
|
2023-11-05 00:03:20 +01:00
|
|
|
};
|
2023-12-05 17:51:52 +01:00
|
|
|
spaceapid = pkgs.buildGoModule {
|
2023-11-05 00:03:20 +01:00
|
|
|
pname = "spaceapid";
|
|
|
|
version = "main";
|
|
|
|
|
|
|
|
src = spaceapidSrc;
|
|
|
|
|
|
|
|
# Since spaceapid doesn't have any dependencies, we can set this to null and
|
|
|
|
# use the nonexistend vendored dependencies.
|
|
|
|
vendorHash = null;
|
|
|
|
};
|
2024-01-15 03:25:48 +01:00
|
|
|
spaceapidConfigResponse = pkgs.writeText "spaceapid-config-ccchh-response.json" (builtins.readFile spaceapid-config/ccchh-response.json);
|
|
|
|
spaceapidConfigDynamic = pkgs.writeText "spaceapid-config-ccchh-dynamic.json" (builtins.readFile spaceapid-config/ccchh-dynamic.json);
|
2023-11-05 00:03:20 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
users.users.spaceapi = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "spaceapi";
|
|
|
|
};
|
|
|
|
users.groups.spaceapi = { };
|
|
|
|
|
|
|
|
systemd.services.spaceapid = {
|
|
|
|
enable = true;
|
|
|
|
description = "Daemon hosting the SpaceAPI";
|
|
|
|
unitConfig = {
|
|
|
|
Wants = [ "network-online.target" ];
|
|
|
|
After = [ "network.target" "network-online.target" ];
|
|
|
|
};
|
|
|
|
serviceConfig = {
|
2024-01-15 03:25:48 +01:00
|
|
|
ExecStart = "${spaceapid}/bin/spaceapid -c ${spaceapidConfigResponse},${spaceapidConfigDynamic},/secrets/spaceapid-config-ccchh-credentials.secret";
|
2023-11-05 00:03:20 +01:00
|
|
|
User = "spaceapi";
|
|
|
|
Group = "spaceapi";
|
|
|
|
Restart = "on-failure";
|
2023-11-10 21:56:25 +01:00
|
|
|
StateDirectory = "spaceapid";
|
2023-11-05 00:03:20 +01:00
|
|
|
};
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
deployment.keys = {
|
2024-01-15 03:25:48 +01:00
|
|
|
"spaceapid-config-ccchh-credentials.secret" = {
|
|
|
|
keyCommand = [ "pass" "noc/vm-secrets/chaosknoten/public-web-static/spaceapid-config-ccchh-credentials" ];
|
2023-11-05 00:03:20 +01:00
|
|
|
destDir = "/secrets";
|
|
|
|
user = "spaceapi";
|
|
|
|
group = "spaceapi";
|
|
|
|
permissions = "0640";
|
|
|
|
uploadAt = "pre-activation";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|