1c96e14174
unzip(1) doesn't care about the extension, unlike the unpackFile hook. Change-Id: Ia9d0e17c4b343ee5d32350329eb6267b9dc35605 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1641 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com> Reviewed-by: tazjin <mail@tazj.in>
32 lines
564 B
Nix
32 lines
564 B
Nix
{ lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib)
|
|
lowerChars
|
|
replaceStrings
|
|
upperChars
|
|
;
|
|
|
|
caseFold = replaceStrings upperChars (map (c: "!" + c) lowerChars);
|
|
|
|
in
|
|
|
|
{ path, version, sha256 }:
|
|
|
|
pkgs.fetchurl {
|
|
name = "source";
|
|
url = "https://proxy.golang.org/${caseFold path}/@v/v${version}.zip";
|
|
inherit sha256;
|
|
|
|
recursiveHash = true;
|
|
downloadToTemp = true;
|
|
|
|
postFetch = ''
|
|
unpackDir="$TMPDIR/unpack"
|
|
mkdir "$unpackDir"
|
|
|
|
${pkgs.unzip}/bin/unzip "$downloadedFile" -d "$unpackDir"
|
|
mv "$unpackDir/${path}@v${version}" "$out"
|
|
'';
|
|
}
|