feat(discord): jellyfin-rpc
This commit is contained in:
@@ -13,51 +13,36 @@ in {
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable
|
||||
(let
|
||||
# Fixes flickering and platform detection on Wayland.
|
||||
vesktop-wayland-wrapper =
|
||||
pkgs.symlinkJoin {
|
||||
name = "vesktop-wayland-wrapper";
|
||||
paths = [ pkgs.callPackage pkgs.vesktop ];
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/vesktop \
|
||||
--add-flags "--disable-gpu-compositing"
|
||||
# --add-flags "--disable-gpu-compositing --ozone-platform-hint=auto"
|
||||
'';
|
||||
};
|
||||
in {
|
||||
sydnix.impermanence.directories =
|
||||
let xdg-config-home =
|
||||
config.home.confighome
|
||||
or "${config.home.homeDirectory}/.config";
|
||||
in [
|
||||
# This directory should really be written in terms of
|
||||
# `config.programs.nixcord.vesktopConfigDir`, but it defaults to null
|
||||
# for unknown reasons. This is in conflict with the docs, which claim
|
||||
# it should be the path used here.
|
||||
(lib.removePrefix
|
||||
config.home.homeDirectory
|
||||
"${xdg-config-home}/vesktop")
|
||||
];
|
||||
imports = [
|
||||
./discord/jellyfin-rpc.nix
|
||||
];
|
||||
|
||||
programs.nixcord = {
|
||||
enable = true;
|
||||
discord = {
|
||||
# Install Vesktop without Discord.
|
||||
enable = false;
|
||||
# openASAR.enable = true;
|
||||
vencord.enable = false;
|
||||
vencord.package = pkgs.vencord;
|
||||
};
|
||||
vesktop = {
|
||||
enable = true;
|
||||
# package =
|
||||
# if cfg.fixWayland
|
||||
# then vesktop-wayland-wrapper
|
||||
# else pkgs.vesktop;
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
sydnix.impermanence.directories =
|
||||
let xdg-config-home =
|
||||
config.home.confighome
|
||||
or "${config.home.homeDirectory}/.config";
|
||||
in [
|
||||
# This directory should really be written in terms of
|
||||
# `config.programs.nixcord.vesktopConfigDir`, but it
|
||||
# defaults to null for unknown reasons. This is in conflict
|
||||
# with the docs, which claim it should be the path used
|
||||
# here.
|
||||
(lib.removePrefix
|
||||
config.home.homeDirectory
|
||||
"${xdg-config-home}/vesktop")
|
||||
];
|
||||
|
||||
programs.nixcord = {
|
||||
enable = true;
|
||||
discord = {
|
||||
enable = false;
|
||||
vencord.enable = false;
|
||||
vencord.package = pkgs.vencord;
|
||||
};
|
||||
});
|
||||
vesktop = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
82
modules/home/discord/jellyfin-rpc.nix
Normal file
82
modules/home/discord/jellyfin-rpc.nix
Normal file
@@ -0,0 +1,82 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.sydnix.discord.jellyfin-rpc;
|
||||
vesktop-wrapper =
|
||||
pkgs.vesktop.overrideAttrs (finalAttrs: prevAttrs: {
|
||||
postFixup = ''
|
||||
${prevAttrs.postFixup or ""}
|
||||
if [[ -e $out/bin/.vesktop-wrapped ]]; then
|
||||
echo ".vesktop-wrapped already exists..."
|
||||
exit 1
|
||||
fi
|
||||
mv $out/bin/vesktop $out/bin/.vesktop-wrapped
|
||||
tee $out/bin/vesktop <<EOF
|
||||
#!/usr/bin/env bash
|
||||
systemctl start --user jellyfin-rpc
|
||||
$out/bin/.vesktop-wrapped "\$@"
|
||||
systemctl stop --user jellyfin-rpc
|
||||
EOF
|
||||
chmod +x $out/bin/vesktop
|
||||
'';
|
||||
});
|
||||
|
||||
jellyfin-rpc-config-template =
|
||||
pkgs.writeText "jellyfin-rpc-config-template"
|
||||
(lib.toJSON {
|
||||
jellyfin = {
|
||||
url = "https://watch.deertopia.net";
|
||||
username = ["lain" "msyds"];
|
||||
music = {
|
||||
display = ["year" "album" "genres"];
|
||||
separator = "-";
|
||||
};
|
||||
};
|
||||
images = {
|
||||
enable_images = true;
|
||||
imgur_images = false;
|
||||
};
|
||||
});
|
||||
in {
|
||||
options.sydnix.discord.jellyfin-rpc = {
|
||||
enable = lib.mkEnableOption "Jellyfin rich presence";
|
||||
};
|
||||
|
||||
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 = {
|
||||
Unit = {
|
||||
After = ["jellyfin-rpc-configure"];
|
||||
Wants = ["jellyfin-rpc-configure"];
|
||||
};
|
||||
Service = {
|
||||
ExecStart = lib.getExe pkgs.jellyfin-rpc;
|
||||
};
|
||||
};
|
||||
|
||||
sydnix.sops.secrets.jellyfin-rpc-api-key = {};
|
||||
|
||||
programs.nixcord.vesktop.package = vesktop-wrapper;
|
||||
|
||||
assertions = [{
|
||||
assertion = config.programs.nixcord.vesktop.enable;
|
||||
message = "Jellyfin RPC requires Vesktop.";
|
||||
}];
|
||||
};
|
||||
}
|
||||
@@ -8,6 +8,7 @@ in {
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
sydnix.discord.enable = true;
|
||||
sydnix.discord.jellyfin-rpc.enable = true;
|
||||
|
||||
stylix.targets.nixcord.enable = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user