upgrade-nix: fix profile symlink resolution#15438
Open
amaanq wants to merge 1 commit intoNixOS:masterfrom
Open
upgrade-nix: fix profile symlink resolution#15438amaanq wants to merge 1 commit intoNixOS:masterfrom
amaanq wants to merge 1 commit intoNixOS:masterfrom
Conversation
Contributor
|
Would be nice to have some nixos upgrade tests in hydra... |
Contributor
|
Let's instead use a much better end-to-end test from nixpkgs: |
71b53ae to
f04fe2f
Compare
Ericson2314
reviewed
Mar 11, 2026
2eba5c9 to
7213bdc
Compare
`canonPath(profileDir, true)` (which resolves symlinks) was converted to `canonPath(profileDir)` (which doesn't) in a5a2562, so the profile path was never resolved to its store target. This is fixed by using `store->followLinksToStorePath` instead. The while loop that attempted to chase symlinks into `/profiles/` is removed. It called `readLink`, which returns relative targets for `nix-env` generation links (e.g. `.local-1-link`), crashing `canonPath` with "not an absolute path". The loop is also unnecessary now that `followLinksToStorePath` is used, since it resolves the full symlink chain to the store path regardless of whether the profile is under `/profiles/`. A NixOS VM test was added, which is based on nixpkgs' `nixosTests.nix-upgrade`, with three variants; one for stable, latest, and current.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
canonPath(profileDir, true)(which resolves symlinks) was convertedto
canonPath(profileDir)(which doesn't) in a5a2562, so the profilepath was never resolved to its store target. This is fixed by using
store->followLinksToStorePathinstead.The while loop that attempted to chase symlinks into
/profiles/isremoved. It called
readLink, which returns relative targets fornix-envgeneration links (e.g..local-1-link), crashingcanonPathwith "not an absolute path". The loop is also unnecessary now that
followLinksToStorePathis used, since it resolves the full symlinkchain to the store path regardless of whether the profile is under
/profiles/.A NixOS VM test was added, which is based on nixpkgs'
nixosTests.nix-upgrade,with three variants; one for stable, latest, and current.
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.