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

Add nix package type #314

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions PURL-TYPES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,25 @@ swift
pkg:swift/github.com/Alamofire/Alamofire@5.4.3
pkg:swift/github.com/RxSwiftCommunity/RxFlow@2.12.4


nix
---

``nix`` for Nix derivations:
Copy link

Choose a reason for hiding this comment

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

Suggested change
``nix`` for Nix derivations:
``nix`` for Nix store paths:

The PURL is for each store path, and we may have multiple PURL for different output paths in the same derivation.


- The default package repository is <https://github.com/NixOS/nixpkgs> but the ``repository`` qualifier can override the package repository.
Copy link

Choose a reason for hiding this comment

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

Does this field even matter at all? With just the PURL we cannot reproduce the drv path anyways, there's a lot of other details (like rev, system, ...) we'd need. Also, the line gets blurry if you have a repo that imports nixpkgs, but overrides an expression, what should this be set to?

Inclined to remove this, this can only be a hint at most.

Choose a reason for hiding this comment

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

With this field being mostly informative I feel we'd want a nar package type or at least a nar field to better identify where you got the package from if using a cache like cache.nixos.org. ommitted or something for if you built it locally?

Copy link

Choose a reason for hiding this comment

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

It is not identifying the package. If you have a nar sha256 hash, you can fetch it from any content-addressed store.

Copy link

@06kellyjac 06kellyjac Sep 26, 2024

Choose a reason for hiding this comment

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

"what" being covered by the hash, but "where" can also useful for some governance.
Also if you can find that hash in your content-addressed store then great, but if you can't you might at least want a possible alternative location to check to find the same artifact described by the PURL.

Also lightning quick response! ⚡

- The ``name`` is the package ``pname`` field of the given derivation. It is case sensitive.
Copy link

@flokli flokli Sep 17, 2024

Choose a reason for hiding this comment

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

We don't always have the pname / version separate. Deep down pname and version are concatenated into a single string. Should something creating a PURL try to split this off? (Probably fine, but in that case, see the comment on the version field).

Choose a reason for hiding this comment

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

the current state of name, pname, and versioning standards was part of why I didn't expect there to be a PURL standard yet for nix. (TBH I haven't checked on the current-state of discussions for a while so maybe it's settled lol)
Although it'd be great if this spec discussion helps push things forwards

- The ``version`` is the ``version`` field of the given derivation.
Copy link

@flokli flokli Sep 17, 2024

Choose a reason for hiding this comment

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

How do PURL look like for store paths where the version cannot be extracted? Is this field (and other fields) optional or required? The spec for other PURLs in this file do explicitly say what's required and what not.

- The ``drvpath`` qualifier is the derivation path (``.drvPath``).
Copy link

Choose a reason for hiding this comment

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

Do we want to have an outpath here too, or are PURL always for individual output paths, so this information would be redundant?

Is drvpath optional or required?

- The ``output`` qualifier is the output field, by default: ``out``
Copy link

Choose a reason for hiding this comment

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

Suggested change
- The ``output`` qualifier is the output field, by default: ``out``
- The ``output`` qualifier is the name of the output, which helps to distinguish in the case of multi-output derivations

The "default" behavior is confusing. It doesn't describe if it should always be set, or if it is "out" in case the field is not present.

Or should it always be set to something, and the fact it's "out" in single-output derivations is an implementation detail of Nix that should be left out of the spec? I prefer this one, which is my the suggestion uses this variant.

I don't think it should be omitted in case of single-output derivations, it'd be odd if it suddenly would appear if an expression is refactored to multiple outputs.

Choose a reason for hiding this comment

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

including the output field also accounts for if the default is changed in the future and shouldn't be very painful to just include

Copy link

Choose a reason for hiding this comment

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

we should just map this to outputName of the drv. Then this works with lib.getLib etc


- Examples::

pkg:nix/glibc@2.39-52?drvpath=/nix/store/3nxf8kw3vgghz2y72b9qwi01sz62nhyk-glibc-2.39-52.drv&output=out
pkg:nix/glibc@2.39-52?drvpath=/nix/store/3nxf8kw3vgghz2y72b9qwi01sz62nhyk-glibc-2.39-52.drv&output=out&repository=github:user/nixpkgs
pkg:nix/systemd@255.6?drvpath=/nix/store/r34i4md1cmc19392zbbp9ya5nmd0av0k-systemd-255.6.drv&output=dev


Copy link

Choose a reason for hiding this comment

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

You probably want to remove "nix" from the old list below.

Other candidate types to define:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down