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

derivationOf primop #10120

Open
roberth opened this issue Mar 1, 2024 · 5 comments
Open

derivationOf primop #10120

roberth opened this issue Mar 1, 2024 · 5 comments
Labels
feature Feature request or proposal good first issue Quick win for first-time contributors idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. language The Nix expression language; parser, interpreter, primops, evaluation, etc

Comments

@roberth
Copy link
Member

roberth commented Mar 1, 2024

Is your feature request related to a problem? Please describe.

It behaves roughly as an inverse of outputOf and is equivalent to the planned ^.. syntax on the CLI.

This function improves RFC 92 and multi-derivation package support, by allowing the derivation path to be accessed for any output, whose derivations may be distinct, rather than only exposing a single drvPath.

pkg.drvPath is rarely needed. When we have a function for it, this attribute can be removed from the packages.

NixOS/nixpkgs#281536 adds such a function in Nixpkgs. Its implementation can serve as a polyfill for this builtin.

Describe the solution you'd like

A primop that takes the Nix language representation of a DerivingPath, a string with context, and returns the deriver field if it is present. Otherwise it should throw or return null.

Describe alternatives you've considered

Require the Nixpkgs library for this functionality.

Additional context

Priorities

Add 👍 to issues you find important.

@roberth roberth added the feature Feature request or proposal label Mar 1, 2024
@fricklerhandwerk fricklerhandwerk added the language The Nix expression language; parser, interpreter, primops, evaluation, etc label Mar 1, 2024
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/pre-rfc-implement-dependency-retrieval-primitive/43418/9

@edolstra edolstra added the idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. label Jun 24, 2024
@fricklerhandwerk
Copy link
Contributor

Discussed in Nix team meeting:

  • @edolstra: if there's a polyfill, why don't we use that?
    • @roberth: implementing it in C++ would be very simple, run much faster, and would provide much better error messages
    • @edolstra: looks fine otherwise
  • @fricklerhandwerk has reservations whether growing the API surface is a good use of limited time, but not going to block
  • idea approved

@edolstra
Copy link
Member

Team discussion:

  • Idea approved, seems useful and mirrors outputOf.
  • Probably doesn't need to be experimental since it's straight-forward and doesn't really fall under RFC 92.

@roberth roberth added the good first issue Quick win for first-time contributors label Jun 24, 2024
@roberth
Copy link
Member Author

roberth commented Jun 24, 2024

Note that it needs to be pure: only return the deriver field that's readily available, and don't query the store in the way nix-store -q --deriver does.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-06-24-nix-team-meeting-minutes-155/47739/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal good first issue Quick win for first-time contributors idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. language The Nix expression language; parser, interpreter, primops, evaluation, etc
Projects
None yet
Development

No branches or pull requests

4 participants