Skip to content

feat: add support for additional nix build options, refactor and documentation - #4

Open
yeoldegrove wants to merge 3 commits into
nilla-nix:mainfrom
yeoldegrove:feat/additional-options
Open

feat: add support for additional nix build options, refactor and documentation#4
yeoldegrove wants to merge 3 commits into
nilla-nix:mainfrom
yeoldegrove:feat/additional-options

Conversation

@yeoldegrove

@yeoldegrove yeoldegrove commented Jan 8, 2026

Copy link
Copy Markdown

This PR adds support for passing additional nix build options to enable e.g. remote builders in nilla-home, along with comprehensive code refactoring to improve maintainability and reduce duplication. It also adds an initial README.md.

Features

Remote Build Support

  • Support for passing additional nix build options via -- separator
  • Enables remote builds using --builders flag
  • Informative logging indicating where build operations occur (locally or remotely)
# Build with remote builders
nilla home build <specifier> -- --builders "ssh://remote x86_64-linux"

# Build and switch with remote builders
nilla home switch <specifier> -- --builders "ssh://remote x86_64-linux"

Improved Logging

  • Clear indication of operation location (local vs remote)
  • Build operations show where the build happens
🍦 Nilla  INFO  Building home <specifier> locally
🍦 Nilla  INFO  Building home <specifier> with builders: ssh://remote x86_64-linux

Code Improvements

Refactoring

  • Extracted common home command logic into a shared commands/common.rs module
  • Created util/args.rs module with constants and utilities for argument parsing
  • Reduced code duplication across build and switch commands
  • Centralized project resolution, attribute formatting, and logging logic

Technical Details

  • Uses Clap's trailing_var_arg and allow_hyphen_values for flexible argument passthrough
  • Constants for --builders flag to reduce duplication
  • Utility functions for extracting builder information from command-line arguments
  • Updated BuildOpts to accept and pass through extra arguments to nix build

Documentation

  • Added comprehensive README.md with installation instructions
  • Documents integration with nilla-cli as an external subcommand
  • Includes usage examples for remote builds
  • Covers installation methods: with Nilla, without Flakes, with Flakes, and run with Flakes

Add a generic passthrough mechanism to allow passing additional
nix build options through nilla-home commands. This enables
remote builders (--builders) and any other nix build options.

Changes:
- Add extra_nix_build_args field to BuildArgs and SwitchArgs
- Add trailing_var_arg support to capture arguments after --
- Add args utility module with functions to extract builder information
- Update BuildOpts to accept and pass through extra arguments
- Update build and switch commands to use passthrough and log build location
- Update help text to document the passthrough mechanism

Usage example:
  nilla home build -- --builders "ssh://remote x86_64-linux"
  nilla home switch -- --builders "ssh://remote x86_64-linux"
Extract duplicated logic from build and switch commands into
a shared common module to improve maintainability and reduce
code duplication.

Changes:
- Create commands/common.rs with shared functions:
  - get_nilla_nix_path(): Resolve project and get nilla.nix path with entry
  - format_home_attribute(): Format home attribute path
  - log_build_operation(): Log build operations with location info
- Refactor both command implementations to use shared functions
- Reduce code duplication and improve maintainability
- Improve code readability and consistency
Add comprehensive README documenting:
- Integration with Nilla CLI via external subcommand mechanism
- Installation methods (with Nilla, without Flakes, with Flakes)
- Usage examples with nix build option passthrough
- Command examples for build and switch operations
- Specifier format documentation for Home Manager configurations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant