1
0
Fork 0
My current NixOS configurations
  • Nix 88.6%
  • Shell 11.4%
Find a file
2026-10-13 15:05:41 +11:00
modules Deploy roadwarrior - Generation 133 (Predicted) 2026-10-13 15:04:54 +11:00
users Deploy roadwarrior - Generation 129 (Predicted) 2026-10-07 22:27:30 +11:00
.gitignore Initial commit 2026-07-03 07:13:31 +00:00
configuration.nix Deploy roadwarrior - Generation 124 (Predicted) 2026-10-06 21:07:21 +11:00
fix-nix.sh Deploy roadwarrior - Generation 99 2026-08-10 19:08:21 +10:00
flake.lock Deploy roadwarrior - Generation 132 (Predicted) 2026-10-13 12:48:28 +11:00
flake.nix Deploy roadwarrior - Generation 120 (Predicted) 2026-10-04 00:00:22 +10:00
hardware-configuration.nix Deploy roadwarrior - Generation 113 (Predicted) 2026-10-03 13:58:53 +10:00
LICENSE Initial commit 2026-07-03 07:13:31 +00:00
nixos-switch.log Deploy roadwarrior - Generation 133 (Predicted) 2026-10-13 15:05:41 +11:00
README.md Deploy roadwarrior - Generation 116 (Predicted) 2026-10-03 15:02:14 +10:00
update-system.sh Deploy roadwarrior - Generation 133 (Predicted) 2026-10-13 12:57:53 +11:00

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:

  1. 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.

  1. Define the Host in flake.nix Add a new entry under outputs.nixosConfigurations with 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>
  ];
};
  1. Adjust Hardware Modules
  • Review configuration.nix imports.
  • 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.nix and ./modules/apps-chromium.nix.
  • If using NVIDIA PRIME on another machine, update amdgpuBusId and nvidiaBusId in modules/hardware-nvidia.nix to match lspci values.
  1. Adjust System Settings
  • Change networking.hostName in modules/services-network.nix.
  • Update or add user declarations in users/ and import them in configuration.nix.
  • Modify the Headscale coordination URL in modules/services-tailscale.nix if 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 --autostash from the remote repository.
  • Updates flake.lock with nix flake update.
  • Formats files with Alejandra (nix fmt).
  • Commits changes with generation tracking if files change.
  • Runs nixos-rebuild switch and 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.