about summary refs log tree commit diff
path: root/nix/fetchGoModule/default.nix
blob: e49a5e3a1c5ee796a0bd5cf4e9d6f7e7b623a92a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 ];
})