Skip to content

Conversation

@jacobmichels
Copy link

Description

I want to leverage nix-installer as a rust library. I tried building the library without any features enabled and got compilation errors due due to usage of clap without the cli feature enabled (which I presume brings in clap).

This PR simply adds some checks to ensure the cli feature is enabled before calling anything from clap. Only two files needed to be modified before the code compiled without any features enabled.

Example error

error: cannot find attribute `clap` in this scope
   --> /Users/<username>/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nix-installer-0.23.0/src/planner/mod.rs:180:42
    |
180 |     #[cfg_attr(not(target_os = "linux"), clap(hide = true))]
Checklist
  • Formatted with cargo fmt
  • Built with nix build
  • Ran flake checks with nix flake check
  • Added or updated relevant tests (leave unchecked if not applicable)
  • Added or updated relevant documentation (leave unchecked if not applicable)
  • Linked to related issues (leave unchecked if not applicable)
Validating with install.determinate.systems

If a maintainer has added the upload to s3 label to this PR, it will become available for installation via install.determinate.systems:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/pr/$PR_NUMBER | sh -s -- install

@jacobmichels jacobmichels marked this pull request as draft July 21, 2025 14:01
@jacobmichels jacobmichels marked this pull request as ready for review July 21, 2025 14:05
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.

2 participants