NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.32k stars 1.49k forks source link

New derivation-making builtin #9774

Open Ericson2314 opened 8 months ago

Ericson2314 commented 8 months ago

builtins.derivation (and builtins.derivationStrict) have a number of issues:

TODO other things

Priorities

Add :+1: to issues you find important.

nixos-discourse commented 8 months ago

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

https://discourse.nixos.org/t/2024-01-15-nix-team-meeting-minutes-115/38297/1

roberth commented 8 months ago
Outdated - possible pkg.derivation attr in Nixpkgs We should align this with - https://github.com/NixOS/nixpkgs/pull/281161 Currently that means that the return type should have a `path` field containing the `.drv`, but other than that, I've proposed to keep it lean.
roberth commented 8 months ago

We should also consider whether we even want to return such attributes as inputSrcs, inputDrvs eagerly, as this will probably result in plenty of unused-but-referenced Values that we can't GC. Technically we could work around that by adding them as thunks that call an (internal or not) primop for retrieving those from the .drv file. This is only a partial solution to the space leak though, because the attrs and thunks still take a bit of space, even if not evaluated.

Ericson2314 commented 8 months ago

@roberth I was thinking the user would just drop them if they don't want them.

Outdated - possible pkg.derivation attr in Nixpkgs But yes, this conflicts with `derivation` just being the result of the new primop.
roberth commented 6 months ago

Nix prints the position of the name attribute, but this is almost always useless:

whose name attribute is located at nixpkgs/pkgs/stdenv/generic/make-derivation.nix:331:7

Ideally, Nix would accept a __pos parameter with a user-provided position, such as mkDerivation's pos argument, which is already used for some Nixpkgs-specific error messages. Nix should use this too, but __pos must not be written to the actual derivation in the store, as that would affect the hash every time the position changes slightly. Changes to derivation attribute hashing need to be forward compatible, and we have no good forward compatibility in the current derivation/derivationStrict primops.

In summary:

nixos-discourse commented 6 months ago

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

https://discourse.nixos.org/t/2024-03-11-nix-team-meeting-132/42960/1

roberth commented 4 months ago

Added two examples of meta attributes that the store layer must be aware of.