Skip to content

Commit

Permalink
nix-env to nix profile: maintain priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
elikoga authored and iFreilicht committed Feb 29, 2024
1 parent bf48501 commit ed9aac6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/nix/profile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ struct ProfileManifest
for (auto & packageInfo : packageInfos) {
ProfileElement element;
element.storePaths = {packageInfo.queryOutPath()};
element.priority = packageInfo.queryMetaInt("priority", defaultPriority);
addElement(std::move(element));
}
}
Expand Down
6 changes: 4 additions & 2 deletions tests/functional/nix-profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ printf false > $flake1Dir/ca.nix
cp ./config.nix $flake1Dir/

# Test upgrading from nix-env.
nix-env -f ./user-envs.nix -i foo-1.0
nix-env -f ./user-envs.nix -i foo-1.0 foo-0.2
nix profile list | grep -A2 'Name:.*foo' | grep 'Store paths:.*foo-1.0'
nix profile list | grep -A2 'Name:.*foo-1' | grep 'Store paths:.*foo-0.2'
nix profile install $flake1Dir -L
nix profile list | grep -A4 'Name:.*flake1' | grep 'Locked flake URL:.*narHash'
grep '"priority":13' $TEST_HOME/.nix-profile/manifest.json
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
[ -e $TEST_HOME/.nix-profile/share/man ]
(! [ -e $TEST_HOME/.nix-profile/include ])
Expand All @@ -59,7 +61,7 @@ nix profile diff-closures | grep 'env-manifest.nix: ε → ∅'

# Test XDG Base Directories support
export NIX_CONFIG="use-xdg-base-directories = true"
nix profile remove flake1 2>&1 | grep 'removed 1 packages'
nix profile remove flake1 foo-1 2>&1 | grep 'removed 2 packages'
nix profile install $flake1Dir
[[ $($TEST_HOME/.local/state/nix/profile/bin/hello) = "Hello World" ]]
unset NIX_CONFIG
Expand Down
1 change: 1 addition & 0 deletions tests/functional/user-envs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ in
(makeDrv "foo-2.0" "foo")
(makeDrv "bar-0.1.1" "bar")
(makeDrv "foo-0.1" "foo" // { meta.priority = 10; })
(makeDrv "foo-0.2" "ijioj" // { meta.priority = 13; })
(makeDrv "fail-0.1" "fail")
]

0 comments on commit ed9aac6

Please sign in to comment.