- NixOS flake config for atlas/server/laptop - Module categories and patterns - Boot, desktop, gaming, dev tooling setup
9.9 KiB
9.9 KiB
NixOS Repo Notes (atlas/server/laptop)
This document summarizes the current NixOS configuration repo layout, patterns, and
modules as implemented in flake.nix, hosts/**/configuration.nix, and modules/**.nix.
Setup Details (What This Config Builds)
- Flake-based multi-host NixOS:
atlas(desktop),laptop(desktop no gaming),server(headless). Seeflake.nixandhosts/README.md. - Channel:
nixos-unstableviainputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";inflake.nix. - Kernel: CachyOS kernel via
nix-cachyos-kerneloverlay added inflake.nixmodules list.- Desktop uses
pkgs.cachyosKernels.linuxPackages-cachyos-latest-x86_64-v3inmodules/core/boot.nix. - Server uses
pkgs.cachyosKernels.linuxPackages-cachyos-serverinmodules/core/boot_server.nix.
- Desktop uses
- Bootloader: Limine with Secure Boot enabled.
boot.loader.limine.enable = true;boot.loader.limine.secureBoot.enable = true;- Wallpaper set to
wallpaper/nix.png.
- Disk encryption (atlas hardware config currently checked in):
- Root: LUKS2
cryptrootmapped to/dev/mapper/cryptrootwith XFS (hosts/atlas/hardware-configuration.nix). - Swap: LUKS2
cryptswapwith keyfile at/var/lib/secrets/swap.keyincluded in initrd. boot.resumeDevice = "/dev/mapper/cryptswap";inmodules/core/boot.nix.
- Root: LUKS2
- Boot UX and kernel params:
- Plymouth enabled (
nixos-bgrt) andquiet/splash/logleveltuned inmodules/core/boot.nix. boot.initrd.systemd.enable = true;.
- Plymouth enabled (
- Scheduler tuning:
services.scx.enable = true; services.scx.scheduler = "scx_lavd";inmodules/core/boot.nix(andmodules/core/boot_server.nix). - Nix settings:
nix-command+flakesenabled inmodules/core/system.nix.- Unfree allowed:
nixpkgs.config.allowUnfree = true;. - Auto upgrade weekly + GC daily (delete older than 10d) in
modules/core/system.nix. system.stateVersion = "26.05";.
- Networking defaults (core module):
networking.networkmanager.enable = true;services.openssh.enable = true;services.tailscale.enable = true;networking.hostName = "nix";(see “Notable Repo Quirks” below).
- Locale:
- Timezone
Europe/Berlin - Default locale
en_US.UTF-8with manyde_DE.UTF-8LC_*overrides - Console keymap
de-latin1-nodeadkeys
- Timezone
- Desktop stack (atlas/laptop):
- Display manager:
lyviaservices.displayManager.ly.enable = true; - Session:
services.displayManager.defaultSession = "niri"; - WM/Compositor:
programs.niri.enable = true;(modules/desktop/niri.nix) - XDG portals: enabled with GTK portal + polkit agent user service
- Display manager:
- Audio: PipeWire + WirePlumber, Bluetooth enabled; Pulseaudio disabled.
- Flatpak: enabled and adds Flathub remote during activation.
- Gaming (atlas):
- Steam with firewall openings and Proton GE.
- GameMode with sysctl tuning and
gamescope. - Wine staging + udev rules for game devices.
- Dev tooling:
- Docker enabled with weekly auto prune.
direnv+nix-direnvenabled.- Large CLI/dev package set including
nixd,nil,nixfmt,claude-code, andopencode.
Repository Structure and Import Graph
- Host entrypoints are under
hosts/<hostname>/configuration.nix:hosts/atlas/configuration.niximports:./hardware-configuration.nix../../modules/core../../modules/hardware../../modules/desktop../../modules/services../../modules/dev../../modules/gaming
hosts/laptop/configuration.niximports:- core/hardware/desktop/dev plus a subset of services modules
hosts/server/configuration.niximports:- specific core/hardware modules +
../../modules/dev+../../modules/services/maintenance.nix - enables
services.openssh.enable = true;explicitly (core also enables it)
- specific core/hardware modules +
Flake Outputs and Host Construction
flake.nix defines:
specialArgs = { inherit inputs username; };so modules can reference:usernamefor user paths (e.g.users.users.${username};MusicFolder = "/home/${username}/Music").inputsfor flake packages (e.g. Zen browser, Noctalia shell, Opencode).
- A helper
mkHost hostname = nixpkgs.lib.nixosSystem { ... }that loads:./hosts/${hostname}/configuration.nix- an inline module setting
nixpkgs.overlays = [ inputs.nix-cachyos-kernel.overlays.pinned ];
nixConfigbinary caches:nix-communityCachixattic.xuyh0120.win/lantian
Module Categories
modules/default.nix aggregates:
modules/core/default.nixmodules/hardware/default.nixmodules/desktop/default.nixmodules/services/default.nixmodules/dev/default.nixmodules/gaming/default.nix
Each category default.nix is “imports only” style.
Configuration Patterns Used
- Module function signature:
- Most modules follow
{ config, pkgs, lib, ... }:plusinputsand/orusernamewhen needed.
- Most modules follow
- Centralized username:
flake.nixsetsusername = "pinj";and passes it viaspecialArgs.
- Accessing packages from flake inputs:
- Pattern used in
modules/desktop/apps.nixandmodules/dev/tools.nix:inputs.<name>.packages.${pkgs.stdenv.hostPlatform.system}.default
- Pattern used in
- Overlays:
- Global CachyOS kernel overlay is injected from
flake.nix. - Dev category also adds a local overlay:
modules/dev/default.nixsetsnixpkgs.overlays = [ (import ../../overlays/firebase-tools.nix) ];overlays/firebase-tools.nixforcesfirebase-toolsto usenodejs_22when available.
- Global CachyOS kernel overlay is injected from
- System packages as the main mechanism:
- Many features are enabled by adding to
environment.systemPackagesin the relevant module.
- Many features are enabled by adding to
- Host-specific composition:
- “Desktop features” are composed by importing modules; server imports a smaller subset.
Modules Used (By Category)
Core (modules/core/*)
modules/core/boot.nix- Limine boot + Secure Boot, kernel selection, Plymouth, kernel params
- scx scheduler configuration
modules/core/boot_server.nix- Same structure as
boot.nixbut useslinuxPackages-cachyos-server
- Same structure as
modules/core/system.nix- Nix flakes enablement, auto upgrade, GC, allowUnfree,
system.stateVersion
- Nix flakes enablement, auto upgrade, GC, allowUnfree,
modules/core/networking.nix- NetworkManager, OpenSSH, Tailscale, default hostname
modules/core/users.nix- Creates
users.users.${username}with Fish shell and group memberships - Enables Fish and Zsh
- Creates
modules/core/localization.nix- Timezone/locale and console keymap
Hardware (modules/hardware/*)
modules/hardware/storage.nix- Mount points for several ext4 SSDs under
/mnt/*withnofailand GVFS visibility - Weekly fstrim
- zram swap enabled (
memoryPercent = 100,algorithm = "zstd")
- Mount points for several ext4 SSDs under
modules/hardware/audio.nix- PipeWire + WirePlumber config, 32-bit ALSA support, Bluetooth enabled
- Adds audio utilities (
pavucontrol,pwvucontrol,playerctl)
modules/hardware/gpu-amd.nix- AMD graphics stack, 32-bit support, VA-API/VDPAU helpers, ROCm ICD
- CoreCtrl + AMD overdrive
modules/hardware/power.nix- power-profiles-daemon + CPU governor
Desktop (modules/desktop/*)
modules/desktop/niri.nix- Enables X server,
lydisplay manager, default sessionniri, XKB layout
- Enables X server,
modules/desktop/portals.nix- XDG portal (GTK), polkit enabled + user
polkit-gnome-agentsystemd service - Wayland-related env vars and utilities
- XDG portal (GTK), polkit enabled + user
modules/desktop/theming.nix- Font packages + fontconfig defaults, gtk/qt theming utilities
modules/desktop/apps.nix- GUI app set
- Installs Zen browser via flake input
- Installs Noctalia shell via flake input
- Enables Flatpak + adds Flathub remote in activation script
- Enables GNOME keyring,
programs.yazi, andprograms.firefox
Services (modules/services/*)
modules/services/avahi.nix- Avahi mDNS publishing + firewall openings
modules/services/printing.nix- CUPS printing
modules/services/maintenance.nixpsd,fwupd,earlyoom,plocateperiodic indexing
modules/services/navidrome.nix- Local-only Navidrome on
127.0.0.1:4533withMusicFolder=/home/${username}/Music - Ensures
~/Musicexists via tmpfiles
- Local-only Navidrome on
Development (modules/dev/*)
modules/dev/docker.nix- Docker enabled + weekly auto prune; includes
docker-composeandlazydocker
- Docker enabled + weekly auto prune; includes
modules/dev/shell.nix- Fish prompt and shell init (Ghostty integration if present), lots of aliases/abbrs
- Fish plugins and CLI QoL tools
modules/dev/tools.nix- Toolchains and CLIs (node/python/rustup, compilers, nix tooling, cloud CLIs, AI tools)
- Installs Opencode via flake input
Gaming (modules/gaming/*)
modules/gaming/steam.nix- Steam enabled, firewall exceptions, Proton GE, steam hardware udev rules
modules/gaming/gamemode.nix- GameMode enabled with renice + AMD perf-level config
- Sysctl tuning for gaming workloads
- Includes
gamemodeandgamescope
modules/gaming/wine.nix- Wine staging + helpers; controller udev rules
Operational Commands (Repo-Local)
- Evaluate and validate:
nix flake check
- Build without activating:
sudo nixos-rebuild dry-build --flake .#atlassudo nixos-rebuild dry-build --flake .#laptopsudo nixos-rebuild dry-build --flake .#server
- Activate (on target machine):
sudo nixos-rebuild switch --flake .#atlas(or#laptop,#server)
- Format:
nixfmt **/*.nix
Notable Repo Quirks / Potential Follow-Ups
modules/core/networking.nixsetsnetworking.hostName = "nix";which will apply to all hosts unless overridden elsewhere (host configs currently comment about setting hostname).scripts/setup-secureboot.shandscripts/install-fde.shreference#nixosin their example commands, butflake.nixdefines#atlas,#server, and#laptop.modules/core/boot_server.nixfile header comment saysmodules/core/boot.nix(cosmetic).hosts/server/hardware-configuration.nixandhosts/laptop/hardware-configuration.nixare identical tohosts/atlas/hardware-configuration.nixin this repo snapshot (likely placeholders).