flake/pkgs/nvft/README.md
2026-03-20 14:44:24 +00:00

1.6 KiB

nvft (nvfetcher + tools)

A Nix package that combines nvfetcher source updates with automatic Go vendor hash calculation.

Usage

# Enter the nix-shell (makes nvft available)
nix-shell

# Run the updater
nvft

This will:

  1. Save existing vendorHash and source hashes
  2. Run nvfetcher to update all source versions and hashes in _sources/generated.nix
  3. Restore saved vendorHash values
  4. Check if source hash changed - if yes, recalculate vendorHash; if no, skip (fast!)
  5. Update vendorHash in _sources/generated.nix only if needed

Configuration

Go packages that need vendor hash updates are configured in the GO_PACKAGES array within the script.

Currently configured packages:

  • mender-cli -> modules/home/terminal/hr/mender-cli.nix

To add more Go packages, edit pkgs/nvft/default.nix and add entries to the GO_PACKAGES array.

How it Works

For each Go package:

  1. Compares old vs new source hash to detect updates
  2. If source unchanged, keeps existing vendorHash (fast)
  3. If source changed, creates a temporary build with lib.fakeHash
  4. Attempts to build, which fails with the correct hash
  5. Extracts the correct hash from the error message
  6. Updates vendorHash directly in _sources/generated.nix alongside the source information

Package Usage

Go packages read vendorHash from the sources:

let
  src = sources.mender-cli;
in
buildGoModule {
  inherit (src) pname version src vendorHash;
  # ... rest of package
}

The vendorHash is stored in _sources/generated.nix alongside the version and source hash, keeping all auto-generated values in one place.