Skip to content

Allow flag aliases#11142

Merged
edolstra merged 2 commits intoNixOS:masterfrom
detroyejr:fix-alias-flags
Jul 22, 2024
Merged

Allow flag aliases#11142
edolstra merged 2 commits intoNixOS:masterfrom
detroyejr:fix-alias-flags

Conversation

@detroyejr
Copy link
Copy Markdown
Contributor

Motivation

The nix cli should allow aliases to be used as flags. Examples:

  • --max-jobs has an alias --build-max-jobs
  • --keep-derivations has an alias --gc-keep-derivations
  • --sandbox has an alias --build-use-sandbox

Context

Fixes #10989

Per the issue, the nix CLI should allow aliases to be used as flags. Currently, the cli prevents this and throws an unrecognized error. Looks like this behavior was implemented but not enabled so I've added some very small changes to BaseSettings<T>, BaseSettings<bool>, and BaseSettings<SandboxMode> to fix this.

Also added 2 tests to make sure all 3 types work.

Example from the issue works now:

nix eval --extra-experimental-features nix-command --expr '{}' --cores 1
nix eval --extra-experimental-features nix-command --expr '{}' --build-cores 1

Also returns the same error:

nix build --extra-experimental-features nix-command --extra-experimental-features flakes --build-max-jobs -1 nixpkgs#hello
nix build --extra-experimental-features nix-command --extra-experimental-features flakes --max-jobs -1 nixpkgs#hello

> error: configuration setting 'max-jobs' should be 'auto' or an integer

Feel free to close if this behavior isn't desired.

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Jul 19, 2024
@edolstra edolstra merged commit 40f80e1 into NixOS:master Jul 22, 2024
@cole-h
Copy link
Copy Markdown
Member

cole-h commented Jul 22, 2024

Thank you! I took a look a week or two ago and I guess I was investigating in the wrong direction, because my failed attempt was much less clean 😆

@nixos-discourse
Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-07-22-nix-team-meeting-minutes-163/49544/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings aliases are not supported as flags, while their "real" names are

5 participants