Skip to content

Commit

Permalink
added windows-zalman gaming configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
heywoodlh committed Dec 17, 2024
1 parent ba902cc commit 23ad209
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 59 deletions.
61 changes: 58 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
};
#proxmox-nixos.url = "github:SaumonNet/proxmox-nixos";
proxmox-nixos.url = "github:heywoodlh/proxmox-nixos";
nvidia-patch = {
url = "github:icewind1991/nvidia-patch-nixos";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs@{ self,
Expand Down Expand Up @@ -117,6 +121,7 @@
lanzaboote,
comin,
proxmox-nixos,
nvidia-patch,
... }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
Expand Down Expand Up @@ -288,6 +293,13 @@
./nixos/hosts/zenbook-14/configuration.nix
];
};
nixos-zalman = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = inputs;
modules = [
./nixos/hosts/zalman/configuration.nix
];
};
nixos-usb = nixpkgs.lib.nixosSystem {
system = "${system}";
specialArgs = inputs;
Expand Down
86 changes: 86 additions & 0 deletions nixos/hosts/zalman/configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Config specific to my Zalman gaming PC
{ config, pkgs, nixpkgs-stable, lib, ... }:

let
system = pkgs.system;
stable-pkgs = import nixpkgs-stable {
inherit system;
config.allowUnfree = true;
};
in {
imports = [
./hardware-configuration.nix
../../server.nix
../../roles/gaming/nvidia-patch.nix
../../roles/gaming/sunshine.nix
];

boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.supportedFilesystems = [ "ntfs" ];

networking.hostName = "nixos-zalman";
networking.networkmanager.enable = true;
time.timeZone = "America/Denver";
i18n.defaultLocale = "en_US.utf8";

home-manager.users.heywoodlh = {
heywoodlh.home.applications = [
{
name = "Rustdesk";
command = ''
bash -c "SHELL='/run/current-system/sw/bin/bash' ${pkgs.rustdesk-flutter}/bin/rustdesk"
'';
}
];
};

environment.systemPackages = with pkgs; [
playerctl
exfatprogs
];

# spotifyd
services.spotifyd = {
enable = true;
settings = {
global = {
username = "31los4pph7awxi3i2inw5xiyut4u";
password_cmd = "cat /opt/spotify.txt";
dbus_type = "system"; # headless mode :)
device_name = "windows-zalman";
};
};
};
# spotify ports
networking.firewall = {
allowedTCPPorts = [ 57621 ];
allowedUDPPorts = [ 5353 ];
};

# wake-on-lan
networking.interfaces.enp4s0.wakeOnLan.enable = true;

# nix limits
nix.settings = {
cores = 2;
max-jobs = 2;
};

# filesystems
#fileSystems = {
# "/games/steam-ssd-2" = {

# };
# "/games/wd-black" = {

# };
#};

swapDevices = [
{
device = "/swap";
size = 32 * 1024;
}
];
}
18 changes: 18 additions & 0 deletions nixos/roles/gaming/nvidia-patch.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ pkgs, config, nvidia-patch, ... }:
let
package = config.boot.kernelPackages.nvidiaPackages.stable;
in {
nixpkgs.overlays = [ nvidia-patch.overlays.default ];
hardware.graphics = {
enable = true;
};
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia = {
modesetting.enable = true;
powerManagement.enable = false;
powerManagement.finegrained = false;
open = false;
nvidiaSettings = true;
package = pkgs.nvidia-patch.patch-nvenc (pkgs.nvidia-patch.patch-fbc package);
};
}
106 changes: 50 additions & 56 deletions nixos/roles/gaming/sunshine.nix
Original file line number Diff line number Diff line change
@@ -1,66 +1,60 @@
{ config, lib, pkgs, ... }:
with lib;

# useful links:
# https://docs.lizardbyte.dev/projects/sunshine/en/latest/troubleshooting/linux.html
# https://nixos.wiki/wiki/Steam
let
cfg = config.services.sunshine;
in
{
options = {

services.sunshine = {
enable = mkEnableOption (mdDoc "Sunshine");
};
gamescope-sh = pkgs.writeShellScriptBin "gs.sh" ''
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[@]}"
'';
in {
services.sunshine = {
enable = true;
autoStart = true;
capSysAdmin = true; # only needed for Wayland -- omit this when using with Xorg
openFirewall = true;
};

config = mkIf config.services.sunshine.enable {

boot = { kernelModules = [ "uinput" ]; };
services = {
udev.extraRules = ''
KERNEL=="uinput", GROUP="input", MODE="0660" OPTIONS+="static_node=uinput"
'';
};

security.wrappers.sunshine = {
owner = "root";
group = "root";
capabilities = "cap_sys_admin+p";
source = "${pkgs.sunshine}/bin/sunshine";
};

systemd.user.services.sunshine = {
description = "sunshine";
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${config.security.wrapperDir}/sunshine";
};
};

services.avahi = {
# autologin gamescope
programs = {
gamescope = {
enable = true;
reflector = true;
nssmdns = true;
publish = {
enable = true;
addresses = true;
userServices = true;
workstation = true;
};
capSysNice = true;
};

networking.firewall = {
allowedTCPPorts = [
47984
47989
48010
];
allowedUDPPorts = [
47998
47999
48000
48002
48010
];
steam = {
enable = true;
gamescopeSession.enable = true;
};
};
hardware.xone.enable = true; # support for the xbox controller USB dongle
services.getty.autologinUser = "heywoodlh";
environment = {
systemPackages = pkgs.mangohud;
loginShellInit = ''
[[ "$(tty)" = "/dev/tty1" ]] && ${gamescope-sh}/bin/gs.sh
'';
};
}

0 comments on commit 23ad209

Please sign in to comment.