mirror of
https://codeberg.org/muon/home.git
synced 2026-07-03 23:49:35 +00:00
Add vendor fetch
This commit is contained in:
parent
bf93912b39
commit
2d02ac206f
10 changed files with 360 additions and 46 deletions
55
pkgs/nvft/README.md
Normal file
55
pkgs/nvft/README.md
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# nvft (nvfetcher + tools)
|
||||
|
||||
A Nix package that combines nvfetcher source updates with automatic Go vendor hash calculation.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# 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:
|
||||
|
||||
```nix
|
||||
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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue