I’m trying to understand how vendorSha256 is being generated.
For example, let’s assume I want to write this nix expression from scratch:
{ lib, buildGoModule, fetchFromGitHub }:
buildGoModule rec {
pname = "oapi-codegen";
version = "1.6.0";
src = fetchFromGitHub {
owner = "deepmap";
repo = pname;
rev = "v${version}";
sha256 = "sha256-doJ1ceuJ/gL9vlGgV/hKIJeAErAseH0dtHKJX2z7pV0=";
};
vendorSha256 = "sha256-Y4WM+o+5jiwj8/99UyNHLpBNbtJkKteIGW2P1Jd9L6M=";
# Tests use network
doCheck = false;
meta = with lib; {
description = "Go client and server OpenAPI 3 generator";
homepage = "https://github.com/deepmap/oapi-codegen";
license = licenses.asl20;
maintainers = [ maintainers.j4m3s ];
};
}
I managed to find sha256
value by downloading the source from github, unzip it, and then ran on the extracted oapi-codegen-1.6.0
directory:
nix hash path --base64 --type sha256 oapi-codegen-1.6.0
But I couldn’t find how to get the value of vendorSha256. From nixpkgs manual I get this info:
-
vendorSha256
: is the hash of the output of the intermediate fetcher derivation.vendorSha256
can also takenull
as an input. Whennull
is used as a value, rather than fetching the dependencies and vendoring them, we use the vendoring included within the source repo. If you’d like to not have to update this field on dependency changes, rungo mod vendor
in your source repo and setvendorSha256 = null;
When I run:
nix-build -E 'with import <nixpkgs> { }; callPackage ./myCustomExpression.nix { }'
I see the first lines of output as:
these 2 derivations will be built:
/nix/store/j13s3dvlwz5w9xl5wbhkcs7lrkgksv3l-oapi-codegen-1.6.0-go-modules.drv
/nix/store/4wyj1d9f2m0521nlkjgr6al0wfz12yjn-oapi-codegen-1.6.0.drv
So I guess the intermediate fetcher derivation is j13s3dvlwz5w9xl5wbhkcs7lrkgksv3l-oapi-codegen-1.6.0-go-modules.drv
. This derivation will be used to fetch all of the dependencies of the Go module as I read in the manual.
But how can I know the hash of this itermediate fetcher derivation if at the time I’m writing my Nix expression I haven’t built it yet? There must be a way since the guys contributing to nixpkgs know how to add it, but I cannot manage to figure it out.
Thanks in advance!