{"record":{"id":"30b91bd537cda9b8","repo":"gastownhall/beads","slug":"vendorhash-not-found-in-default-nix","errorCode":null,"errorMessage":"vendorHash not found in default.nix","messagePattern":"vendorHash not found in default\\.nix","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/preflight.go","lineNumber":767,"sourceCode":"\t\t)\n\t}\n\n\tnixPath := \"default.nix\"\n\tnixInfo, err := os.Stat(nixPath)\n\tif err != nil {\n\t\treturn false, \"\", \"\", fmt.Errorf(\"cannot stat default.nix: %v\", err)\n\t}\n\tnixPerm := nixInfo.Mode().Perm()\n\n\tcontent, err := os.ReadFile(nixPath)\n\tif err != nil {\n\t\treturn false, \"\", \"\", fmt.Errorf(\"cannot read default.nix: %v\", err)\n\t}\n\n\tre := regexp.MustCompile(`(vendorHash\\s*=\\s*)\"([^\"]+)\"`)\n\tloc := re.FindSubmatchIndex(content)\n\tif loc == nil {\n\t\treturn false, \"\", \"\", fmt.Errorf(\"vendorHash not found in default.nix\")\n\t}\n\toldHash := string(content[loc[4]:loc[5]])\n\n\tconst sentinel = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"\n\tprobed := append(append([]byte{}, content[:loc[4]]...), append([]byte(sentinel), content[loc[5]:]...)...)\n\tif err := os.WriteFile(nixPath, probed, nixPerm); err != nil {\n\t\treturn false, \"\", \"\", fmt.Errorf(\"cannot write default.nix: %v\", err)\n\t}\n\n\trestored := false\n\tdefer func() {\n\t\tif !restored {\n\t\t\t_ = os.WriteFile(nixPath, content, nixPerm)\n\t\t}\n\t}()\n\n\tctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\n\tdefer cancel()","sourceCodeStart":749,"sourceCodeEnd":785,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/preflight.go#L749-L785","documentation":"fixNixHash locates the vendorHash assignment using the regex `(vendorHash\\s*=\\s*)\"([^\"]+)\"`. If no match is found in default.nix, the automated repair cannot proceed and this error is returned. This catches default.nix files that don't set vendorHash, or spell it differently (e.g. `vendorSha256` used by older Nixpkgs, or `outputHash` in vendored derivations).","triggerScenarios":"Running `bd fix` against a default.nix that lacks a `vendorHash = \"...\"` assignment, uses an attribute name other than vendorHash, formats it so the value is not a simple quoted string, or contains only commented-out vendorHash.","commonSituations":"Projects using the older `vendorSha256` attribute name from pre-23.05 nixpkgs; a mkGoModule/mkVendor derivation using `overrideAttrs` style hashes; hand-edited default.nix that dropped the vendorHash line.","solutions":["Open default.nix and ensure it contains `vendorHash = \"sha256-...\";` inside buildGoModule — add or rename the attribute (e.g. change vendorSha256 to vendorHash if on a modern nixpkgs)","Then re-run `bd fix` so the automated hash repair can find and update it","If your derivation intentionally doesn't vendor Go modules, skip the nix fix entirely (the file legitimately has no vendorHash)"],"exampleFix":"// before (default.nix)\nvendorSha256 = \"sha256-old==\";\n// after\nvendorHash = \"sha256-old==\";","handlingStrategy":"validation","validationCode":"grep -qE 'vendorHash\\s*=\\s*\"[^\"]+\"' default.nix || { echo \"default.nix lacks a vendorHash assignment\"; exit 1; }","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"bd\", \"fix\").CombinedOutput()\nif err != nil && strings.Contains(string(out), \"vendorHash not found in default.nix\") {\n    // add/rename the vendorHash attribute in default.nix, then retry\n}","preventionTips":["Keep the attribute named vendorHash (modern nixpkgs), not vendorSha256","Always keep vendorHash present with a real or sentinel sha256 value in buildGoModule","Lint default.nix in CI to assert the vendorHash line exists"],"tags":["nix","regex","parsing","build","vendorhash"],"backgroundTag":"expected-field-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}