summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2026-03-16 20:48:51 +0100
committerMel <mel@rnrd.eu>2026-03-20 23:52:33 +0100
commitba45d857652b6cfbe9fe4a3006d8e5ea2ff17050 (patch)
tree89088a29a609a5ea1909e4018ea2d562aa460a63 /modules
parent6d88b856e52eec94cf11509562d4d06b3df1e132 (diff)
downloadminerals-ba45d857652b6cfbe9fe4a3006d8e5ea2ff17050.tar.zst
minerals-ba45d857652b6cfbe9fe4a3006d8e5ea2ff17050.zip
Configure MoonDeckBuddy to use with MoonDeck and Sunshine/Moonlight
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'modules')
-rw-r--r--modules/sunshine.nix52
1 files changed, 37 insertions, 15 deletions
diff --git a/modules/sunshine.nix b/modules/sunshine.nix
index 3d44889..9384441 100644
--- a/modules/sunshine.nix
+++ b/modules/sunshine.nix
@@ -1,10 +1,20 @@
-{ me, lib, auxiliaryPkgs, ... }:
+{
+  me,
+  lib,
+  pkgs,
+  auxiliaryPkgs,
+  ...
+}:
 
 let
+  inherit (lib)
+    substring
+    toUpper
+    getExe
+    ;
+
   # todo: move this to a utils package
-  capitalize = str:
-    with builtins;
-    lib.toUpper (substring 0 1 str) + substring 1 (-1) str;
+  capitalize = str: toUpper (substring 0 1 str) + substring 1 (-1) str;
 
   user = "mel";
 in
@@ -37,9 +47,11 @@ in
       };
 
       apps = [
+        # the app that moondeck will call when connecting via moonlight
         {
           name = "MoonDeckStream";
           cmd = "${auxiliaryPkgs.moondeck-buddy}/bin/MoonDeckStream";
+          image-path = "${auxiliaryPkgs.moondeck-buddy}/share/icons/hicolor/256x256/apps/moondeckbuddy.png";
           exclude-global-prep-cmd = "false";
           elevated = "false";
         }
@@ -48,19 +60,29 @@ in
     };
   };
 
-  # configuration for moondeck-buddy for a nicer integration with the steam deck
+  # run the buddy app for the moondeck for a nicer integration of sunshine/moonlight
+  # when using a steam deck!
+  systemd.user.services.moondeck-buddy = {
+    description = "MoonDeck Buddy";
 
-  home-manager.users.${user} =
-    { inputs, config, ... }:
-    {
-      # start moondeck-buddy automatically
-      xdg.autostart = {
-        enable = true;
-        entries = with auxiliaryPkgs; [
-          "${moondeck-buddy}/share/applications/MoonDeckBuddy.desktop"
-        ];
-      };
+    wantedBy = [ "graphical-session.target" ];
+    partOf = [ "graphical-session.target" ];
+    after = [
+      "graphical-session.target"
+      "network-online.target"
+    ];
+
+    serviceConfig = {
+      ExecStart = "${getExe auxiliaryPkgs.moondeck-buddy}";
+
+      # try to stay alive even if something moondeck-buddy depends on,
+      # like steam, crashes.
+      Restart = "on-failure";
+      RestartSec = "5s";
+
+      Environment = "QT_QPA_PLATFORM=wayland";
     };
+  };
 
   networking.firewall.allowedTCPPorts = [ 59999 ]; # port for moondeck-buddy
 }