From 16da1a32244a994b8497c8c37dd28552cb233a6d Mon Sep 17 00:00:00 2001 From: detroyejr Date: Sat, 12 Apr 2025 14:46:29 -0400 Subject: [PATCH 1/2] Add optimize as an alias of optimise --- src/libutil/include/nix/util/args.hh | 2 ++ src/nix/store.cc | 1 + tests/functional/optimise-store.sh | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/libutil/include/nix/util/args.hh b/src/libutil/include/nix/util/args.hh index 463270374..fb02dd87f 100644 --- a/src/libutil/include/nix/util/args.hh +++ b/src/libutil/include/nix/util/args.hh @@ -398,6 +398,8 @@ public: AcceptedShorthand, /** Aliases that will go away */ Deprecated, + /** Aliases for linguistic variation */ + LinguisticVariation, }; /** An alias, except for the original syntax, which is in the map key. */ diff --git a/src/nix/store.cc b/src/nix/store.cc index 80f9363ca..0e4e9941c 100644 --- a/src/nix/store.cc +++ b/src/nix/store.cc @@ -8,6 +8,7 @@ struct CmdStore : NixMultiCommand { aliases = { {"ping", { AliasStatus::Deprecated, {"info"}}}, + {"optimize", { AliasStatus::LinguisticVariation, {"optimise"}}}, }; } diff --git a/tests/functional/optimise-store.sh b/tests/functional/optimise-store.sh index 05c4c41e4..808097349 100755 --- a/tests/functional/optimise-store.sh +++ b/tests/functional/optimise-store.sh @@ -41,6 +41,28 @@ if [ "$inode1" != "$inode3" ]; then exit 1 fi +outPath4=$(echo 'with import '"${config_nix}"'; mkDerivation { name = "foo4"; builder = builtins.toFile "builder" "mkdir $out; echo hello > $out/foo"; }' | nix-build - --no-out-link) + +NIX_REMOTE="" nix store optimise + +inode1="$(stat --format=%i $outPath1/foo)" +inode4="$(stat --format=%i $outPath4/foo)" +if [ "$inode1" != "$inode4" ]; then + echo "inodes do not match" + exit 1 +fi + +outPath5=$(echo 'with import '"${config_nix}"'; mkDerivation { name = "foo5"; builder = builtins.toFile "builder" "mkdir $out; echo hello > $out/foo"; }' | nix-build - --no-out-link) + +NIX_REMOTE="" nix store optimize # alias of optimise + +inode1="$(stat --format=%i $outPath1/foo)" +inode5="$(stat --format=%i $outPath5/foo)" +if [ "$inode1" != "$inode5" ]; then + echo "inodes do not match" + exit 1 +fi + nix-store --gc if [ -n "$(ls $NIX_STORE_DIR/.links)" ]; then From d81d307fd3125d0f0542a06c0a84c87ce7dae7b9 Mon Sep 17 00:00:00 2001 From: detroyejr Date: Fri, 18 Apr 2025 09:46:54 -0400 Subject: [PATCH 2/2] Add release note --- doc/manual/rl-next/optimise-alias.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 doc/manual/rl-next/optimise-alias.md diff --git a/doc/manual/rl-next/optimise-alias.md b/doc/manual/rl-next/optimise-alias.md new file mode 100644 index 000000000..3af8bf59c --- /dev/null +++ b/doc/manual/rl-next/optimise-alias.md @@ -0,0 +1,7 @@ +--- +synopsis: Add an alias for optimise. +issues: 1902, 11326 +prs: 11577 +--- + +Add "optimize" as a linguistic variation of "optimise". Now both the `nix-store` and `nix store` commands work with the same spelling.