8.5 KiB
8.5 KiB
GitHub Copilot Instructions for nixos-systems
This repository manages NixOS configurations for the UGA Innovation Factory's fleet of devices using Nix flakes and a custom configuration system.
Repository Overview
This is a NixOS system configuration repository that uses:
- Nix flakes for dependency management and reproducible builds
- Custom namespace (
ugaif.*) for all Innovation Factory-specific options - Inventory-based host generation from
inventory.nix - External module support for user and system configurations
- Multiple hardware types: desktops, laptops, Surface tablets, LXC containers, WSL
Code Style and Conventions
Nix Code Style
- Use the repository's formatter:
nix fmt **/*.nix(usesnixfmt-rfc-style) - Follow existing indentation (2 spaces)
- Use descriptive variable names
- Add comments for complex logic, especially in host generation
- Preserve existing comment style and documentation
File Organization
flake.nix: Entry point - inputs and outputs onlyinventory.nix: Fleet definitions - host configurationsusers.nix: User account definitionshosts/: Host generation logic and hardware typessw/: Software configurations organized by system typeinstaller/: Build artifact generation (ISO, LXC, etc.)templates/: Templates for external configurations
Naming Conventions
- Module options: Use
ugaif.*namespace for all custom options - Hostnames:
{type}{number}or{type}-{name}(e.g.,nix-laptop1,nix-surface-alpha) - Hardware types: Prefix with
nix-(e.g.,nix-desktop,nix-laptop) - Software types: Use descriptive names (
desktop,tablet-kiosk,headless)
Custom Namespace (ugaif)
All Innovation Factory-specific options MUST use the ugaif namespace:
Host Options (ugaif.host.*)
ugaif.host = {
filesystem.device = "/dev/sda"; # Boot disk
filesystem.swapSize = "32G"; # Swap size
buildMethods = [ "iso" ]; # Artifact types
useHostPrefix = true; # Hostname prefix behavior
wsl.user = "username"; # WSL default user
};
Software Options (ugaif.sw.*)
ugaif.sw = {
type = "desktop"; # System type
kioskUrl = "https://..."; # Kiosk browser URL
python.enable = true; # Python tools (pixi, uv)
remoteBuild = {
enable = true; # Use remote builders
hosts = [ "nix-builder" ]; # Build servers
};
extraPackages = with pkgs; [ ... ]; # Additional packages
};
User Options (ugaif.users.*)
ugaif.users = {
accounts = { ... }; # User definitions
enabledUsers = [ "root" "engr-ugaif" ]; # Enabled users
};
ugaif.forUser = "username"; # Convenience: enable user + set WSL user
Development Workflow
Testing Changes
- Always run
nix flake checkbefore committing to validate all configurations - Use
nix flake check --show-tracefor detailed error messages - Test specific host builds:
nix build .#nixosConfigurations.{hostname}.config.system.build.toplevel - For local testing:
sudo nixos-rebuild test --flake .
Making Changes
- Minimal modifications: Change only what's necessary
- Preserve existing functionality: Don't break working configurations
- Test before committing: Run
nix flake checkto validate all hosts - Update documentation: Keep README.md and other docs in sync with changes
Common Tasks
Adding a New User
- Edit
users.nixto add user definition underugaif.users.accounts - Enable user in
inventory.nixviaugaif.users.username.enable = trueor useugaif.forUser = "username" - Test:
nix flake check
Adding a New Host
- Edit
inventory.nixto add device(s) under appropriate type - Use
devices = Nfor simple count ordevices = { ... }for custom configs - Test:
nix flake checkand build specific host
Modifying Software Configuration
- Edit appropriate file in
sw/directory based on system type - For system-wide changes: modify
sw/{type}/programs.nix - For specific hosts: use
ugaif.sw.extraPackagesininventory.nix - Test:
nix flake check
Creating External Modules
- Use templates:
nix flake init -t github:UGA-Innovation-Factory/nixos-systems#{user|system} - User modules: Provide
home.nix(required) andnixos.nix(optional) - System modules: Provide
default.nixthat accepts{ inputs, ... } - Reference in
inventory.nixorusers.nixusingbuiltins.fetchGit
Important Constraints
What NOT to Do
- Never use options outside the
ugaifnamespace for Innovation Factory-specific functionality - Never remove or modify working host configurations unless explicitly requested
- Never break existing functionality when adding new features
- Never hardcode values that should be configurable
- Never add global changes that affect all systems without careful consideration
What to ALWAYS Do
- Always run
nix flake checkbefore finalizing changes - Always use the
ugaif.*namespace for custom options - Always preserve existing comment styles and documentation
- Always test that configurations build successfully
- Always consider impact on existing hosts when making changes
- Always use
nix fmt **/*.nixto format code before committing
External Module Integration
This repository supports external configurations via Git repositories:
User Configurations (Dotfiles)
# In users.nix
myuser = {
description = "My Name";
home = builtins.fetchGit {
url = "https://github.com/username/dotfiles";
rev = "abc123..."; # Pin to specific commit
};
};
System Configurations
# In inventory.nix
nix-lxc = {
devices."special" = builtins.fetchGit {
url = "https://github.com/org/server-config";
rev = "abc123...";
};
};
Key Points:
- External modules receive
{ inputs }parameter with flake inputs - User modules must provide
home.nix(home-manager config) - System modules must provide
default.nix(NixOS module) - Always pin to specific commit hash (
rev) for reproducibility
Building and Artifacts
Available Build Commands
# Check all configurations
nix flake check
# Build installer ISO
nix build .#installer-iso-{hostname}
# Build live ISO
nix build .#iso-{hostname}
# Build LXC container
nix build .#lxc-{hostname}
# Build Proxmox template
nix build .#proxmox-{hostname}
# Show all available outputs
nix flake show
Artifact Types
Set via ugaif.host.buildMethods:
"iso"- Installer ISO with auto-install"live-iso"- Live boot ISO without installer"lxc"- LXC container tarball"proxmox"- Proxmox VMA template"ipxe"- iPXE netboot kernel and initrd
Troubleshooting
Common Issues
- Build failures: Run
nix flake check --show-tracefor detailed errors - External modules not loading: Check URL accessibility and module structure
- User not appearing: Ensure user is enabled for that host
- Formatting issues: Run
nix fmt **/*.nixto auto-format
Getting Help
- Review existing documentation:
README.md,USER_CONFIGURATION.md,EXTERNAL_MODULES.md - Check templates in
templates/directory for examples - Examine existing configurations in
inventory.nixandusers.nix
Additional Context
System Types
- desktop: Full GNOME desktop environment
- tablet-kiosk: Surface tablets with Firefox kiosk browser
- stateless-kiosk: Diskless PXE boot kiosks
- headless: Servers and containers without GUI
Hardware Types
- nix-desktop: Desktop workstations
- nix-laptop: Laptops
- nix-surface: Surface Pro tablets
- nix-lxc: LXC containers
- nix-wsl: WSL (Windows Subsystem for Linux)
- nix-ephemeral: Temporary/stateless systems
Key Dependencies
- NixOS 25.11 (nixpkgs)
- home-manager (user environment)
- disko (disk partitioning)
- nixos-hardware (hardware quirks)
- nixos-generators (ISO/LXC builds)
- nixos-wsl (WSL support)
Code Review Checklist
When reviewing or generating code:
- Uses
ugaif.*namespace for custom options - Runs
nix flake checksuccessfully - Follows existing code style and formatting
- Preserves existing functionality
- Updates relevant documentation if needed
- Uses appropriate abstractions (don't repeat logic)
- Considers impact on all system types
- Tests artifact builds if modifying build logic
- Pins external modules to specific commits