3.6 KiB
3.6 KiB
AGENTS.md - NixOS Configuration Repository
This file provides guidance for AI coding assistants working on this NixOS configuration.
Repository Overview
This is a NixOS system configuration for a desktop named "atlas". It uses flakes, modular organization, and includes customizations for gaming, development, and daily desktop use.
Build/Validation Commands
# Validate Nix syntax and build configuration
nix flake check
# Build the configuration (dry-run, doesn't activate)
nixos-rebuild dry-build --flake .
# Format all .nix files with nixfmt
nixfmt **/*.nix
# Check for common issues
nixos-rebuild dry-activate --flake .
Code Style Guidelines
File Organization
- Entry point:
configuration.nix - Flake definition:
flake.nix - Modular structure under
modules/organized by category:core/- Boot, system, networking, users, localizationhardware/- GPU, audio, storage, power managementdesktop/- Window manager, apps, theming, portalsservices/- System services (avahi, printing, navidrome)dev/- Development tools, docker, shellsgaming/- Steam, wine, gamemode
Module Pattern
Each module follows this structure:
# modules/<category>/<name>.nix
# Brief description of what this module configures
{
config,
pkgs,
lib,
inputs, # Only if using flake inputs
username, # Custom arg passed from flake
...
}:
{
# Configuration options here
}
Imports Pattern
default.nix files should only contain imports:
# modules/<category>/default.nix
{
imports = [
./boot.nix
./system.nix
];
}
Formatting Rules
- Use 2-space indentation
- No tabs
- Keep lines under 100 characters when possible
- Add blank lines between logical sections
- Use descriptive comments with
# Descriptionformat
Naming Conventions
- Module files: descriptive lowercase with hyphens (e.g.,
gpu-amd.nix) - Use
usernamevariable from flake for user-specific paths - Use
lib.mkIffor conditional configuration - Use
lib.mkDefaultfor values that can be overridden
Input Handling
- Pass
inputsfrom flake when accessing external packages - Access input packages via:
inputs.<name>.packages.${pkgs.stdenv.hostPlatform.system}.default - Use
pkgs.stdenv.hostPlatform.systemfor system-specific packages
Special Files
hardware-configuration.nix- Generated by nixos-generate-config, DO NOT EDIT- Scripts in
scripts/are bash installers (not part of NixOS config) - Overlays contain patched Python scripts
Security Notes
- Never commit secrets, API keys, or tokens
- Sensitive files are in
.gitignore - Use proper LUKS encryption for swap and root partitions
- Secure Boot is enabled with custom Limine patches
Common Tasks
Adding a New Module
- Create file in appropriate
modules/<category>/subdirectory - Add to the category's
default.niximports - Follow existing module structure and formatting
- Add brief header comment describing purpose
Adding a Package
- System packages: add to
environment.systemPackagesin appropriate module - User packages: prefer adding to system packages for shared use
- Flake packages: access via inputs with proper system attribute
Testing Changes
# Before committing, always verify syntax
nix flake check
# Build to catch evaluation errors
nixos-rebuild dry-build --flake .
Dependencies
External flake inputs:
nixpkgs- Main NixOS packages (nixos-unstable)noctalia- Desktop shellnix-cachyos-kernel- CachyOS kernel with optimizationszen-browser- Zen browseropencode- AI coding assistant