home-server/services/lk-jwt.nix

62 lines
1.6 KiB
Nix
Raw Normal View History

2026-04-01 14:20:27 -07:00
{ config, pkgs, lib, ... }:
let
# lk-jwt-service isn't in nixpkgs — build from source.
# On first `nix build`, the fake hashes will fail and print the correct ones.
lk-jwt-service = pkgs.buildGoModule {
pname = "lk-jwt-service";
version = "0.3.0";
src = pkgs.fetchFromGitHub {
owner = "element-hq";
repo = "lk-jwt-service";
rev = "v0.3.0";
2026-04-01 14:40:27 -07:00
hash = "sha256-fA33LZkozPTng47kunXWkfUExVbMZsiL8Dtkm1hLV6U=";
2026-04-01 14:20:27 -07:00
};
2026-04-01 14:40:27 -07:00
vendorHash = "sha256-0A9pd+PAsGs4KS2BnCxc7PAaUAV3Z+XKNqSrmYvxNeM=";
2026-04-01 14:20:27 -07:00
meta.mainProgram = "lk-jwt-service";
};
in
{
sops.secrets."livekit/api_key" = {
sopsFile = ./secrets/livekit_vps.yaml;
mode = "0400";
2026-04-01 14:46:37 -07:00
owner = "livekit";
group = "livekit";
2026-04-01 14:20:27 -07:00
};
sops.secrets."livekit/api_secret" = {
sopsFile = ./secrets/livekit_vps.yaml;
mode = "0400";
2026-04-01 14:46:37 -07:00
owner = "livekit";
group = "livekit";
2026-04-01 14:20:27 -07:00
};
systemd.services.lk-jwt = {
description = "LiveKit JWT service for Matrix OpenID token exchange";
wantedBy = [ "multi-user.target" ];
after = [
"network-online.target"
"livekit.service"
];
wants = [ "network-online.target" ];
serviceConfig = {
2026-04-01 14:46:37 -07:00
User = "livekit";
Group = "livekit";
2026-04-01 14:20:27 -07:00
Restart = "always";
RestartSec = 5;
};
2026-04-01 14:46:37 -07:00
environment = {
LIVEKIT_URL = "wss://livekit.ellie.town";
2026-04-19 15:33:09 -07:00
LIVEKIT_FULL_ACCESS_HOMESERVERS = "ellie.town";
2026-04-01 14:46:37 -07:00
LK_JWT_PORT = "8080";
};
2026-04-01 14:20:27 -07:00
2026-04-01 14:46:37 -07:00
script = ''
2026-04-01 14:49:52 -07:00
export LIVEKIT_KEY_FROM_FILE=${config.sops.secrets."livekit/api_key".path}
export LIVEKIT_SECRET_FROM_FILE=${config.sops.secrets."livekit/api_secret".path}
2026-04-01 14:20:27 -07:00
exec ${lk-jwt-service}/bin/lk-jwt-service
'';
};
}