From 1f2266d590ba6afa82157ea7715813f2e02bd1c7 Mon Sep 17 00:00:00 2001 From: detroyejr Date: Sat, 12 Apr 2025 14:46:29 -0400 Subject: [PATCH] Add optimize as an alias of optimise --- src/nix/store.cc | 1 + tests/functional/optimise-store.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/nix/store.cc b/src/nix/store.cc index 80f9363ca..e34d63c96 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::AcceptedShorthand, {"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