aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThéophane Hufschmitt <theophane.hufschmitt@tweag.io>2023-05-16 11:37:45 +0200
committerThéophane Hufschmitt <theophane.hufschmitt@tweag.io>2023-05-16 11:41:58 +0200
commite997512523d8c5d22005b6cd5e22271284273ee6 (patch)
tree9ba54525ef0f799a1259deb2c1c75ea2ea7234c9 /tests
parent3d144e778e4193c948fa6e0a23f9f3de194bc62f (diff)
Fix the printing of the installables on `nix profile install` conflict
- If the element comes from a flake, print the full flakeref (with the fragment part) and not just the reference to the flake itself - If the element doesn't come from a flake, print its store path(s) This is a bit too verbose, but has the advantages of being correct (and not crashing), so it's strictly better than the previous situation Fix https://github.com/NixOS/nix/issues/8284
Diffstat (limited to 'tests')
-rw-r--r--tests/nix-profile.sh13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/nix-profile.sh b/tests/nix-profile.sh
index 4ef5b484a..9da3f802b 100644
--- a/tests/nix-profile.sh
+++ b/tests/nix-profile.sh
@@ -157,17 +157,17 @@ error: An existing package already provides the following file:
To remove the existing package:
- nix profile remove path:${flake1Dir}
+ nix profile remove path:${flake1Dir}#packages.${system}.default
The new package can also be installed next to the existing one by assigning a different priority.
The conflicting packages have a priority of 5.
To prioritise the new package:
- nix profile install path:${flake2Dir} --priority 4
+ nix profile install path:${flake2Dir}#packages.${system}.default --priority 4
To prioritise the existing package:
- nix profile install path:${flake2Dir} --priority 6
+ nix profile install path:${flake2Dir}#packages.${system}.default --priority 6
EOF
)
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
@@ -177,3 +177,10 @@ nix profile install $flake2Dir --priority 0
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World2" ]]
# nix profile install $flake1Dir --priority 100
# [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
+
+# Ensure that conflicts are handled properly even when the installables aren't
+# flake references.
+# Regression test for https://github.com/NixOS/nix/issues/8284
+clearProfiles
+nix profile install $(nix build $flake1Dir --no-link --print-out-paths)
+expect 1 nix profile install --impure --expr "(builtins.getFlake ''$flake2Dir'').packages.$system.default"