Add NixOS dual-configuration setup (dev and gaming profiles)

Co-authored-by: ragusa-it <196988693+ragusa-it@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-01 19:35:39 +00:00
parent cf10576824
commit bf80ac7579
6 changed files with 653 additions and 1 deletions

208
README.md
View File

@@ -1 +1,207 @@
# nixos
# NixOS Dual-Configuration Setup
A NixOS system with **two fully isolated configurations**:
1. **Dev** - Latest stable kernel, web development tooling (Docker, Node.js, direnv)
2. **Gaming** - Zen kernel, Steam, Lutris, performance tools
Both share a common base: MangoWC (Wayland compositor) + Noctalia Shell, AMD RDNA 4 GPU support, and a shared `/home` directory with mutable dotfiles.
## Target Hardware
| Component | Model | Notes |
|-----------|-------|-------|
| CPU | AMD Ryzen 7 5700G | Zen 3, iGPU available |
| GPU | AMD RX 9060 XT | RDNA 4, requires Kernel 6.14+, Mesa 25.0+ |
| Motherboard | MSI B550 Tomahawk | Excellent IOMMU groups |
## Directory Structure
```
nixos-config/
├── flake.nix # Main flake definition
├── flake.lock # Auto-generated after first build
├── hosts/
│ └── <hostname>/
│ └── hardware-configuration.nix # Copy from /etc/nixos/
└── modules/
├── common.nix # Shared configuration
├── dev.nix # Development profile
└── gaming.nix # Gaming profile
```
## Prerequisites
1. NixOS installed (minimal install is fine)
2. Flakes enabled in existing config or via: `nix-shell -p nixFlakes`
3. Know your hostname, username, timezone, and locale
## Quick Setup
### 1. Clone and Prepare
```bash
# Clone this repo to your config directory
git clone <this-repo> ~/nixos-config
cd ~/nixos-config
# Replace the placeholder hardware-configuration.nix with your actual one
cp /etc/nixos/hardware-configuration.nix hosts/<hostname>/
```
### 2. Replace Placeholders
Edit the following files and replace these placeholders:
| Placeholder | Example Value | Files |
|-------------|---------------|-------|
| `<hostname>` | `desktop` | `flake.nix`, `modules/common.nix` |
| `<username>` | `john` | `modules/common.nix`, `modules/dev.nix`, `modules/gaming.nix` |
| `<timezone>` | `America/New_York` | `modules/common.nix` |
| `<locale>` | `en_US.UTF-8` | `modules/common.nix` |
Also rename `hosts/hostname/` to match your actual hostname.
### 3. Stage Files in Git
```bash
cd ~/nixos-config
git add .
```
### 4. Verify Flake
```bash
nix flake check
nix flake show
```
### 5. Build and Switch
```bash
# Build and switch to dev config as main system profile
sudo nixos-rebuild switch --flake .#dev
# Build gaming config as separate boot profile
sudo nixos-rebuild boot --profile-name gaming --flake .#gaming
```
### 6. Reboot and Verify
Boot menu should show:
- `NixOS (dev)` - Default boot
- `NixOS (gaming, zen)` - Gaming profile
## Updating
**IMPORTANT:** Always update both profiles together to avoid kernel/Mesa version drift:
```bash
cd ~/nixos-config
git add .
sudo nixos-rebuild switch --flake .#dev
sudo nixos-rebuild boot --profile-name gaming --flake .#gaming
```
To update flake inputs:
```bash
nix flake update
git add flake.lock
sudo nixos-rebuild switch --flake .#dev
sudo nixos-rebuild boot --profile-name gaming --flake .#gaming
```
## Configuration Summary
| Config | Kernel | Key Features |
|--------|--------|--------------|
| `dev` | Latest | Docker, Node.js, direnv, dev CLI tools |
| `gaming` | Zen | Steam, Lutris, MangoHUD, Gamemode, CoreCtrl |
| **Shared** | - | MangoWC, Noctalia, AMD GPU, PipeWire, Firefox |
## Post-Installation
### Change Password
```bash
passwd
```
### Setup MangoWC
```bash
mkdir -p ~/.config/mango
cp /etc/mango/config.conf ~/.config/mango/config.conf
# Create autostart script
cat > ~/.config/mango/autostart.sh << 'EOF'
#!/bin/bash
qs -c noctalia-shell &
EOF
chmod +x ~/.config/mango/autostart.sh
```
Add to `~/.config/mango/config.conf`:
```
exec-once="~/.config/mango/autostart.sh"
```
### Auto-start MangoWC from TTY
Add to `~/.bash_profile` or `~/.zprofile`:
```bash
if [[ -z $WAYLAND_DISPLAY ]] && [[ $(tty) == /dev/tty1 ]]; then
exec mango
fi
```
## GPU Verification
```bash
# Verify firmware loaded
dmesg | grep -i "amdgpu" | grep -i "firmware"
# Check GPU detected
lspci | grep VGA
# Verify Vulkan
vulkaninfo | head -30
# Check ray tracing support
vulkaninfo | grep VK_KHR_ray_tracing_pipeline
# Verify OpenCL
clinfo | head -20
```
## Troubleshooting
### Flake can't find files
```bash
git add . # Flakes require files to be tracked by git
```
### MangoWC doesn't start
```bash
systemctl status seatd
groups # Ensure user is in 'seat' group
```
### RDNA 4 black screen
```bash
dmesg | grep -i "amdgpu" | grep -i "firmware"
uname -r # Should be 6.14+
```
### Steam doesn't launch
Ensure `hardware.graphics.enable32Bit = true;` in common.nix.
### Games won't launch
```bash
cat /proc/sys/vm/max_map_count # Should be 2147483642 on gaming profile
```
## License
MIT

50
flake.nix Normal file
View File

@@ -0,0 +1,50 @@
{
description = "NixOS - Isolated Gaming & Dev configurations";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
mango = {
url = "github:DreamMaoMao/mango";
inputs.nixpkgs.follows = "nixpkgs";
};
quickshell = {
url = "github:outfoxxed/quickshell";
inputs.nixpkgs.follows = "nixpkgs";
};
noctalia = {
url = "github:noctalia-dev/noctalia-shell";
inputs.nixpkgs.follows = "nixpkgs";
inputs.quickshell.follows = "quickshell";
};
};
outputs = { self, nixpkgs, mango, quickshell, noctalia, ... }@inputs:
let
system = "x86_64-linux";
specialArgs = { inherit inputs system; };
# IMPORTANT: Replace <hostname> with actual hostname
commonModules = [
./hosts/<hostname>/hardware-configuration.nix
./modules/common.nix
mango.nixosModules.mango
];
in {
nixosConfigurations = {
# Development configuration
dev = nixpkgs.lib.nixosSystem {
inherit system specialArgs;
modules = commonModules ++ [ ./modules/dev.nix ];
};
# Gaming configuration
gaming = nixpkgs.lib.nixosSystem {
inherit system specialArgs;
modules = commonModules ++ [ ./modules/gaming.nix ];
};
};
};
}

View File

@@ -0,0 +1,42 @@
# This is a placeholder hardware-configuration.nix file.
#
# IMPORTANT: Replace this file with your actual hardware-configuration.nix
# generated during NixOS installation, typically found at:
# /etc/nixos/hardware-configuration.nix
#
# To generate a new hardware configuration, run:
# sudo nixos-generate-config --show-hardware-config > hardware-configuration.nix
#
# This placeholder will NOT work for actual system builds.
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
# Example boot configuration (replace with your actual hardware)
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
# Example filesystem configuration (replace with your actual mounts)
# fileSystems."/" = {
# device = "/dev/disk/by-uuid/YOUR-ROOT-UUID";
# fsType = "ext4";
# };
#
# fileSystems."/boot" = {
# device = "/dev/disk/by-uuid/YOUR-BOOT-UUID";
# fsType = "vfat";
# };
#
# swapDevices = [
# { device = "/dev/disk/by-uuid/YOUR-SWAP-UUID"; }
# ];
# CPU microcode updates for AMD
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

170
modules/common.nix Normal file
View File

@@ -0,0 +1,170 @@
{ config, pkgs, inputs, system, ... }:
{
# --------------------------------------------------------------------------
# BOOT
# --------------------------------------------------------------------------
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# --------------------------------------------------------------------------
# SYSTEM
# --------------------------------------------------------------------------
# IMPORTANT: Replace with actual values
networking.hostName = "<hostname>";
time.timeZone = "<timezone>";
i18n.defaultLocale = "<locale>";
networking.networkmanager.enable = true;
# --------------------------------------------------------------------------
# AMD GPU - RDNA 4 (RX 9060 XT) + Zen 3 CPU (5700G)
# --------------------------------------------------------------------------
# CRITICAL: RDNA 4 requires navi44 firmware blobs
hardware.enableAllFirmware = true;
# Use the modern amdgpu NixOS module (cleaner than manual initrd config)
hardware.amdgpu.initrd.enable = true;
hardware.graphics = {
enable = true;
enable32Bit = true; # Required for Steam/Wine
extraPackages = with pkgs; [
rocmPackages.clr.icd # OpenCL support for RDNA 4
];
# NOTE: AMDVLK intentionally omitted
# Some games auto-select AMDVLK over RADV, causing performance issues
# RADV (Mesa) is the default and performs better for gaming
};
# RADV is already the default Vulkan driver
# This variable is optional but makes it explicit
environment.variables.AMD_VULKAN_ICD = "RADV";
# --------------------------------------------------------------------------
# CPU - Zen 3 Optimizations (Ryzen 7 5700G)
# --------------------------------------------------------------------------
boot.kernelParams = [
"amd_pstate=active" # Better power/performance scaling on Zen 3
];
# --------------------------------------------------------------------------
# MOTHERBOARD - MSI B550 Tomahawk Sensors
# --------------------------------------------------------------------------
boot.kernelModules = [ "nct6775" ]; # B550 hardware monitoring
# --------------------------------------------------------------------------
# MANGOWC + NOCTALIA
# --------------------------------------------------------------------------
programs.mango.enable = true;
# Required for screen sharing, file dialogs
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
};
# Enable seatd for session management
services.seatd.enable = true;
# --------------------------------------------------------------------------
# USER ACCOUNT
# --------------------------------------------------------------------------
# IMPORTANT: Replace <username> with actual username
users.users.<username> = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" "video" "seat" ];
# Set initial password or use hashedPassword
initialPassword = "changeme";
packages = with pkgs; [
# -- Noctalia Shell --
inputs.quickshell.packages.${system}.default
inputs.noctalia.packages.${system}.default
brightnessctl
cliphist
wlsunset
# -- MangoWC Ecosystem --
foot # Terminal
wmenu # Launcher
wl-clipboard # Clipboard
grim # Screenshot
slurp # Region selection
swaybg # Wallpaper
# -- Applications --
firefox
];
};
# --------------------------------------------------------------------------
# SYSTEM PACKAGES
# --------------------------------------------------------------------------
environment.systemPackages = with pkgs; [
vim
wget
curl
htop
git
unzip
file
# GPU verification tools
clinfo # Verify OpenCL: clinfo
vulkan-tools # Verify Vulkan: vulkaninfo
pciutils # lspci for hardware info
];
# --------------------------------------------------------------------------
# FONTS
# --------------------------------------------------------------------------
fonts.packages = with pkgs; [
# Nerd fonts - syntax changed in NixOS 25.05+
# Old syntax was: (nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
# New syntax is individual packages:
nerd-fonts.jetbrains-mono
# Other fonts
inter
roboto
];
# --------------------------------------------------------------------------
# AUDIO (PipeWire)
# --------------------------------------------------------------------------
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
# Disable PulseAudio (conflicts with PipeWire)
hardware.pulseaudio.enable = false;
# RealtimeKit for PipeWire
security.rtkit.enable = true;
# --------------------------------------------------------------------------
# MISC
# --------------------------------------------------------------------------
# Allow unfree packages (needed for Steam, some drivers)
nixpkgs.config.allowUnfree = true;
# Enable flakes
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# Garbage collection
nix.gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 14d";
};
# IMPORTANT: Set to the NixOS version of your install media
# Check with: nixos-version
# Do NOT change this after initial install
system.stateVersion = "25.05";
}

86
modules/dev.nix Normal file
View File

@@ -0,0 +1,86 @@
{ pkgs, ... }:
{
# Identification tag (shows in boot menu and `nixos-version`)
system.nixos.tags = [ "dev" ];
# --------------------------------------------------------------------------
# KERNEL - Latest stable for RDNA 4 GPU support
# --------------------------------------------------------------------------
# NOTE: LTS kernels often lag behind new GPU support.
# For RDNA 4 (RX 9060 XT), use linuxPackages_latest instead of linuxPackages.
boot.kernelPackages = pkgs.linuxPackages_latest;
# --------------------------------------------------------------------------
# DOCKER
# --------------------------------------------------------------------------
virtualisation.docker = {
enable = true;
autoPrune = {
enable = true;
dates = "weekly";
};
};
# IMPORTANT: Replace <username> with actual username
users.users.<username>.extraGroups = [ "docker" ];
# --------------------------------------------------------------------------
# DEVELOPMENT TOOLS
# --------------------------------------------------------------------------
programs.direnv = {
enable = true;
nix-direnv.enable = true; # Caches nix shells
};
# IMPORTANT: Replace <username> with actual username
users.users.<username>.packages = with pkgs; [
# -- Git --
lazygit
gh # GitHub CLI
# -- Node.js --
nodejs_22
nodePackages.pnpm
nodePackages.yarn
# -- CLI Tools --
httpie # HTTP client
jq # JSON processor
yq # YAML processor
fd # Find alternative
ripgrep # Grep alternative
eza # ls alternative
bat # cat alternative
fzf # Fuzzy finder
zoxide # cd alternative
delta # Git diff viewer
# -- Database Clients --
postgresql # psql client
# redis # Uncomment if needed
# -- Misc --
gnumake
gcc
];
# --------------------------------------------------------------------------
# SERVICES (Optional - uncomment if needed)
# --------------------------------------------------------------------------
# Local PostgreSQL
# services.postgresql = {
# enable = true;
# ensureDatabases = [ "devdb" ];
# ensureUsers = [{
# name = "<username>";
# ensureDBOwnership = true;
# }];
# };
# Local Redis
# services.redis.servers."dev" = {
# enable = true;
# port = 6379;
# };
}

98
modules/gaming.nix Normal file
View File

@@ -0,0 +1,98 @@
{ pkgs, ... }:
{
# Identification tags (shows in boot menu)
system.nixos.tags = [ "gaming" "zen" ];
# --------------------------------------------------------------------------
# KERNEL - Zen for gaming performance
# --------------------------------------------------------------------------
boot.kernelPackages = pkgs.linuxPackages_zen;
# --------------------------------------------------------------------------
# STEAM
# --------------------------------------------------------------------------
programs.steam = {
enable = true;
gamescopeSession.enable = true;
remotePlay.openFirewall = true;
dedicatedServer.openFirewall = true;
};
# --------------------------------------------------------------------------
# GAMEMODE - Auto performance optimizations
# --------------------------------------------------------------------------
programs.gamemode = {
enable = true;
enableRenice = true;
settings = {
general = {
renice = 10;
};
gpu = {
apply_gpu_optimisations = "accept-responsibility";
gpu_device = 0;
amd_performance_level = "high";
};
};
};
# --------------------------------------------------------------------------
# CORECTRL - AMD GPU Control
# --------------------------------------------------------------------------
programs.corectrl = {
enable = true;
gpuOverclock = {
enable = true;
ppfeaturemask = "0xffffffff";
};
};
# IMPORTANT: Replace <username> with actual username
users.users.<username>.extraGroups = [ "corectrl" "gamemode" ];
# --------------------------------------------------------------------------
# GAMING PACKAGES
# --------------------------------------------------------------------------
# IMPORTANT: Replace <username> with actual username
users.users.<username>.packages = with pkgs; [
# -- Performance Overlays --
mangohud # FPS counter, GPU stats
goverlay # MangoHud GUI config
# -- Game Launchers --
lutris # Multi-platform launcher
heroic # Epic/GOG launcher
bottles # Wine prefix manager
# -- Proton/Wine --
protonup-qt # Proton-GE installer
winetricks
protontricks
# -- Utilities --
gamescope # Micro-compositor for gaming
corectrl # AMD GPU control GUI
# -- Optional Game Clients --
# prismlauncher # Minecraft
# retroarch # Emulation
];
# --------------------------------------------------------------------------
# KERNEL PARAMETERS - Gaming optimizations
# --------------------------------------------------------------------------
boot.kernel.sysctl = {
# Reduce swappiness for gaming
"vm.swappiness" = 10;
# Increase max map count (needed for some games)
"vm.max_map_count" = 2147483642;
};
# Additional kernel params for gaming (appends to common.nix params)
boot.kernelParams = [
"amd_pstate=active" # Inherited from common, but explicit for clarity
"mitigations=off" # Optional: Disable CPU mitigations for ~5% perf gain
# Remove this line if security is a concern
];
}