From 725ad92c811c01b4bb0e952061a75a355f5f5d32 Mon Sep 17 00:00:00 2001 From: soraefir Date: Wed, 19 Aug 2026 20:18:38 +0200 Subject: [PATCH] Updates and fixes --- flake.lock | 107 +++++++++--------- flake.nix | 2 +- modules/home/gui/apps/mpv/default.nix | 33 ++++++ modules/home/gui/games/wow.nix | 2 +- packages/default.nix | 2 + .../jellyfin-mpv-shim-watchdog/default.nix | 51 +++++++++ shells/devsh/default.nix | 2 +- 7 files changed, 141 insertions(+), 58 deletions(-) create mode 100644 packages/jellyfin-mpv-shim-watchdog/default.nix diff --git a/flake.lock b/flake.lock index 5c4b1ae..8dc194a 100644 --- a/flake.lock +++ b/flake.lock @@ -23,11 +23,11 @@ ] }, "locked": { - "lastModified": 1779036909, - "narHash": "sha256-zXcwYQGCT6pzinK+1dBB2ekTVtfxGZAapb3Evdcu4fY=", + "lastModified": 1786845137, + "narHash": "sha256-oQFip+v0luP8NIxJzmiW4Wu8bILsbFWom5l0zonl8hQ=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "56c666e108467d87d13508936aade6d567f2a501", + "rev": "4cff07de74b50e64bdd68cd4e722ab5b6b35ee48", "type": "github" }, "original": { @@ -74,21 +74,21 @@ "type": "github" } }, - "flake-utils": { + "flake-parts_2": { "inputs": { - "systems": "systems" + "nixpkgs-lib": "nixpkgs-lib_2" }, "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "lastModified": 1772408722, + "narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, @@ -97,11 +97,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1780065812, - "narHash": "sha256-SCSLUKBmwlSLGQ8Xbr8PjRFtiHNk0l9ktqkcmqdBkfE=", + "lastModified": 1787144466, + "narHash": "sha256-HHfv2/HkNSKbbSyU9iD/g8lbP6r4tl33sSw1W4rXCk0=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "b76b5639c0593e0aeb0b5879ad62d4b30596c144", + "rev": "0471accf8d0a8210b31d947497d179ecc99e0021", "type": "github" }, "original": { @@ -117,11 +117,11 @@ ] }, "locked": { - "lastModified": 1779726825, - "narHash": "sha256-RUkMrREjKDQrA+dA9+xZviGAxM5W1aVdyOr/bSYpHrE=", + "lastModified": 1787146702, + "narHash": "sha256-YbRcLdU/yK4gWsQg7V8WTKZHfXL33g8+wSFUX3wyevs=", "owner": "nix-community", "repo": "home-manager", - "rev": "b179bde238977f7d4454fc770b1a727eaf55111c", + "rev": "173b7e8d40fdc8c296a9c99854314f17a3a1704c", "type": "github" }, "original": { @@ -152,11 +152,11 @@ }, "nixUnstable": { "locked": { - "lastModified": 1780030872, - "narHash": "sha256-u6WU/yd/o8iYQrHX3RAwO1hYa3LkoSL+WNQD0rJfJZQ=", + "lastModified": 1787111413, + "narHash": "sha256-sFosWtq21eHGJRnTc/hvf4M1obRgLEUMNm/IzllkHMA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e9a7635a57597d9754eccebdfc7045e6c8600e6b", + "rev": "afe3d8ac4395617bdcdac9f188ac8717a062e014", "type": "github" }, "original": { @@ -174,11 +174,11 @@ ] }, "locked": { - "lastModified": 1780169171, - "narHash": "sha256-3HBYDfBgZ+ph52HS6Ks/bMMwuh2uONIT72sZ1CtLE/s=", + "lastModified": 1784642409, + "narHash": "sha256-hcbDqFuySAJawljt5r0sKBCJKYnbtGD0T/ZIozH1Dq0=", "owner": "nix-community", "repo": "nixos-wsl", - "rev": "998b2821c30b2938637230916904ceb8757c79e8", + "rev": "eaeb18da90024448a60eb1ec7132eafa4003404e", "type": "github" }, "original": { @@ -215,13 +215,28 @@ "type": "github" } }, + "nixpkgs-lib_2": { + "locked": { + "lastModified": 1772328832, + "narHash": "sha256-e+/T/pmEkLP6BHhYjx6GmwP5ivonQQn0bJdH9YrRB+Q=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "c185c7a5e5dd8f9add5b2f8ebeff00888b070742", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs_2": { "locked": { - "lastModified": 1780203844, - "narHash": "sha256-K5sT4jTpGs15ADhviMKNBH38REpPf5Q6mM1+N6cArVE=", + "lastModified": 1787101114, + "narHash": "sha256-gwrPcFf/rDjHPaVflbDZ040ZDmBTRj/7+s8ZmE2SaIM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b51242d7d43689db2f3be91bd05d5b24fbb469c4", + "rev": "b18a4b905f8d028dc4476412e6d6891728695379", "type": "github" }, "original": { @@ -239,11 +254,11 @@ ] }, "locked": { - "lastModified": 1780265777, - "narHash": "sha256-t/KORFHEv8Jn2vFmVfv4Zffekv+MUogI2KgtxuCcEmQ=", + "lastModified": 1787161289, + "narHash": "sha256-CVTJnlo3KGv9XDT7594byKZAT2cZAMQUVvY4/1plK8M=", "owner": "nix-community", "repo": "nur", - "rev": "39917b7f68263188707925ffe26c9df6ef4e7d64", + "rev": "512f014a5717fd8181e971f7a0d12901e35521d3", "type": "github" }, "original": { @@ -273,11 +288,11 @@ ] }, "locked": { - "lastModified": 1777944972, - "narHash": "sha256-VfGRo1qTBKOe3s2gOv8LSoA6Fk19PvBlwQ1ECN0Evn8=", + "lastModified": 1786629091, + "narHash": "sha256-gkig4nPi1CWc4Z50GBsjE4ygSE7hMpl/TwID2an2Cck=", "owner": "Mic92", "repo": "sops-nix", - "rev": "c591bf665727040c6cc5cb409079acb22dcce33c", + "rev": "a8627b21b9107c5711c96b84f32a9a4b3d45295f", "type": "github" }, "original": { @@ -286,34 +301,16 @@ "type": "github" } }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "vscode-server": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": [ - "nixpkgs" - ] + "flake-parts": "flake-parts_2" }, "locked": { - "lastModified": 1770124655, - "narHash": "sha256-yHmd2B13EtBUPLJ+x0EaBwNkQr9LTne1arLVxT6hSnY=", + "lastModified": 1784312229, + "narHash": "sha256-2uHCSUw341o3my1R0U0YCfbnMEazylxb58evWsjGL50=", "owner": "nix-community", "repo": "nixos-vscode-server", - "rev": "92ce71c3ba5a94f854e02d57b14af4997ab54ef0", + "rev": "2f984dfbe7e5271b5c413d3e734374cc1306c921", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 8ac3c46..8f78a00 100755 --- a/flake.nix +++ b/flake.nix @@ -32,7 +32,7 @@ vscode-server = { url = "github:nix-community/nixos-vscode-server"; - inputs.nixpkgs.follows = "nixpkgs"; + # inputs.nixpkgs.follows = "nixpkgs"; }; }; diff --git a/modules/home/gui/apps/mpv/default.nix b/modules/home/gui/apps/mpv/default.nix index 9ac65b3..aad5ab1 100755 --- a/modules/home/gui/apps/mpv/default.nix +++ b/modules/home/gui/apps/mpv/default.nix @@ -1,6 +1,7 @@ { lib, config, pkgs, ... }: let configuredMpv = config.programs.mpv.finalPackage; + shimWatchdog = pkgs.custom.jellyfin-mpv-shim-watchdog; in{ config = lib.mkIf (config.syscfg.make.gui) { @@ -81,5 +82,37 @@ in{ }; programs.yt-dlp.enable = true; + + # The upstream jellyfin-mpv-shim service has no Restart and no network + # ordering: it happily starts while offline (silently dead) and never + # recovers a connection dropped by a network blip. Gate its start on the + # network being up, and let a watchdog notice the "up but not connected" + # state that systemd can't see. See pkgs.custom.jellyfin-mpv-shim-watchdog. + systemd.user.services.jellyfin-mpv-shim.Service = { + ExecStartPre = "${shimWatchdog}/bin/jellyfin-mpv-shim-watchdog wait-online"; + TimeoutStartSec = "infinity"; # stay in start-pre until the network is back + Restart = "on-failure"; + RestartSec = 5; + }; + + systemd.user.services.jellyfin-mpv-shim-watchdog = { + Unit = { + Description = "Restart jellyfin-mpv-shim when it is up but not connected"; + After = [ "jellyfin-mpv-shim.service" ]; + }; + Service = { + Type = "oneshot"; + ExecStart = "${shimWatchdog}/bin/jellyfin-mpv-shim-watchdog check"; + }; + }; + + systemd.user.timers.jellyfin-mpv-shim-watchdog = { + Unit.Description = "Periodic health check for jellyfin-mpv-shim"; + Timer = { + OnActiveSec = "60s"; + OnUnitActiveSec = "60s"; + }; + Install.WantedBy = [ "timers.target" ]; + }; }; } diff --git a/modules/home/gui/games/wow.nix b/modules/home/gui/games/wow.nix index fa9071f..0bb0d03 100644 --- a/modules/home/gui/games/wow.nix +++ b/modules/home/gui/games/wow.nix @@ -5,7 +5,7 @@ home.packages = with pkgs; [ # custom.simc - unstable.instawow + instawow ]; # templates buggy currently diff --git a/packages/default.nix b/packages/default.nix index 95c30e2..2c05fbb 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -7,4 +7,6 @@ vosk = pkgs.callPackage ./vosk { }; eww-ensure-daemon = pkgs.callPackage ./eww-ensure-daemon { }; + + jellyfin-mpv-shim-watchdog = pkgs.callPackage ./jellyfin-mpv-shim-watchdog { }; } diff --git a/packages/jellyfin-mpv-shim-watchdog/default.nix b/packages/jellyfin-mpv-shim-watchdog/default.nix new file mode 100644 index 0000000..d0c866b --- /dev/null +++ b/packages/jellyfin-mpv-shim-watchdog/default.nix @@ -0,0 +1,51 @@ +{ writeShellScriptBin +, coreutils +, findutils +, gnugrep +, iproute2 +, systemd +}: + +# jellyfin-mpv-shim keeps a persistent socket to the Jellyfin server. When the +# machine drops off the network that socket dies, but the process stays alive +# and the unit stays "active" — running yet deaf to cast requests, the "up but +# not working, restart it by hand" case. systemd can't see this: nothing +# crashes and the shim speaks no health protocol, so we probe the real thing — +# is its MainPID still holding a live (established, non-loopback) connection? +# +# check (default) one tick, run by a 60s timer: restart if online but +# not connected, rate-limited to one restart per 5 min +# wait-online block until a real address exists; used as ExecStartPre so the +# unit only starts once online + +writeShellScriptBin "jellyfin-mpv-shim-watchdog" '' + set -u + service="jellyfin-mpv-shim.service" + stamp="''${XDG_RUNTIME_DIR:-/run/user/$(${coreutils}/bin/id -u)}/jellyfin-mpv-shim-watchdog.stamp" + + # A global-scope address on a non-loopback interface — true for a LAN IP too, + # so this needs no server URL and works whether Jellyfin is local or remote. + network_up() { ${iproute2}/bin/ip -o addr show scope global up 2>/dev/null | ${gnugrep}/bin/grep -q .; } + + if [ "''${1:-check}" = wait-online ]; then + while ! network_up; do ${coreutils}/bin/sleep 5; done + exit 0 + fi + + # Healthy: MainPID owns an established socket to something other than loopback. + pid="$(${systemd}/bin/systemctl --user show -p MainPID --value "$service" 2>/dev/null)" + if [ "''${pid:-0}" != 0 ] && ${iproute2}/bin/ss -tnpH state established 2>/dev/null \ + | ${gnugrep}/bin/grep "pid=$pid," \ + | ${gnugrep}/bin/grep -qv -e '127\.0\.0\.1' -e '\[::1\]'; then + exit 0 + fi + + # Not connected: only worth restarting once the network is actually back... + network_up || exit 0 + # ...and not if we already restarted within the last 5 minutes. + [ -e "$stamp" ] && [ -n "$(${findutils}/bin/find "$stamp" -mmin -5 2>/dev/null)" ] && exit 0 + + : > "$stamp" + echo "jellyfin-mpv-shim-watchdog: online but no live connection -> restarting $service" + ${systemd}/bin/systemctl --user restart "$service" +'' diff --git a/shells/devsh/default.nix b/shells/devsh/default.nix index 261b95c..e336e0a 100644 --- a/shells/devsh/default.nix +++ b/shells/devsh/default.nix @@ -38,7 +38,7 @@ pkgs.mkShell { #CUSTOM (custom...) ]) ++ (with pkgs.llvmPackages; [ libcxxClang - ]) ++ (with pkgs.python313Packages; [ + ]) ++ (with pkgs.python3Packages; [ pip pandas numpy matplotlib typer pillow reportlab python-barcode pypdf markdown requests ]) ;