Skip to content

Support pkg removal in variant with -name syntax - #1402

Open
jrray wants to merge 4 commits into
mainfrom
variant-unconstrained-pkg-test
Open

Support pkg removal in variant with -name syntax#1402
jrray wants to merge 4 commits into
mainfrom
variant-unconstrained-pkg-test

Conversation

@jrray

@jrray jrray commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Variants can now remove inherited requests from build.options by prefixing the variant key with '-'. For example, { "-foo": "" } drops a package request and { "-debug": "" } drops a var request for that variant while leaving other variants unchanged.

This also keeps variant-specific additions working as before, including unconstrained package requests like { new-dep: "" }.

Implementation details:

  • Variant removal keys are validated as option names.
  • Removed option names are carried on the variant and filtered out during opts_for_variant resolution.
  • Added tests for removing both package and var options.
  • Updated user and API docs with examples for both forms.

jrray and others added 3 commits August 11, 2026 11:47
Confirm that a variant entry like { foo: "" } — a valid package
name with an empty value — is treated as a new package requirement
(not a var) when the key is absent from build.options.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: J Robert Ray <jrray@imageworks.com>
A variant entry like `{ "-foo": "" }` removes the package option
named `foo` from the build environment for that variant, even if
`foo` appears in `build.options`. The leading `-` is stripped and
the remainder is validated as a package name; invalid names produce
an error at parse time.

The removal is exposed via a new `Variant::removed_requirements()`
trait method (default: empty). `opts_for_variant` in both
`BuildSpec` and `RecipeBuildSpec` now filter out removed options
before returning the opt list.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: J Robert Ray <jrray@imageworks.com>
Document the new variant key syntax that removes a package
request inherited from build.options for a single variant.

Add examples to both the user guide and the v0 API reference
next to existing variant option patterns.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: J Robert Ray <jrray@imageworks.com>
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.18919% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/spk-schema/src/v0/variant.rs 75.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Allow variant entries prefixed with '-' to remove any existing
build option from build.options, not only package options.
This enables disabling var requests with keys like
{ "-debug": "" }.

Update variant parsing to validate removal keys as option names,
add test coverage for var removal, and update user/reference docs
with examples that remove both pkg and var options.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: J Robert Ray <jrray@imageworks.com>
@jrray

jrray commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

@rydrman does this pass the smell test for you?

We have a use case where a package has a lot of variants and the owner wants to remove a package dependency from one of the variants. This feature makes doing this less error-prone because the removal is explicit in the one variant and it is less likely that you forget to add the dependency back in any new variants or cut-and-paste a variant without realizing you've copied a variant that is missing a dependency you wanted.

@jrray jrray self-assigned this Aug 12, 2026
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