forked from CCCHH/nix-infra
60 lines
1.8 KiB
Nix
60 lines
1.8 KiB
Nix
{ pkgs, ... }:
|
|
|
|
let
|
|
spaceapidSrc = builtins.fetchGit {
|
|
url = "https://git.hamburg.ccc.de/CCCHH/spaceapid.git";
|
|
ref = "main";
|
|
rev = "bbeb0d0e2b4538faed275b9891fb55149bc3a2f8";
|
|
};
|
|
spaceapid = pkgs.buildGoModule rec {
|
|
pname = "spaceapid";
|
|
version = "main";
|
|
|
|
src = spaceapidSrc;
|
|
|
|
ldflags = [
|
|
"-X main.version=${version}-${spaceapidSrc.rev}"
|
|
];
|
|
|
|
# Since spaceapid doesn't have any dependencies, we can set this to null and
|
|
# use the nonexistend vendored dependencies.
|
|
vendorHash = null;
|
|
};
|
|
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);
|
|
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 = {
|
|
ExecStart = "${spaceapid}/bin/spaceapid -c ${spaceapidConfigResponse},${spaceapidConfigDynamic},/secrets/spaceapid-config-ccchh-credentials.secret";
|
|
User = "spaceapi";
|
|
Group = "spaceapi";
|
|
Restart = "on-failure";
|
|
StateDirectory = "spaceapid";
|
|
};
|
|
wantedBy = [ "multi-user.target" ];
|
|
};
|
|
|
|
deployment.keys = {
|
|
"spaceapid-config-ccchh-credentials.secret" = {
|
|
keyCommand = [ "pass" "noc/vm-secrets/chaosknoten/public-web-static/spaceapid-config-ccchh-credentials" ];
|
|
destDir = "/secrets";
|
|
user = "spaceapi";
|
|
group = "spaceapi";
|
|
permissions = "0640";
|
|
uploadAt = "pre-activation";
|
|
};
|
|
};
|
|
}
|