about summary refs log tree commit diff
path: root/nix/fetchGoModule
diff options
context:
space:
mode:
authoredef <edef@edef.eu>2020-08-03T10·20+0000
committeredef <edef@edef.eu>2020-08-03T10·29+0000
commit8d6fcbe1a5e4791d81d2a83b89407f8d2d4d8362 (patch)
treedf9f4eda4e5027b9670fecf34bcf16f2baecd65e /nix/fetchGoModule
parent6b181d314f81fbff46df988618a89792b8219cbc (diff)
chore(nix/fetchGoModule): Move //users/edef/fetchGoModule to //nix r/1559
Change-Id: Ie7f52367ef91c0c8017a36c2a6c7edb06f10e57d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1589
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'nix/fetchGoModule')
-rw-r--r--nix/fetchGoModule/OWNERS2
-rw-r--r--nix/fetchGoModule/default.nix24
2 files changed, 26 insertions, 0 deletions
diff --git a/nix/fetchGoModule/OWNERS b/nix/fetchGoModule/OWNERS
new file mode 100644
index 0000000000..47b6a04183
--- /dev/null
+++ b/nix/fetchGoModule/OWNERS
@@ -0,0 +1,2 @@
+owners:
+  - edef
diff --git a/nix/fetchGoModule/default.nix b/nix/fetchGoModule/default.nix
new file mode 100644
index 0000000000..e49a5e3a1c
--- /dev/null
+++ b/nix/fetchGoModule/default.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 ];
+})