diff --git a/etcnixos/common.nix b/etcnixos/common.nix index 949883e..c4e74e2 100644 --- a/etcnixos/common.nix +++ b/etcnixos/common.nix @@ -33,11 +33,23 @@ services.kmscon.enable = true; + # Gamescope configuration for Steam Deck-like experience + programs = { + gamescope = { + enable = true; + capSysNice = true; + }; + steam = { + enable = true; + gamescopeSession.enable = true; + }; + }; + services.greetd = { enable = true; settings = { default_session = { - command = "${lib.getExe pkgs.tuigreet} --time --cmd niri-session"; + command = "${lib.getExe pkgs.tuigreet} --sessions --time"; user = username; }; terminal.vt = lib.mkForce 2; diff --git a/etcnixos/system-yarn.nix b/etcnixos/system-yarn.nix index efe5e05..b49d963 100644 --- a/etcnixos/system-yarn.nix +++ b/etcnixos/system-yarn.nix @@ -25,20 +25,26 @@ fsType = "f2fs"; options = [ "nofail" ]; }; + networking.hostId = "abf570f9"; services.openssh = { enable = true; ports = [ 22 ]; settings = { - PasswordAuthentication = true; - AllowUsers = null; # Allows all users by default. Can be [ "user1" "user2" ] - UseDns = true; - X11Forwarding = false; - PermitRootLogin = "yes"; # "yes", "without-password", "prohibit-password", "forced-commands-only", "no" + PasswordAuthentication = false; + PermitRootLogin = "yes"; }; }; + users.users.${username}.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO4jL6gYOunUlUtPvGdML0cpbKSsPNqQ1jit4E7U1RyH" # laptop + ]; + + users.users.root.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO4jL6gYOunUlUtPvGdML0cpbKSsPNqQ1jit4E7U1RyH" # laptop + ]; + programs.steam = { remotePlay.openFirewall = true; localNetworkGameTransfers.openFirewall = true; diff --git a/flake.lock b/flake.lock index d86b64d..11a9cf4 100644 --- a/flake.lock +++ b/flake.lock @@ -15,6 +15,28 @@ "type": "github" } }, + "deploy-rs": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1762286984, + "narHash": "sha256-9I2H9x5We6Pl+DBYHjR1s3UT8wgwcpAH03kn9CqtdQc=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "9c870f63e28ec1e83305f7f6cb73c941e699f74f", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", + "type": "github" + } + }, "disko": { "inputs": { "nixpkgs": [ @@ -62,11 +84,11 @@ ] }, "locked": { - "lastModified": 1762997295, - "narHash": "sha256-/4kxhVbD/wHVVg9B2srm1NzXEEmEI239JwMtyNYgZQQ=", + "lastModified": 1763310170, + "narHash": "sha256-XFB1UvfWL9JgJqBKicGe2f8+cW7zh1yMcgKof8dGlvw=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "4897d454109bd9965a8372363169a5b676753094", + "rev": "d33a3fae28a7f2c8ab0b6bdfd929eb73692ce06a", "type": "github" }, "original": { @@ -76,6 +98,22 @@ } }, "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { "flake": false, "locked": { "lastModified": 1747046372, @@ -141,11 +179,11 @@ ] }, "locked": { - "lastModified": 1762964643, - "narHash": "sha256-RYHN8O/Aja59XDji6WSJZPkJpYVUfpSkyH+PEupBJqM=", + "lastModified": 1763313531, + "narHash": "sha256-yvdCYUL85zEDp2NzPUBmaNBXP6KnWEOhAk3j7PTfsKw=", "owner": "nix-community", "repo": "home-manager", - "rev": "827f2a23373a774a8805f84ca5344654c31f354b", + "rev": "3670a78eee49deebe4825fc8ecc46b172d1a8391", "type": "github" }, "original": { @@ -172,7 +210,7 @@ "lanzaboote": { "inputs": { "crane": "crane", - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "flake-parts": "flake-parts", "nixpkgs": [ "nixpkgs" @@ -183,11 +221,11 @@ ] }, "locked": { - "lastModified": 1762205063, - "narHash": "sha256-If6vQ+KvtKs3ARBO9G3l+4wFSCYtRBrwX1z+I+B61wQ=", + "lastModified": 1763154177, + "narHash": "sha256-LIIrMS2f2pPT2/BHs8dfGeupI23v5DNcoRz3W+iMsUA=", "owner": "nix-community", "repo": "lanzaboote", - "rev": "88b8a563ff5704f4e8d8e5118fb911fa2110ca05", + "rev": "70be03ab23d0988224e152f5b52e2fbf44a6d8ee", "type": "github" }, "original": { @@ -210,11 +248,11 @@ "xwayland-satellite-unstable": "xwayland-satellite-unstable" }, "locked": { - "lastModified": 1762938849, - "narHash": "sha256-ltM04Wy+vMm/EAwhGTl2BYjCgF+Kq4lltpDH9NEh264=", + "lastModified": 1763289873, + "narHash": "sha256-vzVbMit/Y8IdSYiN2jal77Bp0uRw3MNqSoqy0l4dYoo=", "owner": "sodiboo", "repo": "niri-flake", - "rev": "ea9b76cfa921d42a7502260b2d1296798089dfe6", + "rev": "13d47ed15fc3d8cc98ad42525e85851faf15a47c", "type": "github" }, "original": { @@ -243,11 +281,11 @@ "niri-unstable": { "flake": false, "locked": { - "lastModified": 1762881062, - "narHash": "sha256-j0Gxopn4jGYQae/90V2v4u4+Ec+gFLq3UbSaGfczpOM=", + "lastModified": 1763286485, + "narHash": "sha256-noCCGXkqQxHT+Pk723/poMqkbLHPtgENwg/kntlh2mA=", "owner": "YaLTeR", "repo": "niri", - "rev": "5b77107161c504376b962107913bf74b575703e7", + "rev": "9dad215b9f384310dea53fbd1aa8010e42f779f4", "type": "github" }, "original": { @@ -265,14 +303,14 @@ "nixpkgs": [ "nixpkgs" ], - "systems": "systems" + "systems": "systems_2" }, "locked": { - "lastModified": 1762937100, - "narHash": "sha256-vVM8PKSd9MRRmeMQ4qOLIhsUtBnEozHXr8e20xvpX78=", + "lastModified": 1763282415, + "narHash": "sha256-Blb9l3DjFXjhYOqR7RoA/TQUS7BnBN4VufpRvG4XSlo=", "owner": "marienz", "repo": "nix-doom-emacs-unstraightened", - "rev": "e2cfa1ca0af3e6e5dc01bd5ba478e0c623251504", + "rev": "b04d4b93dc60bc586224b28564b116f0692ce05c", "type": "github" }, "original": { @@ -314,11 +352,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1762844143, - "narHash": "sha256-SlybxLZ1/e4T2lb1czEtWVzDCVSTvk9WLwGhmxFmBxI=", + "lastModified": 1762977756, + "narHash": "sha256-4PqRErxfe+2toFJFgcRKZ0UI9NSIOJa+7RXVtBhy4KE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9da7f1cf7f8a6e2a7cb3001b048546c92a8258b4", + "rev": "c5ae371f1a6a7fd27823bc500d9390b38c05fa55", "type": "github" }, "original": { @@ -356,6 +394,7 @@ }, "root": { "inputs": { + "deploy-rs": "deploy-rs", "disko": "disko", "emacs-overlay": "emacs-overlay", "home-manager": "home-manager", @@ -377,11 +416,11 @@ ] }, "locked": { - "lastModified": 1763001554, - "narHash": "sha256-wsfhRTuxu6f06RMmP4JWcq3wWRlmYtQaJZ6b3f+EJ94=", + "lastModified": 1763260832, + "narHash": "sha256-KMEJ9S7bZLvDIfVu2XdEJTZVYAc/arjFt5KnhGqwCOg=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "315d97eb753cee8e1aa039a5e622b84d32a454bb", + "rev": "c3cea2a0ec0d5debbef4aa2a0cfe59bd0fb0aeeb", "type": "github" }, "original": { @@ -405,6 +444,39 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "xwayland-satellite-stable": { "flake": false, "locked": { @@ -448,11 +520,11 @@ ] }, "locked": { - "lastModified": 1763007974, - "narHash": "sha256-XMgjrDIHonLqIjc1eMQkLeemGcNqqYU0Dq+zNmeMYOI=", + "lastModified": 1763317021, + "narHash": "sha256-UOP9AyuBvQCEzGe6u8FxuhnJU2ShUPU4G7z7zraFNoo=", "owner": "0xc000022070", "repo": "zen-browser-flake", - "rev": "eff1c79c78950ebb4ce70c3d51513e294cf30b52", + "rev": "db2be18049b9159a33ee7083566040fca4254c03", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 743f7c5..478cb19 100644 --- a/flake.nix +++ b/flake.nix @@ -57,6 +57,11 @@ url = "github:nix-community/impermanence"; inputs.nixpkgs.follows = "nixpkgs"; }; + + deploy-rs = { + url = "github:serokell/deploy-rs"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -66,6 +71,7 @@ lanzaboote, nixos-hardware, home-manager, + deploy-rs, ... }@inputs: let @@ -78,6 +84,7 @@ in { formatter.${system} = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style; + nixosConfigurations = nixpkgs.lib.foldl' ( config: hostname: config @@ -110,5 +117,14 @@ }; } ) { } hostnames; + + # Deploy-rs configuration for yarn host only + deploy.nodes.yarn = { + hostname = "desktop"; + profiles.system = { + user = "root"; + path = deploy-rs.lib.${system}.activate.nixos self.nixosConfigurations.yarn; + }; + }; }; } diff --git a/home-manager/home-yarn.nix b/home-manager/home-yarn.nix index d6f4614..d47f01d 100644 --- a/home-manager/home-yarn.nix +++ b/home-manager/home-yarn.nix @@ -16,8 +16,81 @@ # https://github.com/NixOS/nixpkgs/pull/339370#issuecomment-2731336341 bs-manager + + # Steam session scripts + (writeShellScriptBin "steam-session" '' + #!/usr/bin/env bash + set -xeuo pipefail + + gamescopeArgs=( + --adaptive-sync # VRR support + --hdr-enabled + --mangoapp # performance overlay + --rt + --steam + ) + + steamArgs=( + -pipewire-dmabuf + -tenfoot + ) + + mangoConfig=( + cpu_temp + gpu_temp + ram + vram + ) + + mangoVars=( + MANGOHUD=1 + MANGOHUD_CONFIG="$(IFS=,; echo "''${mangoConfig[*]}")" + ) + + export "''${mangoVars[@]}" + exec gamescope "''${gamescopeArgs[@]}" -- steam "''${steamArgs[@]}" + '') + + (writeShellScriptBin "steam-session-greetd" '' + #!/usr/bin/env bash + set -xeuo pipefail + + # Set environment variables for Steam gaming session + export STEAM_RUNTIME=1 + export SDL_VIDEODRIVER=wayland + export QT_QPA_PLATFORM=wayland + export GDK_BACKEND=wayland + export XDG_CURRENT_DESKTOP=Steam + export XDG_SESSION_TYPE=wayland + + # Kill any existing compositor + pkill niri || true + + # Start Steam in Big Picture mode with gamescope + exec steam-session + '') ]; + # Create desktop entry for Steam session + xdg.dataFile."wayland-sessions/steam-session.desktop".text = '' + [Desktop Entry] + Name=Steam Session + Comment=Steam Deck-like gaming session with gamescope + Exec=${config.home.homeDirectory}/.nix-profile/bin/steam-session-greetd + Type=Application + DesktopNames=steam + ''; + + # Create desktop entry for Niri session + xdg.dataFile."wayland-sessions/niri-session.desktop".text = '' + [Desktop Entry] + Name=Niri Session + Comment=Niri Wayland compositor + Exec=${config.programs.niri.package}/bin/niri-session + Type=Application + DesktopNames=niri + ''; + programs.obs-studio = { enable = true; plugins = with pkgs.obs-studio-plugins; [