From 2ab7561ac9f5cc58cad84137bd64c4e330c888c7 Mon Sep 17 00:00:00 2001 From: edef Date: Mon, 3 Aug 2020 02:06:11 +0000 Subject: feat(edef/fetchGoModule): init Change-Id: I160a4264b9ade35d7cfcc1609ab395eab164d4d8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1586 Tested-by: BuildkiteCI Reviewed-by: lukegb --- users/edef/fetchGoModule.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 users/edef/fetchGoModule.nix (limited to 'users/edef') diff --git a/users/edef/fetchGoModule.nix b/users/edef/fetchGoModule.nix new file mode 100644 index 000000000000..e49a5e3a1c5e --- /dev/null +++ b/users/edef/fetchGoModule.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: + +{ path, version, sha256 }: + +(pkgs.fetchurl { + name = "source"; + url = "https://proxy.golang.org/${path}/@v/v${version}.zip"; + inherit sha256; + + recursiveHash = true; + downloadToTemp = true; + + postFetch = '' + unpackDir="$TMPDIR/unpack" + mkdir "$unpackDir" + cd "$unpackDir" + + mv "$downloadedFile" "$TMPDIR/src.zip" + unpackFile "$TMPDIR/src.zip" + mv "$unpackDir/${path}@v${version}" "$out" + ''; +}).overrideAttrs ({ nativeBuildInputs ? [], ... }: { + nativeBuildInputs = nativeBuildInputs ++ [ pkgs.unzip ]; +}) -- cgit 1.4.1