Skip to content

Instantly share code, notes, and snippets.

@rstacruz
Last active May 7, 2026 22:27
Show Gist options
  • Select an option

  • Save rstacruz/4937120a4c25d418156d0dfa9710fe8c to your computer and use it in GitHub Desktop.

Select an option

Save rstacruz/4937120a4c25d418156d0dfa9710fe8c to your computer and use it in GitHub Desktop.
NixOS config: Extract modules/gaming.nix plan

Extract modules/gaming.nix from shared config in alphanaut and misamino

Context

Both hosts/alphanaut/configuration.nix and hosts/misamino/configuration.nix contain ~40 lines of identical gaming-related configuration (gamemode, steam, sunshine, udev/uinput rules, 32-bit graphics). Extracting this into a shared module eliminates duplication and makes the gaming stack reusable.

Minimal host is unaffected — it has no gaming configuration.

Files

  • New: modules/gaming.nix
  • Edit: hosts/alphanaut/configuration.nix
  • Edit: hosts/misamino/configuration.nix

Plan

1. Create modules/gaming.nix

{ pkgs, ... }:

{
  # Feral GameMode
  programs.gamemode.enable = true;

  # Steam - post-setup: login, configure library folder
  # MangoHud: use `mangohud %command%` in Steam game launch options
  programs.steam = {
    enable = true;
    remotePlay.openFirewall = true;
    localNetworkGameTransfers.openFirewall = true;
    package = pkgs.steam.override {
      extraPkgs = pkgs': with pkgs'; [ mangohud ];
    };
  };

  # Sunshine - screen streaming
  # https://127.0.0.1:47990 (ignore https warning)
  # Default: admin / password
  services.sunshine = {
    enable = true;
    autoStart = true;
    capSysAdmin = true; # Required for Wayland/KMS (screen capture)
    openFirewall = true;
  };

  # For Sunshine: https://myme.no/posts/2025-12-11-hifi-sunshine-on-nixos.html
  # Host requirement: add "input" and "uinput" to users.users.rsc.extraGroups.
  services.udev.extraRules = ''
    KERNEL=="uinput", MODE="0660", GROUP="uinput", SYMLINK+="uinput"
  '';

  hardware.uinput.enable = true;

  # Enable OpenGL 32-bit support (Steam, Wine, Proton)
  # Host note: misamino adds extraPackages = [ intel-media-driver ] in its host config.
  hardware.graphics = {
    enable = true;
    enable32Bit = true;
  };
}

Note: Fixes typo ignorignore in the Sunshine comment.

2. Modify hosts/alphanaut/configuration.nix

  1. Add ../../modules/gaming.nix to the imports list, at the top (below existing imports).
  2. Remove the following blocks:
    • programs.gamemode.enable = true;
    • programs.steam = { ... };
    • services.sunshine = { ... };
    • services.udev.extraRules block
    • hardware.uinput.enable = true;
    • hardware.graphics = { enable = true; enable32Bit = true; };

Host-specific note: users.users.rsc.extraGroups still needs "input" and "uinput" — documented in gaming.nix comments.

3. Modify hosts/misamino/configuration.nix

  1. Add ../../modules/gaming.nix to the imports list, at the top (below existing imports).

  2. Remove the same blocks as alphanaut.

  3. Replace the hardware.graphics block with only the host-specific extraPackages:

    hardware.graphics.extraPackages = with pkgs; [
      intel-media-driver
    ];

    NixOS module system merges attrsets, so enable/enable32Bit from gaming.nix and extraPackages from the host config compose correctly.

  4. Remove port 47990 from networking.firewall.allowedTCPPorts — it is redundant since services.sunshine.openFirewall = true handles it.

Host-specific note: users.users.rsc.extraGroups still needs "input" and "uinput" — documented in gaming.nix comments.

Verification

  1. Run nix flake check to catch syntax errors.
  2. Run nixos-rebuild dry-build --flake .#misamino to verify misamino evaluates.
  3. Run nixos-rebuild dry-build --flake .#alphanaut to verify alphanaut evaluates.

Risks and notes

  • Rollback: If evaluation breaks, both hosts are affected. Test one host's dry-build before committing both.
  • Group dependency: The "input" and "uinput" entries in users.users.rsc.extraGroups are required by Sunshine/uinput. Documented in gaming.nix comments; remains in host configs.
  • Future: If a non-gaming graphical host is added later, hardware.graphics base could move to a general workstation module.

Readiness

READY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment