Skip to content

Comments

lib.path.hasStorePathPrefix: init#273883

Merged
infinisil merged 1 commit intoNixOS:masterfrom
tweag:path.hasStorePathPrefix
Dec 13, 2023
Merged

lib.path.hasStorePathPrefix: init#273883
infinisil merged 1 commit intoNixOS:masterfrom
tweag:path.hasStorePathPrefix

Conversation

@infinisil
Copy link
Member

@infinisil infinisil commented Dec 13, 2023

Description of changes

In order to implement #269283 I need a path function to detect whether a path is a store path or not. So this PR adds a function to do that:

lib.path.hasStorePathPrefix /nix/store/nvl9ic0pj1fpyln3zaqrf4cclbqdfn1j-foo
-> true

This is followed up by a PR to split the store path from such a path: #273884

This work is sponsored by Antithesis

Things done

  • Documentation
  • Tidy code
  • Tests

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: lib The Nixpkgs function library label Dec 13, 2023
@infinisil infinisil mentioned this pull request Dec 13, 2023
3 tasks
@infinisil infinisil force-pushed the path.hasStorePathPrefix branch 2 times, most recently from a1ad0c1 to 48b1b5d Compare December 13, 2023 04:15
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Dec 13, 2023
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just docs 🚀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reorder these to convey the most important information fastest.

  1. /nix/store/nvl9ic0pj1fpyln3zaqrf4cclbqdfn1j-foo/bar/baz
  2. /nix/store
  3. /nix/store/nvl9ic0pj1fpyln3zaqrf4cclbqdfn1j-foo
  4. the other things that aren't store paths.
  5. the derivation (I think virtually everyone would guess that one right)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually not sure about derivations myself, because you can't actually get path values to derivations legitimately, and Nix even has a check preventing derivation names ending with .drv (unless RFC 92 stuff).

But, after thinking about it, just sticking to the reference docs on store paths (lovely to have that!) should be best. There, store derivations are clearly indicated as also having a store path.

I reordered these sections as you suggested now :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's drvPath on all packages, but the semantics are odd.

There's little reason to reference derivation paths as strings, let alone path values, so this is more than good enough.

@infinisil infinisil force-pushed the path.hasStorePathPrefix branch from c21cc20 to d4b7b15 Compare December 13, 2023 16:12
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Let's merge when green.

@delroth delroth added the 12.approvals: 1 This PR was reviewed and approved by one person. label Dec 13, 2023
@infinisil infinisil merged commit 2f3e65a into NixOS:master Dec 13, 2023
@infinisil infinisil deleted the path.hasStorePathPrefix branch December 13, 2023 20:04
@github-actions
Copy link
Contributor

Successfully created backport PR for release-23.11:

@infinisil
Copy link
Member Author

Now #273884 is ready :)

Copy link
Contributor

@fricklerhandwerk fricklerhandwerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused why this has such a bulky name and was not called isStorePath

@infinisil
Copy link
Member Author

infinisil commented Dec 13, 2023

@fricklerhandwerk Because this is technically not a store path: /nix/store/nvl9ic0pj1fpyln3zaqrf4cclbqdfn1j-foo/bar/baz. I need a function specifically to return whether a path has a store path as a prefix. That is for #273884

@fricklerhandwerk
Copy link
Contributor

Okay, I see that now. Thanks.

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 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants