tvl-depot/nix/fetchGoModule/default.nix
edef 1c96e14174 chore(nix/fetchGoModule): don't move downloaded file
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>
2020-08-04 22:51:51 +00:00

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"
'';
}