Skip to content

Add optimize as an alias of optimise#15997

Open
GraysonTinker wants to merge 3 commits into
NixOS:masterfrom
GraysonTinker:optimize-alias
Open

Add optimize as an alias of optimise#15997
GraysonTinker wants to merge 3 commits into
NixOS:masterfrom
GraysonTinker:optimize-alias

Conversation

@GraysonTinker

@GraysonTinker GraysonTinker commented Jun 8, 2026

Copy link
Copy Markdown

This PR allows the use of both nix store optimise and nix store optimize via a new linguistic alias type.

Continuation of #11577 with the trivial merge conflict resolved and formatting/shellcheck fixed. Previously received 2 positive reviews and then didn't get any attention.

Closes #11577. Closes #1902.

Motivation

Context


Add 👍 to pull requests you find important.

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

@GraysonTinker GraysonTinker requested a review from edolstra as a code owner June 8, 2026 15:16
@github-actions github-actions Bot added documentation new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority labels Jun 8, 2026
@GraysonTinker GraysonTinker force-pushed the optimize-alias branch 2 times, most recently from 2cba46c to e4c41b4 Compare June 8, 2026 15:22
@tomberek

Copy link
Copy Markdown
Contributor

Will this affect tab-completion... making it less effective, stopping short of completing the whole thing?

@GraysonTinker

Copy link
Copy Markdown
Author

Will this affect tab-completion... making it less effective, stopping short of completing the whole thing?

Hm, good question, I didn't think to test that. Let me check.

@GraysonTinker

Copy link
Copy Markdown
Author

@tomberek Nope, this doesn't appear in tab completion at all.

@edolstra edolstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit "meh" on this since it seems better in general to have a single canonical name for a command to avoid user confusion.

It might be more useful to use the Suggestions API to detect misspelled command names, in the same way we do for misspelled attribute names.

Comment thread tests/functional/optimise-store.sh
@GraysonTinker

Copy link
Copy Markdown
Author

I'm a bit "meh" on this since it seems better in general to have a single canonical name for a command to avoid user confusion.

I'm not sure that adding this alias would significantly change that, given that optimise is still the only version referenced in the manual, online documentation, completions, etc. I think that the idea of a secondary alias for ease-of-use would be understandable to users.

As a parallel, I don't believe there been any confusion with nix-store --optimise vs. --optimize.

It might be more useful to use the Suggestions API to detect misspelled command names, in the same way we do for misspelled attribute names.

Unless I'm misunderstanding, this already occurs:

$ nix store optimize
error: 'optimize' is not a recognised command
       Did you mean optimise?

@toastal

toastal commented Jun 12, 2026

Copy link
Copy Markdown

I got bit by this again today. No use fighting over spelling if supporting both is trivial.

@xokdvium xokdvium left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test could be refactored to be more clear, but I suppose the existing the test is already pretty ugly.

It seems like this request s quite common, so no use fighting over it (plus nix-store already has this). LGTM

Comment thread tests/functional/optimise-store.sh Outdated
Comment thread tests/functional/optimise-store.sh Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation new-cli Relating to the "nix" command 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.

optimi{z,s}e

6 participants