From 4cc1da46be979a568f12b8fd26ca13b5d2992815 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 6 Oct 2026 17:29:31 -0400 Subject: [PATCH] Add configs for installing sunshine (server) and moonlight (client). --- nix/configuration/configuration.nix | 2 + nix/configuration/hosts/odo/default.nix | 1 + nix/configuration/hosts/quark/default.nix | 1 + nix/configuration/roles/moonlight/default.nix | 25 ++++++++++ nix/configuration/roles/sunshine/default.nix | 50 +++++++++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 nix/configuration/roles/moonlight/default.nix create mode 100644 nix/configuration/roles/sunshine/default.nix diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix index 006578d..4f08f77 100644 --- a/nix/configuration/configuration.nix +++ b/nix/configuration/configuration.nix @@ -65,6 +65,7 @@ in ./roles/memtest86 ./roles/minimal_base ./roles/mitmproxy + ./roles/moonlight ./roles/network ./roles/nix_index ./roles/nix_repl @@ -95,6 +96,7 @@ in ./roles/sshd ./roles/steam ./roles/steam_run_free + ./roles/sunshine ./roles/sway ./roles/tekton ./roles/terraform diff --git a/nix/configuration/hosts/odo/default.nix b/nix/configuration/hosts/odo/default.nix index 08161df..6789136 100644 --- a/nix/configuration/hosts/odo/default.nix +++ b/nix/configuration/hosts/odo/default.nix @@ -119,6 +119,7 @@ me.media.enable = true; me.memtest.enable = true; me.mitmproxy.enable = true; + me.moonlight.enable = true; me.network.enable = true; me.nix_index.enable = true; me.nix_repl.enable = true; diff --git a/nix/configuration/hosts/quark/default.nix b/nix/configuration/hosts/quark/default.nix index ee6a99f..2c6a694 100644 --- a/nix/configuration/hosts/quark/default.nix +++ b/nix/configuration/hosts/quark/default.nix @@ -137,6 +137,7 @@ me.sshd.enable = true; me.steam.enable = true; me.steam_run_free.enable = true; + me.sunshine.enable = true; me.sway.enable = true; me.tekton.enable = true; me.terraform.enable = true; diff --git a/nix/configuration/roles/moonlight/default.nix b/nix/configuration/roles/moonlight/default.nix new file mode 100644 index 0000000..cfe663d --- /dev/null +++ b/nix/configuration/roles/moonlight/default.nix @@ -0,0 +1,25 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + options.me = { + moonlight.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install moonlight."; + }; + }; + + config = lib.mkIf (config.me.moonlight.enable && config.me.graphical) { + environment.systemPackages = with pkgs; [ + moonlight-qt + ]; + }; +} diff --git a/nix/configuration/roles/sunshine/default.nix b/nix/configuration/roles/sunshine/default.nix new file mode 100644 index 0000000..f4d4691 --- /dev/null +++ b/nix/configuration/roles/sunshine/default.nix @@ -0,0 +1,50 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + options.me = { + sunshine.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install sunshine."; + }; + }; + + config = lib.mkIf (config.me.sunshine.enable && config.me.graphical) { + environment.systemPackages = with pkgs; [ + ]; + + services.sunshine = { + enable = true; + autoStart = true; + # capSysAdmin = true; # Only needed on non-wlroots wayland compositors + openFirewall = true; + }; + + # Add user to uinput group to allow sunshine to create virtual input devices like mice/keyboards. + users.users.talexander = { + extraGroups = [ "uinput" ]; + }; + + environment.persistence."/persist" = lib.mkIf (config.me.mountPersistence) { + hideMounts = true; + users.talexander = { + directories = [ + { + directory = ".config/sunshine"; + user = "talexander"; + group = "talexander"; + mode = "0755"; + } + ]; + }; + }; + }; +}