$ show km-clay/nixos-wizard
nixos-wizard is a terminal-based NixOS installer that provides a text-based UI for guided system installation. It follows a modular architecture with an event loop managing UI state, Page and ConfigWidget traits for UI components, and an Installer struct as central data store. The application guides users through configuration steps including disk partitioning, user creation, package selection, and system settings, then generates NixOS configuration files (configuration.nix and disko config) for installation. Key features include interactive disk partitioning powered by Disko, real-time package search with fuzzy matching, and immediate validation of generated configurations.
The LLM identified 5 files worth highlighting for reuse:
The PackageManager implements efficient package selection with real-time fuzzy search and caching. It maintains original package order, uses BTreeMap for O(log n) lookups, and caches filtered results to avoid expensive recomputation on repeated searches. This self-contained component demonstrates non-obvious skill in optimizing UI responsiveness for large package lists and could be extracted for use in any package selection interface.
The OptimizedStrList provides a simple, efficient list widget that works with pre-sorted data and avoids expensive operations. It manages focus state and rendering with minimal overhead, making it suitable for performance-sensitive UI contexts. This component is isolated, self-contained, and demonstrates thoughtful optimization for list-based UI elements.
The bytes_disko_cfg and parse_sectors functions provide robust conversion between human-readable size strings and sector counts for disk partitioning. They handle various formats (bytes, KB, MB, GB, TB, percentages) with proper alignment considerations for Disko compatibility. These utility functions solve a recurring data problem in storage management and could be extracted for use in any disk partitioning tool.
The nixstr, fmt_nix, and highlight_nix functions provide reusable utilities for Nix syntax generation and code formatting. nixstr handles proper string escaping for Nix, fmt_nix uses nixfmt for code formatting, and highlight_nix adds syntax highlighting with bat. These functions solve the common problem of generating valid, readable Nix code and demonstrate non-obvious skill in integrating with Nix ecosystem tools.
The macros in this file provide reusable patterns for command creation, Nix attribute set generation, list syntax, and UI navigation. The command! macro simplifies process creation, attrset! and merge_attrs! enable type-safe Nix configuration generation, and UI navigation macros provide consistent keyboard shortcuts across the TUI. These macros demonstrate excellent DRY principles and could be valuable in any Rust project dealing with Nix or terminal interfaces.