fix(discord): fix jellyfin-rpc dependencies
Some checks failed
build / build-sydpc (push) Successful in 1m48s
build / build-fruitbook (push) Successful in 29s
build / build-deertopia (push) Failing after 51s

- use a systemd oneshot service again lol.
- fix dependencies to run jellyfin-rpc-configure ONCE, and not
  repeatedly each time jellyfin-rpc starts.
This commit is contained in:
2026-03-08 12:03:42 -06:00
parent d5a2f4026a
commit f0841fdd0d

View File

@@ -50,48 +50,35 @@ in {
};
config = lib.mkIf cfg.enable {
systemd.user.services.jellyfin-rpc-configure = {
Service = {
Type = "oneshot";
ExecStart =
let
jq = lib.getExe pkgs.jq;
api-key-file = config.sops.secrets.jellyfin-rpc-api-key.path;
in pkgs.writeShellScript "jellyfin-rpc-configure" ''
dest=''${XDG_CONFIG_HOME:-$HOME/.config}/jellyfin-rpc/main.json
umask 177
[[ -f "$dest" ]] && chmod 600 "$dest"
jq < ${jellyfin-rpc-config-template} > "$dest" \
--rawfile api_key ${api-key-file} \
'.jellyfin.api_key = $api_key'
'';
};
systemd.user.services.jellyfin-rpc-configure =
let api-key-file = config.sops.secrets.jellyfin-rpc-api-key.path;
in {
Unit = {
After = [ "sops-nix.service" ];
Requires = [ "sops-nix.service" ];
X-Restart-Triggers = [ api-key-file ];
};
Install.WantedBy = [ "default.target" ];
Service = {
Type = "oneshot";
ExecStart =
pkgs.writeShellScript "jellyfin-rpc-configure" ''
dest=''${XDG_CONFIG_HOME:-$HOME/.config}/jellyfin-rpc/main.json
mkdir -p "$(dirname "$dest")"
umask 177
[[ -f "$dest" ]] && chmod 600 "$dest"
${lib.getExe pkgs.jq} \
< ${jellyfin-rpc-config-template} \
> "$dest" \
--rawfile api_key ${api-key-file} \
'.jellyfin.api_key = $api_key'
'';
};
};
home.activation.jellyfin-rpc-configure =
let
jq = lib.getExe pkgs.jq;
api-key-file = config.sops.secrets.jellyfin-rpc-api-key.path;
in lib.hm.dag.entryAfter ["writeBoundary"] ''
dest=''${XDG_CONFIG_HOME:-$HOME/.config}/jellyfin-rpc/main.json
um=$(umask)
mkdir -p "$(dirname "$dest")"
umask 177
[[ -f "$dest" ]] && chmod 600 "$dest"
jq < ${jellyfin-rpc-config-template} > "$dest" \
--rawfile api_key ${api-key-file} \
'.jellyfin.api_key = $api_key'
umask $(um)
'';
systemd.user.services.jellyfin-rpc = {
Unit = {
After = ["jellyfin-rpc-configure"];
Wants = ["jellyfin-rpc-configure"];
};
Service = {
ExecStart = lib.getExe pkgs.jellyfin-rpc;
};
Unit.After = [ "jellyfin-rpc-configure.service" ];
Service.ExecStart = lib.getExe pkgs.jellyfin-rpc;
};
sydnix.sops.secrets.jellyfin-rpc-api-key = {};