Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/types: change pathInStore to allow leading period #373285

Closed
wants to merge 1 commit into from

Conversation

jfly
Copy link
Contributor

@jfly jfly commented Jan 12, 2025

As of nix v2.21.0:

Store paths are allowed to start with .

I'm not entirely sure what range of versions of nix we try to stay compatible with over here in nixpkgs. That said, I don't think particular change would cause issues for people using a version of nix that doesn't support leading periods.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

As of [nix v2.21.0](https://nix.dev/manual/nix/2.25/release-notes/rl-2.21.html):

> Store paths are allowed to start with `.`

I'm not entirely sure what range of versions of `nix` we try to stay
compatible with over here in `nixpkgs`. That said, I don't think
particular change would cause issues for people using a version of `nix`
that doesn't support leading periods.
@github-actions github-actions bot added 6.topic: module system About "NixOS" module system internals 6.topic: lib The Nixpkgs function library labels Jan 12, 2025
@jfly jfly requested review from infinisil and roberth January 12, 2025 21:14
@jfly jfly mentioned this pull request Jan 12, 2025
13 tasks
@infinisil
Copy link
Member

What's the motivation for this? And ping @ncfavier who introduced the type in #237259.

@ncfavier
Copy link
Member

I assume what the changelog means is that paths like /nix/store/<hash>-.foo are now allowed. This obviously doesn't make a difference here.

@infinisil
Copy link
Member

Although I'm just realising, the PR isn't changing whether a . is after /nix/store/<hash>-, but rather whether it's allowed after /nix/store/, as can be seen from the test that had to be changed, and that seems wrong. types.pathInStore doesn't look like it ever disallowed the paths that are newly allowed in Nix, so I don't think any change is necessary.

@roberth
Copy link
Member

roberth commented Jan 14, 2025

We already have:

nix-repl> lib.types.pathInStore.check "/nix/store/foo-.bashrc"
true

So leading periods are already accepted, and it seems we can close this particular PR.


However,

types.pathInStore
A path that is contained in the Nix store. This can be a top-level store
path like pkgs.hello or a descendant like "${pkgs.hello}/bin/hello".

This should not include /nix/store/. or /nix/store/... The exclusion of .links is ok, because that location is an implementation detail that should never be accessed by the evaluator, and not even by user generated config files.

Arguably /nix/store/a/.. should also be rejected, but that's not currently the case.

@roberth roberth closed this Jan 14, 2025
@jfly
Copy link
Contributor Author

jfly commented Jan 14, 2025

Urg, sorry. Now realizing that this PR made no sense, sorry for the noise.

@jfly jfly deleted the pathInStore-allow-leading-period branch January 14, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: lib The Nixpkgs function library 6.topic: module system About "NixOS" module system internals 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants