fix(discord): fix jellyfin-rpc dependencies
- 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:
@@ -50,48 +50,35 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
systemd.user.services.jellyfin-rpc-configure = {
|
systemd.user.services.jellyfin-rpc-configure =
|
||||||
Service = {
|
let api-key-file = config.sops.secrets.jellyfin-rpc-api-key.path;
|
||||||
Type = "oneshot";
|
in {
|
||||||
ExecStart =
|
Unit = {
|
||||||
let
|
After = [ "sops-nix.service" ];
|
||||||
jq = lib.getExe pkgs.jq;
|
Requires = [ "sops-nix.service" ];
|
||||||
api-key-file = config.sops.secrets.jellyfin-rpc-api-key.path;
|
X-Restart-Triggers = [ api-key-file ];
|
||||||
in pkgs.writeShellScript "jellyfin-rpc-configure" ''
|
};
|
||||||
dest=''${XDG_CONFIG_HOME:-$HOME/.config}/jellyfin-rpc/main.json
|
Install.WantedBy = [ "default.target" ];
|
||||||
umask 177
|
Service = {
|
||||||
[[ -f "$dest" ]] && chmod 600 "$dest"
|
Type = "oneshot";
|
||||||
jq < ${jellyfin-rpc-config-template} > "$dest" \
|
ExecStart =
|
||||||
--rawfile api_key ${api-key-file} \
|
pkgs.writeShellScript "jellyfin-rpc-configure" ''
|
||||||
'.jellyfin.api_key = $api_key'
|
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 = {
|
systemd.user.services.jellyfin-rpc = {
|
||||||
Unit = {
|
Unit.After = [ "jellyfin-rpc-configure.service" ];
|
||||||
After = ["jellyfin-rpc-configure"];
|
Service.ExecStart = lib.getExe pkgs.jellyfin-rpc;
|
||||||
Wants = ["jellyfin-rpc-configure"];
|
|
||||||
};
|
|
||||||
Service = {
|
|
||||||
ExecStart = lib.getExe pkgs.jellyfin-rpc;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sydnix.sops.secrets.jellyfin-rpc-api-key = {};
|
sydnix.sops.secrets.jellyfin-rpc-api-key = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user