-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Redefine outputs in terms of language-level "package", not necessarily store-level derivation (RFC-92, and multi-drv packages, docs) #6507
Comments
Documentation is quite a frequent problem, I think. Well |
Found this note at /*
[...]
* Note that does mean a derived store paths evaluates to multiple
* opaque paths, which is sort of icky as expressions are supposed to
* evaluate to single values. Perhaps this should have just a single
* output name.
*/
struct DerivedPathBuilt { Seems like a change worth implementing for this issue. The notion of a single derivation with its outputs seems appropriate at the store level, but up from there, built paths are what matter and there's no reason to tie them to their derivation. By making the suggested improvement, it seems that we get a bit closer to multi-drv packages. |
@roberth in the later RFC 92 patches I do indeed make a |
@Ericson2314 I would consider I've updated the issue title and description to clarify the goal of the issue. |
@roberth Oh sure, What I just mean is that the comment you referenced above is quite likely one I wrote! :) And the You might want to take a look at #7261. I agree In a way, this issue here could be a joint effort between the Nixpkgs Architecture team and Nix team because the cross-cutting concerns invovled. |
#7467 somewhat relates to this. |
So currently in the docs we have "store derivation" and "derivation", and what I like about this is it completely decouples the logic:
|
Notably, the proposal [to define a "package" data type that nests derivation(s)] would solve laziness of That means, you can then peak, for example, at That means recovering metadata from packages finally gets the competitive pricing it deserves that is more closely related with its true production cost. |
|
I can't tell why this would have to be a Nix language concept. What precludes Nixpkgs of making that abstraction on top of |
The CLI uses
The language itself remains unchanged. |
@fricklerhandwerk Also check out https://github.com/NixOS/nix/issues/ There is a tension between these too things:
The easiest way to resolve this tension is probably to cut the cord between them: different idioms for different level of abstraction, disjoint terminology (package vs derivation). |
Probably not strictly necessary, but it may be useful for this to be a language level concept. It would essentially encode the same knowledge as a profile, but a posteriori. Since a "useful package" is really the final aim of why we use Nix in the first place, it makes sense for it to be at the root. It may also have the effect of making our current terminology more intuitive. We have derivations, but what are they derived from exactly? A language level package construct makes the answer tangibly obvious. |
|
An attribute set for a package is reasonable, and that's also what the flake schema goes for. But all this is an issue for Nixpkgs, because that's where Nix-language-level metadata is currently lumped together with build configuration, and where a more scalable convention should be established first. There is little Nix can (or should, IMO) do about that. The recently renewed design discussion around lockfiles could offer a place for statically displaying outputs (including metadata) as well, so they don't require computation to determine on the consumer's end. Then we don't have to artificially restrict expressive power in the package declaration itself. |
Is this discussion in scope for
|
Wouldn't this create a need to update the lock file whenever the expressions change? I don't think using the lockfile as a cache is a good idea, and I'd be happy to explain that in a suitable issue/thread. IFD is one reason. Another problem with this is a data model problem that I didn't illustrate at all. It's the problem of the linked comment. What if your update tooling needs to read |
Yeah sounds like a unit in RFC-140 speak is closer to a pair of a package function and a meta; much/all of the meta should not depend on parameters of the package function. I do agree that even if some things are Nixpkgs only, and we have a Nixpkgs CLI to deal with those, we do need something else for Nix<--->Nixpkgs and that is what this issue deals with. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/flakey-profile-declarative-nix-profiles-as-flakes/35163/3 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-12-08-nix-team-meeting-minutes-110/36721/1 |
A small step towards NixOS#6507 I believe this incomplete definition is one that can be agreed on. It would be nice to define more, but considering that the issue also proposes changes to the design, I believe we should hold off on those. As for the wording, we're dealing with some very general and vague terms, that have to be treated with exactly the right amount of vagueness to be effective. I start out with a fairly abstract definition of package. 1. to establish a baseline so we know what we're talking about 2. so that we can go in and clarify that we have an extra, Nix-specific definition. "Software" is notoriously ill-defined, so it makes a great qualifier for package, which we don't really want to pin down either, because that would just get us lost in discussion. We can come back to this after we've done 6057 and a few years in a desert cave. Then comes the "package attribute set" definition. I can already hear Valentin say "That's not even Nix's responsibility!" and on some days I might even agree. However, in our current reality, we have `nix-env`, `nix-build` and `nix profile`, which query the `outputName` attribute - among others - which just don't exist in the derivation. For those who can't believe what they're reading: $ nix-build --expr 'with import ./. {}; bind // {outputName = "lib";}' --no-out-link this path will be fetched (1.16 MiB download, 3.72 MiB unpacked): /nix/store/rfk6klfx3z972gavxlw6iypnj6j806ma-bind-9.18.21-lib copying path '/nix/store/rfk6klfx3z972gavxlw6iypnj6j806ma-bind-9.18.21-lib' from 'https://cache.nixos.org'... /nix/store/rfk6klfx3z972gavxlw6iypnj6j806ma-bind-9.18.21-lib and let me tell you that bind is not a library. So anyway, that's also proof of why calling this a "derivation attrset" would be wrong, despite the type attribute.
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-02-26-nix-team-meeting-minutes-128/40496/1 |
The new package output attributes are somewhat experimental, and provided for compatibility most of all. We'll see how well this goes before the changes proposed in #6507
The new package output attributes are somewhat experimental, and provided for compatibility most of all. We'll see how well this goes before the changes proposed in #6507
The new package output attributes are somewhat experimental, and provided for compatibility most of all. We'll see how well this goes before the changes proposed in #6507
Describe the problem
Goals
doc
into a separate derivationCurrently, packages and derivations are often the same thing, but the lack of a definition and distinction between the two can not continue since RFC 92 (computed derivations,
outputOf
) and the conflation has unnecessarily made the concept of a multi-derivation package ill-formed / "unthinkable".Nix doesn't really have a notion of "package". The term is only mentioned in a few places in the code, and only defined in the context of
buildenv
(ie legacynix-env
). This only related to the usage of derivations in a profile, and therefore does not conflict with a definition of "package".Nixpkgs on the other hand is all about packages, but it does not define precisely what a package is.
I propose the following definition:
A package is an attribute set with the following attributes:
outputs
: list of strings${output}
for eachoutput
inoutputs
: store path stringname
: stringversion
: stringmeta
: attribute set with specific optional(?) attributestests
: optional attrset tree of derivations and/or packagesdevShell
: see Allow to get rid ofnix develop
"shell" logic #7501Notably absent from the definition of a package:
drvPath
: this is an implementation detail. A package consumer really only cares about outputs, which don't need to be provided by a single derivation. Derivation path(s) can be recovered from the outputs.overrideAttrs
,buildInputs
: attributes related to the construction of a derivation. These are implementation detailspassthru
: not related to the construction of a derivation, but an implementation detail for setting package attrs as opposed to derivation attrs. This attribute owes its entire existence tooverrideAttrs
. WithoutoverrideAttrs
,//
is sufficient to set package attributes.all
: not used by Nix itself, rarely used in Nixpkgs (regex:(?<!platforms)(?<!lib)(?<!builtins)[.]all
; still mostly false positives. Only one clear usage, which has a TODO on it)Steps To Reproduce
doc
autoconf: build offline html documentation nixpkgs#172103 where it would be more desirable for the non-doc
outputs not to depend ontexinfo
).drvPath
should be.drvPath
output wasn't included.Expected behavior
Nix represents packages by its outputs and metadata, not the
drvPath
implementation detail.nix-env --version
output2.8. Or 2.x really. I would appreciate a major version increase for the (subtle) change in behavior.
Additional context
I came across this problem again in Nixpkgs today and figured I had to share my thoughts. I guess I should turn it into an RFC? I can do that later if y'all agree that we need something like this.
There's also NixOS/nixpkgs#172008 which is really a different problem, but depends on this issue, as this issue defines the interface for what current and future Nixpkgs' must implement.
I can't change the
bug
label on this issue. It's really a design issue rather than a bug, so another label would be more fitting. Can I have more permissions on this repo?The text was updated successfully, but these errors were encountered: