2023-12-05 17:51:52 +01:00
|
|
|
{ pkgs, ... }:
|
2023-11-05 00:03:20 +01:00
|
|
|
|
|
|
|
let
|
2024-08-04 21:03:29 +02:00
|
|
|
version = "v0.1.0";
|
|
|
|
spaceapidSrc = pkgs.fetchgit {
|
2024-01-15 03:25:48 +01:00
|
|
|
url = "https://git.hamburg.ccc.de/CCCHH/spaceapid.git";
|
2024-08-04 21:03:29 +02:00
|
|
|
rev = version;
|
|
|
|
hash = "sha256-2SDhliltzyydPPZdNn/htDydiK/SHQcYyG/dQ0EyFrY=";
|
2023-11-05 00:03:20 +01:00
|
|
|
};
|
2024-01-16 02:46:09 +01:00
|
|
|
spaceapid = pkgs.buildGoModule rec {
|
2023-11-05 00:03:20 +01:00
|
|
|
pname = "spaceapid";
|
2024-08-04 21:03:29 +02:00
|
|
|
inherit version;
|
2023-11-05 00:03:20 +01:00
|
|
|
|
|
|
|
src = spaceapidSrc;
|
2024-03-06 22:50:32 +01:00
|
|
|
|
2024-01-16 02:46:09 +01:00
|
|
|
ldflags = [
|
2024-08-04 21:03:29 +02:00
|
|
|
"-X main.version=${version}"
|
2024-01-16 02:46:09 +01:00
|
|
|
];
|
2023-11-05 00:03:20 +01:00
|
|
|
|
|
|
|
# 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-05-26 03:49:43 +02:00
|
|
|
ExecStart = "${spaceapid}/bin/spaceapid -c ${spaceapidConfigResponse},${spaceapidConfigDynamic},/run/secrets/spaceapid_config_ccchh_credentials";
|
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" ];
|
|
|
|
};
|
|
|
|
|
2024-05-26 03:49:43 +02:00
|
|
|
sops.secrets."spaceapid_config_ccchh_credentials" = {
|
|
|
|
mode = "0440";
|
|
|
|
owner = "spaceapi";
|
|
|
|
group = "spaceapi";
|
|
|
|
restartUnits = [ "spaceapid.service" ];
|
2023-11-05 00:03:20 +01:00
|
|
|
};
|
|
|
|
}
|