From 5b388c59d40817495c97e0414b9082542ee7825d Mon Sep 17 00:00:00 2001 From: Jimbo Date: Mon, 2 Sep 2024 19:07:17 -0400 Subject: [PATCH] Add initial support for Steam Deck --- flake.nix | 13 ++++++++++ nixos/deck.nix | 37 +++++++++++++++++++++++++++ nixos/deck/greetd-steam.nix | 19 ++++++++++++++ nixos/deck/jovian.nix | 15 +++++++++++ nixos/desktop.nix | 1 + nixos/desktop/greetd-sway.nix | 39 ++++++++++++++++++++++++++++ nixos/desktop/wayland.nix | 48 +++-------------------------------- 7 files changed, 127 insertions(+), 45 deletions(-) create mode 100644 nixos/deck.nix create mode 100644 nixos/deck/greetd-steam.nix create mode 100644 nixos/deck/jovian.nix create mode 100644 nixos/desktop/greetd-sway.nix diff --git a/flake.nix b/flake.nix index 8efc778..04c74c3 100644 --- a/flake.nix +++ b/flake.nix @@ -67,6 +67,12 @@ nixos-mailserver.nixosModule ]; }; + JimDeck = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs outputs;}; + modules = [ + ./nixos/deck.nix + ]; + }; }; # Standalone home-manager configuration entrypoint @@ -87,6 +93,13 @@ ./home-manager/jimbo_server.nix ]; }; + "jimbo@JimDeck" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; + extraSpecialArgs = {inherit inputs outputs;}; + modules = [ + ./home-manager/jimbo_server.nix + ]; + }; # Derivation for ssh envrionments on other people's servers "jimbo@SSH" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; diff --git a/nixos/deck.nix b/nixos/deck.nix new file mode 100644 index 0000000..d591d49 --- /dev/null +++ b/nixos/deck.nix @@ -0,0 +1,37 @@ +{ + imports = [ + # Base configs + ./base.nix + + # Import users and groups + ./users/jimbo.nix + ./users/groups.nix + + # Desktop only + ./desktop/misc.nix + ./desktop/sway.nix + ./desktop/gaming.nix + ./desktop/pipewire.nix + ./desktop/bluetooth.nix + ./desktop/firewall.nix + ./desktop/fonts.nix + ./desktop/qt.nix + + # Steam Deck only + ./deck/jovian.nix + + # Modules + ./modules/security.nix + + # Hardware + ./hardware/machines/deck.nix + ./hardware/systemdboot.nix + ./hardware/opengl.nix + + # Services + ./services/openssh.nix + ./services/mpd.nix + ]; + + networking.hostName = "JimDesktop"; +} diff --git a/nixos/deck/greetd-steam.nix b/nixos/deck/greetd-steam.nix new file mode 100644 index 0000000..5e1164b --- /dev/null +++ b/nixos/deck/greetd-steam.nix @@ -0,0 +1,19 @@ +{pkgs, ...}: { + services = { + # Configure greetd for "auto" login (single user only) + greetd = { + enable = true; + restart = true; + settings = { + terminal = { + vt = 2; + switch = true; + }; + default_session = { + command = "start-gamescope-session"; + user = "jimbo"; + }; + }; + }; + }; +} diff --git a/nixos/deck/jovian.nix b/nixos/deck/jovian.nix new file mode 100644 index 0000000..099ccf3 --- /dev/null +++ b/nixos/deck/jovian.nix @@ -0,0 +1,15 @@ +{ + imports = [ + ./greetd-steam.nix + ]; + + jovian = { + steam = { + enable = true; + desktopSession = "sway"; + }; + decky-loader.enable = true; + devices.steamdeck.enable = true; + steamos.useSteamOSConfig = true; + }; +} diff --git a/nixos/desktop.nix b/nixos/desktop.nix index f18c17d..0f5ac9b 100644 --- a/nixos/desktop.nix +++ b/nixos/desktop.nix @@ -10,6 +10,7 @@ # Desktop only ./desktop/misc.nix ./desktop/sway.nix + ./desktop/greetd-sway.nix ./desktop/printing.nix ./desktop/gaming.nix ./desktop/pipewire.nix diff --git a/nixos/desktop/greetd-sway.nix b/nixos/desktop/greetd-sway.nix new file mode 100644 index 0000000..11a4bea --- /dev/null +++ b/nixos/desktop/greetd-sway.nix @@ -0,0 +1,39 @@ +{pkgs, ...}: { + services = { + # Configure greetd for "auto" login (single user only) + greetd = let + startSway = pkgs.writeScript "startsway" '' + # Use NVIDIA variables if drivers are in use + if lspci -k | grep "Kernel driver in use: nvidia" &> /dev/null; then + # NVIDIA/AMD variables + export LIBVA_DRIVER_NAME=nvidia + export GBM_BACKEND=nvidia-drm + export __GLX_VENDOR_LIBRARY_NAME=nvidia + export WLR_NO_HARDWARE_CURSORS=1 + else + : + fi + + # Sway/Wayland + export XDG_CURRENT_DESKTOP=sway + export QT_QPA_PLATFORM="wayland;xcb" + + # Start Sway + sway --unsupported-gpu + ''; + in { + enable = true; + restart = true; + settings = { + terminal = { + vt = 2; + switch = true; + }; + default_session = { + command = "${startSway}"; + user = "jimbo"; + }; + }; + }; + }; +} diff --git a/nixos/desktop/wayland.nix b/nixos/desktop/wayland.nix index 250e4cc..ceb211f 100644 --- a/nixos/desktop/wayland.nix +++ b/nixos/desktop/wayland.nix @@ -1,54 +1,12 @@ {pkgs, ...}: { - services = { - # Configure greetd for "auto" login (single user only) - greetd = let - startSway = pkgs.writeScript "startsway" '' - # Use NVIDIA variables if drivers are in use - if lspci -k | grep "Kernel driver in use: nvidia" &> /dev/null; then - # NVIDIA/AMD variables - export LIBVA_DRIVER_NAME=nvidia - export GBM_BACKEND=nvidia-drm - export __GLX_VENDOR_LIBRARY_NAME=nvidia - export WLR_NO_HARDWARE_CURSORS=1 - else - : - fi - - # Sway/Wayland - export XDG_CURRENT_DESKTOP=sway - export QT_QPA_PLATFORM="wayland;xcb" - - # Start Sway - sway --unsupported-gpu - ''; - in { - enable = true; - restart = true; - settings = { - terminal = { - vt = 2; - switch = true; - }; - default_session = { - command = "${startSway}"; - user = "jimbo"; - }; - }; - }; - dbus.enable = true; - }; - - programs.xwayland = { - enable = true; - }; - - # Enable backlight and theme control programs = { dconf.enable = true; light.enable = true; + xwayland.enable = true; }; - # Packages needed for Wayland + services.dbus.enable = true; + environment.systemPackages = with pkgs; [ wl-clipboard wdisplays