Why does it matter whether the package manager output changes?
The reason that a FOD has to be bit-for-bit reproducible is because a fetcher relies on the hash of the content (see Advanced Attributes - Nix Reference Manual) to avoid re-computation. If the Zig package manager changes how its package structure is laid out, then all FOD hashes need to be updated, which is a manual and pretty painful process to find out which FODs have changed outputs vs. which ones have not. There’s no good tooling to my knowledge that can automatically detect hash breakages other than simply rebuilding the FOD by settings its hash to a fake one to force re-computation and failure.
I guess the part that I don’t quite understand is how the nix side deals with versioning, is a FOD supposed to stay valid no matter what, or could it get a version attached that represents the version of zigs package manager format/hash/impl?
A FOD is supposed to refer to an immutable resource. If a URL changes under the hood, for example, it would not make sense to use this URL to create a FOD, for the reasons detailed above.
Currently, the way that Zig applications are packaged in nixpkgs is done with codegen using a tool called zon2nix, which generates Nix code by pre-fetching package URLs into the Nix store and computing their Nix hashes, and then creating a Zig package directory from that. This needs to be re-generated each time the build.zig.zon changes, which is not an automatic process, and it’s what I’m trying to avoid so that we can have transparent, simpler auto-updates for Zig-based packages in nixpkgs.
There are packages that support multiple versions of Zig, so I think baking the Zig version into a flattened tree of packages would potentially unnecessarily multiply the number of packages that only differ in Zig versions that may not even differ at all in what they produce from a package management perspective.
This is not really for the Zig side of packaging, but rather for system/distribution packaging, so I’m not really sure why this is a concern, since only one version of Zig is going to be used at this point to build the package for distribution. I’m not trying to restrict the Zig version number outside of for usage inside of Nix and nixpkgs.
What is the goal here for nix, what needs to be frozen and what not?
The idea is that the package directory layout in $HOME/.cache/zig/p needs to have some reasonable guarantee of bit-for-bit reproducibility for me to use the current method I am using in nix to fetch Zig dependencies. That’s it. The Zig version itself doesn’t need to be vendored or anything like that, just the dependencies themselves in a stable format.
And what is allowed to become obsolete/broken when things change (like a new package hash format, or other updates to Zig)?
As far as I know, the only thing that has substantially changed in this package directory layout to my knowledge is the format of the hash itself used to address packages by. This seems like acceptable breakage to me, due to the fact that it would presumably require a Zig version update, and Zig version updates would require rebuilding FODs, since those packages would break entirely and they would break in a way that is detectable.
Imagine the following scenario:
- Nix package
example depends on zig (an alias to zig_0_13)
zig package alias gets updated from zig_0_13 to zig_0_15 in nixpkgs, which requires the hash change
- Package
example now depends on zig_0_15, so in a rebuild, the package will be broken due to the old FOD with the old hashes still being used.
Now, the way to avoid this would be to necessitate the zig package version for a given package example be specified without using the zig package alias in nixpkgs, but I’m not sure if such a policy would be accepted or not.
If the hashes themselves were to not change (like I assume they would with a Zig 1.0 release), then this would not be a problem as far as I know, since no other changes have been made to the package directory’s layout since the package manager was released to my knowledge. My real question is if I should be concerned about any other changes to this package directory.
if it requires a lot of in-depth research, I can’t promise that I will spend huge amounts of time looking into it.
No worries, I appreciate your questions and time taken already :}