about summary refs log tree commit diff
path: root/users
diff options
context:
space:
mode:
authoredef <edef@edef.eu>2020-08-03T02·06+0000
committeredef <edef@edef.eu>2020-08-03T08·18+0000
commit2ab7561ac9f5cc58cad84137bd64c4e330c888c7 (patch)
tree26da7bc22adee8d045b0a382b30393256f479f90 /users
parent4a7b7e35b2c7d30db520dd422b75632e22424b6c (diff)
feat(edef/fetchGoModule): init r/1555
Change-Id: I160a4264b9ade35d7cfcc1609ab395eab164d4d8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1586
Tested-by: BuildkiteCI
Reviewed-by: lukegb <lukegb@tvl.fyi>
Diffstat (limited to 'users')
-rw-r--r--users/edef/fetchGoModule.nix24
1 files changed, 24 insertions, 0 deletions
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 ];
+})