- Nix 88.6%
- Shell 11.4%
|
|
||
|---|---|---|
| modules | ||
| users | ||
| .gitignore | ||
| configuration.nix | ||
| fix-nix.sh | ||
| flake.lock | ||
| flake.nix | ||
| hardware-configuration.nix | ||
| LICENSE | ||
| nixos-switch.log | ||
| README.md | ||
| update-system.sh | ||
NixOS System Configuration
This repository contains the declarative NixOS flake configuration for the host roadwarrior. The configuration targets a Lenovo Legion 5 laptop with AMD CPU architecture and hybrid AMD/NVIDIA graphics. It provides a Wayland-based KDE Plasma 6 desktop environment.
Repository Structure
nixos-roadwarrior/
├── flake.nix # Flake entry point, inputs, and system outputs
├── flake.lock # Pinned revisions for nixpkgs and nixos-hardware
├── configuration.nix # Central system aggregator and package definitions
├── hardware-configuration.nix # Hardware scan results, file systems, and boot modules
├── update-system.sh # Deployment script for git sync, formatting, and rebuilds
├── fix-nix.sh # Recovery script to stop stuck transient switch units
├── modules/ # Modular functional configurations
│ ├── apps-chromium.nix # Chromium packaging forced to AMD EGL drivers
│ ├── apps-steam.nix # Steam client, firewall ports, and hardware rules
│ ├── core-locale.nix # Timezone and locale definitions
│ ├── core-nix-settings.nix # Flakes, garbage collection, and bootloader settings
│ ├── core-utilities.nix # Diagnostic, network, and file management CLI tools
│ ├── desktop-kde.nix # SDDM, KDE Plasma 6, and PipeWire sound services
│ ├── hardware-bluetooth.nix # Bluetooth hardware activation
│ ├── hardware-legion5.nix # Lenovo conservation mode, lid actions, and power rules
│ ├── hardware-nvidia.nix # NVIDIA PRIME offload and power management settings
│ ├── services-network.nix # NetworkManager, hostname, and firewall rules
│ ├── services-tailscale.nix # Tailscale daemon pointed to custom Headscale server
│ └── services-yubikey.nix # Smartcard daemon, PAM U2F, and removal lock rules
└── users/ # User environment and application profiles
└── spatoa.nix # Primary user profile, desktop tools, and credentials
How to Use as a Template for Other Hosts
To adapt this configuration for a new machine, follow these steps:
- Generate Target Hardware Settings
Generate the specific hardware declarations on the target machine:
nixos-generate-config --show-hardware-config > hardware-configuration.nix
Commit this file or move it to a dedicated host directory.
- Define the Host in
flake.nixAdd a new entry underoutputs.nixosConfigurationswith the target host name:
nixosConfigurations.<new-hostname> = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./hardware-configuration.nix
./configuration.nix
# Replace with target-specific nixos-hardware profiles:
# nixos-hardware.nixosModules.<target-hardware>
];
};
- Adjust Hardware Modules
- Review
configuration.niximports. - If the host does not use NVIDIA hybrid graphics, remove
./modules/hardware-nvidia.nix. - If the host is not a Lenovo Legion laptop, remove
./modules/hardware-legion5.nixand./modules/apps-chromium.nix. - If using NVIDIA PRIME on another machine, update
amdgpuBusIdandnvidiaBusIdinmodules/hardware-nvidia.nixto matchlspcivalues.
- Adjust System Settings
- Change
networking.hostNameinmodules/services-network.nix. - Update or add user declarations in
users/and import them inconfiguration.nix. - Modify the Headscale coordination URL in
modules/services-tailscale.nixif necessary.
System Management and Deployment
Rebuilding Manually
Apply the flake configuration directly using nixos-rebuild:
sudo nixos-rebuild switch --flake .#roadwarrior
Automated Updates
The included update-system.sh script automates synchronization, formatting, and rebuilds:
./update-system.sh
This script performs the following tasks:
- Pulls updates with
--rebase --autostashfrom the remote repository. - Updates
flake.lockwithnix flake update. - Formats files with Alejandra (
nix fmt). - Commits changes with generation tracking if files change.
- Runs
nixos-rebuild switchand pushes the commit on success.
Service Recovery
If nixos-rebuild hangs during activation, run the recovery script as root:
sudo ./fix-nix.sh
This stops nixos-rebuild-switch-to-configuration.service, terminates lingering rebuild processes, removes transient unit files, and reloads the systemd daemon.
License
This configuration is licensed under the Apache License, Version 2.0.