summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2026-03-08 00:43:07 +0100
committerMel <mel@rnrd.eu>2026-03-16 20:51:38 +0100
commitc6149a5bedd00e7aefeca1524c19f210ed05718d (patch)
treedc92b2f043cbc0c0fbc68c6d3cbfde333b5da78f
parent11db9a69a4f82f4219961e8035ec9b9d5dce32af (diff)
downloadminerals-c6149a5bedd00e7aefeca1524c19f210ed05718d.tar.zst
minerals-c6149a5bedd00e7aefeca1524c19f210ed05718d.zip
Add Moondeck utilities to aid Sunshine on remote servers
Signed-off-by: Mel <mel@rnrd.eu>
-rw-r--r--modules/sunshine.nix67
-rw-r--r--pkgs/default.nix2
-rw-r--r--pkgs/moondeck-buddy.nix67
-rw-r--r--roles/remote-server.nix21
4 files changed, 139 insertions, 18 deletions
diff --git a/modules/sunshine.nix b/modules/sunshine.nix
new file mode 100644
index 0000000..399fe70
--- /dev/null
+++ b/modules/sunshine.nix
@@ -0,0 +1,67 @@
+{ me, lib, auxiliaryPkgs, ... }:
+
+let
+ # todo: move this to a utils package
+ capitalize = str:
+ with builtins;
+ lib.toUpper (substring 0 1 str) + substring 1 (-1) str;
+
+ user = "mel";
+in
+{
+ services.sunshine = {
+ enable = true;
+ autoStart = true;
+ capSysAdmin = true;
+ openFirewall = true;
+
+ settings = {
+ sunshine_name = capitalize me.name;
+
+ # note: these are the settings for wolfram and it's intel arc b570 gpu
+ # in particular, should be adjusted for different setups when used!
+ adapter_name = "/dev/dri/renderD128"; # primary card should be located here
+ encoder = "vaapi"; # or "qsv" is quicksync is better supported
+ av1_mode = 2;
+ audio_sink = "alsa_output.pci-0000_29_00.0.hdmi-stereo";
+
+ # no need for encryption since we are going through a secure network anyway
+ lan_encryption_mode = 0;
+ wan_encryption_mode = 0;
+ origin_web_ui_allowed = "wan"; # allow access everywhere
+ };
+
+ applications = {
+ env = {
+ # give sunshine access to binaries (we can install stuff into .local/bin if we want)
+ PATH = "$(PATH):/run/current-system/sw/bin:/etc/profiles/per-user/${user}/bin:$(HOME)/.local/bin";
+ };
+
+ apps = [
+ {
+ name = "MoonDeckStream";
+ cmd = "${auxiliaryPkgs.moondeck-buddy}/bin/MoonDeckStream";
+ exclude-global-prep-cmd = "false";
+ elevated = "false";
+ }
+ # + default applications, desktop, low-res desktop, steam big picture
+ ];
+ };
+ };
+
+ # configuration for moondeck-buddy for a nicer integration with the steam deck
+
+ home-manager.users.${user} =
+ { inputs, config, ... }:
+ {
+ # start moondeck-buddy automatically
+ xdg.autostart = {
+ enable = true;
+ entries = with auxiliaryPkgs; [
+ "${moondeck-buddy}/share/applications/MoonDeckBuddy.desktop"
+ ];
+ };
+ };
+
+ networking.firewall.allowedTCPPorts = [ 59999 ]; # port for moondeck-buddy
+}
diff --git a/pkgs/default.nix b/pkgs/default.nix
index eeeb5a7..c2436d9 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -18,4 +18,6 @@
wine = pkgs.callPackage ./wine.nix { };
yubikey-touch-detector = pkgs.callPackage ./yubikey-touch-detector { };
+
+ moondeck-buddy = pkgs.callPackage ./moondeck-buddy.nix { };
}
diff --git a/pkgs/moondeck-buddy.nix b/pkgs/moondeck-buddy.nix
new file mode 100644
index 0000000..1b4c81f
--- /dev/null
+++ b/pkgs/moondeck-buddy.nix
@@ -0,0 +1,67 @@
+# this package is currently waiting for approval into nixpkgs.
+# see: https://github.com/NixOS/nixpkgs/pull/375287
+{
+ lib,
+ stdenv,
+ fetchFromGitHub,
+ nix-update-script,
+ kdePackages,
+ cmake,
+ ninja,
+ qt6,
+ procps,
+ xorg,
+ steam,
+ useNixSteam ? true,
+}:
+
+let
+ inherit (kdePackages) qtbase wrapQtAppsHook;
+ qtEnv =
+ with qt6;
+ env "qt-env-custom-${qtbase.version}" [
+ qthttpserver
+ qtwebsockets
+ ];
+in
+stdenv.mkDerivation (finalAttrs: {
+ pname = "moondeck-buddy";
+ version = "1.9.1";
+
+ src = fetchFromGitHub {
+ owner = "FrogTheFrog";
+ repo = "moondeck-buddy";
+ tag = "v${finalAttrs.version}";
+ fetchSubmodules = true;
+ hash = "sha256-ASqEyhELzOz0sU5sysluay0pMqiBj1lFCEWMQ0oe8YE=";
+ };
+
+ buildInputs = [
+ procps
+ xorg.libXrandr
+ qtbase
+ qtEnv
+ ];
+ nativeBuildInputs = [
+ cmake
+ ninja
+ wrapQtAppsHook
+ ];
+
+ postPatch = lib.optionalString useNixSteam ''
+ substituteInPlace src/lib/shared/appmetadata.cpp \
+ --replace-fail /usr/bin/steam ${lib.getExe steam};
+ '';
+
+ passthru.updateScript = nix-update-script { };
+
+ meta = {
+ mainProgram = "MoonDeckBuddy";
+ description = "Helper to work with moonlight on a steamdeck";
+ homepage = "https://github.com/FrogTheFrog/moondeck-buddy";
+ changelog = "https://github.com/FrogTheFrog/moondeck-buddy/releases/tag/v${finalAttrs.version}";
+ license = lib.licenses.lgpl3Only;
+ maintainers = with lib.maintainers; [ redxtech ];
+ platforms = lib.platforms.linux;
+ };
+})
diff --git a/roles/remote-server.nix b/roles/remote-server.nix
index c9a2efb..6091bd7 100644
--- a/roles/remote-server.nix
+++ b/roles/remote-server.nix
@@ -5,6 +5,9 @@
imports = [
# we inherit from desktop
./desktop.nix
+
+ # primary streaming setup
+ ../modules/sunshine.nix
];
virtualisation = {
@@ -29,24 +32,6 @@
openFirewall = true;
};
- services.sunshine = {
- enable = true;
- autoStart = true;
- capSysAdmin = true;
- openFirewall = true;
- settings = {
- adapter_name = "/dev/dri/renderD128"; # primary card should be located here
- encoder = "vaapi"; # or "qsv" is quicksync is better supported
- av1_mode = 2;
- audio_sink = "alsa_output.pci-0000_29_00.0.hdmi-stereo";
- # no need for encryption since we are going through a secure network anyway
- lan_encryption_mode = 0;
- wan_encryption_mode = 0;
- origin_web_ui_allowed = "wan"; # allow access everywhere
- sunshine_name = "Wolfram"; # todo: change
- };
- };
-
# override desktop configuration, because we do run SSH
# on remote-servers.
age.identityPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];