- Update NAMESPACE.md: filesystem.device and swapSize defaults now null - Update README.md: add 'Using Athenix as a Library' section with lib.mkFleet - Update copilot-instructions.md: reflect new directory structure and defaults - Update EXTERNAL_MODULES.md: correct paths from variants/ and glue/ to hw/ and fleet/ - Update PROXMOX_LXC.md: update hardware type path reference
9.2 KiB
9.2 KiB
GitHub Copilot Instructions for Athenix
This repository manages NixOS configurations for the UGA Innovation Factory's fleet of devices using Nix flakes and a custom configuration system.
Repository: https://git.factory.uga.edu/UGA-Innovation-Factory/athenix.git
Repository Overview
This is a NixOS system configuration repository that uses:
- Nix flakes for dependency management and reproducible builds
- Custom namespace (
athenix.*) 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 definitionshw/: Hardware type modules (desktop, laptop, surface, lxc, wsl, etc.)fleet/: Fleet generation logic and common system configurationsw/: Software configurations by system typeinstaller/: Build artifact generation (ISO, LXC, etc.)templates/: Templates for external configurations
Naming Conventions
- Module options: Use
athenix.*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 (athenix)
All Innovation Factory-specific options MUST use the athenix namespace:
Host Options (athenix.host.*)
athenix.host = {
filesystem.device = "/dev/nvme0n1"; # Boot disk (default: null)
filesystem.swapSize = "32G"; # Swap size (default: null)
buildMethods = [ "installer-iso" ]; # Artifact types (defined in sw/gc.nix)
useHostPrefix = true; # Hostname prefix behavior
wsl.user = "username"; # WSL default user
};
useHostPrefix = true; # Hostname prefix behavior
wsl.user = "username"; # WSL default user
};
Software Options (athenix.sw.*)
athenix.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 (athenix.users.*)
athenix.users = {
accounts = { ... }; # User definitions
enabledUsers = [ "root" "engr-ugaif" ]; # Enabled users
};
athenix.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 underathenix.users.accounts - Enable user in
inventory.nixviaathenix.users.username.enable = trueor useathenix.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
athenix.sw.extraPackagesininventory.nix - Test:
nix flake check
Creating External Modules
- Use templates:
nix flake init -t git+https://git.factory.uga.edu/UGA-Innovation-Factory/athenix.git#{user|system} - User modules: Provide
user.nix(required) andnixos.nix(optional) - System modules: Provide
default.nixthat accepts{ inputs, ... } - Reference in
inventory.nixorusers.nixusingbuiltins.fetchGit
Using Athenix as a Library
External flakes can use Athenix's fleet generator:
outputs = { athenix, ... }: {
nixosConfigurations = athenix.lib.mkFleet {
fleet = import ./custom-inventory.nix;
hwTypes = import ./custom-hardware.nix;
};
};
Important Constraints
What NOT to Do
- Never use options outside the
athenixnamespace 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
athenix.*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.external = builtins.fetchGit {
url = "https://github.com/username/dotfiles";
rev = "abc123..."; # Pin to specific commit
};
# The external user.nix file contains BOTH user account options
# (athenix.users.myuser) AND home-manager configuration
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
user.nix(user options AND 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 athenix.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
athenix.*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