github.com/replit/upm@v0.0.0-20240423230255-9ce4fc3ea24c/nix/upm/default.nix (about) 1 { 2 buildGoModule, 3 rev, 4 makeWrapper, 5 buildGoCache, 6 lib, 7 runCommand, 8 }: 9 let 10 vendorHash = "sha256-MJkcj2AR8DDQWNZaoMWxDvGHt6SwAMS4xcrjh075Uio="; 11 12 goCache = buildGoCache { 13 # keep this up-to-date in CI with: 14 # $ nix run 'github:numtide/build-go-cache#get-external-imports' -- ./. imported-packages 15 importPackagesFile = ./imported-packages; 16 # FIXME: Somehow we get cache invalidation everytime if we don't do this, also it uses a source filter 17 src = runCommand "go-mod" {} '' 18 install -D ${../../go.mod} $out/go.mod 19 install -D ${../../go.sum} $out/go.sum 20 ''; 21 inherit vendorHash; 22 }; 23 in 24 buildGoModule rec { 25 pname = "upm"; 26 version = rev; 27 src = builtins.path { 28 name = "${pname}-src"; 29 path = ../../.; 30 filter = path: _: 31 builtins.all (block: (builtins.baseNameOf path) != block) [ 32 ".github" 33 ".semaphore" 34 "packaging" 35 "scripts" 36 "test-suite" 37 ".goreleaser.yml" 38 ".replit" 39 "replit.nix" 40 ]; 41 }; 42 43 ldflags = [ 44 "-X github.com/replit/upm/internal/cli.version=${rev}" 45 ]; 46 47 preBuild = '' 48 go generate ./internal/backends/python 49 ''; 50 51 buildInputs = [makeWrapper goCache]; 52 53 subPackages = ["cmd/upm"]; 54 55 postInstall = '' 56 make internal/backends/python/pypi_map.sqlite 57 mv internal/backends/python/pypi_map.sqlite $out/ 58 59 wrapProgram $out/bin/upm \ 60 --set PYPI_MAP_DB "$out/pypi_map.sqlite" 61 ''; 62 63 inherit vendorHash; 64 proxyVendor = true; # we only support proxyVendor with buildGoCache just now 65 66 doCheck = false; 67 }