So there’s Restrict fixed-output derivations · Issue #2270 · NixOS/nix · GitHub, and Recommend buildGoPackage instead of buildGoModule in the nixpkgs manual · Issue #84826 · NixOS/nixpkgs · GitHub which suggest that it was a bad decision to design buildGoModule
and rustPlatform.buildRustPackages
as they are today. I’m not sure I deeply understand the core issue of Restrict fixed-output derivations · Issue #2270 · NixOS/nix · GitHub, but I understand that if we could only go back in time and avoid fixed output derivations for sources, we’d satisfy edolstra.
It’s commonly known, that the alternative to buildGoModule
is buildGoPackage
which doesn’t produce fixed output derivations but people don’t like to use it because it requires adding a deps.nix
that is large in size and it’s not comfortable to update it.
I have an idea but I wonder if it’s too wild: Rewrite buildGoModule
so it will parse (in Nix) go.sum
from ${src}
and make it construct the fetchurl
or fetchgit
calls that will satisfy the check sums found there. Emulating Go’s hash calculation in Nix wouldn’t be easy (these are not exactly plain sha256), but I’ve found this project GitHub - vikyd/go-checksum: Simple tool to calc Golang module checksum of go.mod and module dir. which claims it has implemented this, in Go.
As for rewriting buildRustPackage
in a similar manner, it seems there’s a somewhat complete Nix “Parser” and hashes calculator - https://github.com/nmattia/naersk/blob/a82fd7dc31a58c462b6dfa9d9d886fa2cc75dfd4/build.nix .
Is it possible to read a file found in ${src}
and do pure Nix stuff based on it’s contents?