mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
Merge pull request #9656 from edolstra/nix-profile-stable-names
Make profile element names stable
This commit is contained in:
commit
52f949bbf5
6 changed files with 101 additions and 123 deletions
|
@ -49,7 +49,7 @@ cp ./config.nix $flake1Dir/
|
|||
nix-env -f ./user-envs.nix -i foo-1.0
|
||||
nix profile list | grep -A2 'Name:.*foo' | grep 'Store paths:.*foo-1.0'
|
||||
nix profile install $flake1Dir -L
|
||||
nix profile list | grep -A4 'Index:.*1' | grep 'Locked flake URL:.*narHash'
|
||||
nix profile list | grep -A4 'Name:.*flake1' | grep 'Locked flake URL:.*narHash'
|
||||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
|
||||
[ -e $TEST_HOME/.nix-profile/share/man ]
|
||||
(! [ -e $TEST_HOME/.nix-profile/include ])
|
||||
|
@ -58,9 +58,8 @@ nix profile history | grep "packages.$system.default: ∅ -> 1.0"
|
|||
nix profile diff-closures | grep 'env-manifest.nix: ε → ∅'
|
||||
|
||||
# Test XDG Base Directories support
|
||||
|
||||
export NIX_CONFIG="use-xdg-base-directories = true"
|
||||
nix profile remove 1
|
||||
nix profile remove flake1 2>&1 | grep 'removed 1 packages'
|
||||
nix profile install $flake1Dir
|
||||
[[ $($TEST_HOME/.local/state/nix/profile/bin/hello) = "Hello World" ]]
|
||||
unset NIX_CONFIG
|
||||
|
@ -68,7 +67,7 @@ unset NIX_CONFIG
|
|||
# Test upgrading a package.
|
||||
printf NixOS > $flake1Dir/who
|
||||
printf 2.0 > $flake1Dir/version
|
||||
nix profile upgrade 1
|
||||
nix profile upgrade flake1
|
||||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello NixOS" ]]
|
||||
nix profile history | grep "packages.$system.default: 1.0, 1.0-man -> 2.0, 2.0-man"
|
||||
|
||||
|
@ -81,7 +80,7 @@ nix profile rollback
|
|||
|
||||
# Test uninstall.
|
||||
[ -e $TEST_HOME/.nix-profile/bin/foo ]
|
||||
nix profile remove foo
|
||||
nix profile remove foo 2>&1 | grep 'removed 1 packages'
|
||||
(! [ -e $TEST_HOME/.nix-profile/bin/foo ])
|
||||
nix profile history | grep 'foo: 1.0 -> ∅'
|
||||
nix profile diff-closures | grep 'Version 3 -> 4'
|
||||
|
@ -89,7 +88,7 @@ nix profile diff-closures | grep 'Version 3 -> 4'
|
|||
# Test installing a non-flake package.
|
||||
nix profile install --file ./simple.nix ''
|
||||
[[ $(cat $TEST_HOME/.nix-profile/hello) = "Hello World!" ]]
|
||||
nix profile remove 1
|
||||
nix profile remove simple 2>&1 | grep 'removed 1 packages'
|
||||
nix profile install $(nix-build --no-out-link ./simple.nix)
|
||||
[[ $(cat $TEST_HOME/.nix-profile/hello) = "Hello World!" ]]
|
||||
|
||||
|
@ -97,8 +96,9 @@ nix profile install $(nix-build --no-out-link ./simple.nix)
|
|||
mkdir $TEST_ROOT/simple-too
|
||||
cp ./simple.nix ./config.nix simple.builder.sh $TEST_ROOT/simple-too
|
||||
nix profile install --file $TEST_ROOT/simple-too/simple.nix ''
|
||||
nix profile list | grep -A4 'Name:.*simple' | grep 'Name:.*simple1'
|
||||
nix profile remove simple1
|
||||
nix profile list | grep -A4 'Name:.*simple' | grep 'Name:.*simple-1'
|
||||
nix profile remove simple 2>&1 | grep 'removed 1 packages'
|
||||
nix profile remove simple-1 2>&1 | grep 'removed 1 packages'
|
||||
|
||||
# Test wipe-history.
|
||||
nix profile wipe-history
|
||||
|
@ -107,11 +107,11 @@ nix profile wipe-history
|
|||
# Test upgrade to CA package.
|
||||
printf true > $flake1Dir/ca.nix
|
||||
printf 3.0 > $flake1Dir/version
|
||||
nix profile upgrade 0
|
||||
nix profile upgrade flake1
|
||||
nix profile history | grep "packages.$system.default: 1.0, 1.0-man -> 3.0, 3.0-man"
|
||||
|
||||
# Test new install of CA package.
|
||||
nix profile remove flake1
|
||||
nix profile remove flake1 2>&1 | grep 'removed 1 packages'
|
||||
printf 4.0 > $flake1Dir/version
|
||||
printf Utrecht > $flake1Dir/who
|
||||
nix profile install $flake1Dir
|
||||
|
@ -132,14 +132,14 @@ nix profile upgrade flake1
|
|||
[ -e $TEST_HOME/.nix-profile/share/man ]
|
||||
[ -e $TEST_HOME/.nix-profile/include ]
|
||||
|
||||
nix profile remove flake1
|
||||
nix profile remove flake1 2>&1 | grep 'removed 1 packages'
|
||||
nix profile install "$flake1Dir^man"
|
||||
(! [ -e $TEST_HOME/.nix-profile/bin/hello ])
|
||||
[ -e $TEST_HOME/.nix-profile/share/man ]
|
||||
(! [ -e $TEST_HOME/.nix-profile/include ])
|
||||
|
||||
# test priority
|
||||
nix profile remove flake1
|
||||
nix profile remove flake1 2>&1 | grep 'removed 1 packages'
|
||||
|
||||
# Make another flake.
|
||||
flake2Dir=$TEST_ROOT/flake2
|
||||
|
@ -193,3 +193,12 @@ nix profile install $flake2Dir --priority 0
|
|||
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"
|
||||
|
||||
# Test upgrading from profile version 2.
|
||||
clearProfiles
|
||||
mkdir -p $TEST_ROOT/import-profile
|
||||
outPath=$(nix build --no-link --print-out-paths $flake1Dir/flake.nix^out)
|
||||
printf '{ "version": 2, "elements": [ { "active": true, "attrPath": "legacyPackages.x86_64-linux.hello", "originalUrl": "flake:nixpkgs", "outputs": null, "priority": 5, "storePaths": [ "%s" ], "url": "github:NixOS/nixpkgs/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] }' "$outPath" > $TEST_ROOT/import-profile/manifest.json
|
||||
nix build --profile $TEST_HOME/.nix-profile $(nix store add-path $TEST_ROOT/import-profile)
|
||||
nix profile list | grep -A4 'Name:.*hello' | grep "Store paths:.*$outPath"
|
||||
nix profile remove hello 2>&1 | grep 'removed 1 packages, kept 0 packages'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue