Create lint for absolute path literals#15345
Merged
Ericson2314 merged 1 commit intoNixOS:masterfrom Feb 26, 2026
Merged
Conversation
f12f78f to
60b8a33
Compare
roberth
reviewed
Feb 26, 2026
60b8a33 to
7c426a7
Compare
roberth
approved these changes
Feb 26, 2026
|
|
||
| Absolute path literals can make Nix expressions less portable and reproducible, as they depend on the filesystem layout of the machine evaluating the expression. | ||
|
|
||
| Also note that with [pure evaluation mode](@docroot@/command-ref/conf-file.md#conf-pure-eval), accessing files not so easily accessed via relative paths is often prohibited anyways. |
Member
There was a problem hiding this comment.
Suggested change
| Also note that with [pure evaluation mode](@docroot@/command-ref/conf-file.md#conf-pure-eval), accessing files not so easily accessed via relative paths is often prohibited anyways. | |
| Also note that with [pure evaluation mode](@docroot@/command-ref/conf-file.md#conf-pure-eval), accessing files not so easily accessed via relative paths is often prohibited anyway. |
Too germanic and too long. Idk, not a linguist.
Member
Author
There was a problem hiding this comment.
Reworded, and move from release notes to the settings description, where it will be read more on an ongoing basis.
7c426a7 to
ed494f0
Compare
Contributor
|
Does this interact in any way with builtins.storePath. Are there any legitimate use cases for absolute path value usages? |
Member
Author
|
It does not interact with |
xokdvium
reviewed
Feb 26, 2026
xokdvium
approved these changes
Feb 26, 2026
| NIX_CONFIG='lint-absolute-path-literals = warn' nix eval --lint-absolute-path-literals ignore --expr '/tmp/bar' 2>"$TEST_ROOT"/stderr | ||
| grepQuietInverse "absolute path literal" "$TEST_ROOT/stderr" | ||
|
|
||
| echo "absolute-path-literals test passed!" |
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
Fixes #8738
Context
Besides the direct user benefit of having this lint, this reduces the evaluator's usage of
rootFS, which also gets us closer to #9549.Review with whitespace disabled.
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.