summaryrefslogtreecommitdiffstats
path: root/pkgs/build-support/docker/tarsum.nix
blob: 8f169d0b1e880bf2d641d370a3e47084a53a2b6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
  stdenv,
  go,
  docker,
  nixosTests,
}:

stdenv.mkDerivation {
  pname = "tarsum";
  inherit (docker) version;

  nativeBuildInputs = [ go ];
  disallowedReferences = [ go ];

  dontUnpack = true;

  env = {
    CGO_ENABLED = 0;
    GOFLAGS = "-trimpath";
    GO111MODULE = "off";
  };

  buildPhase = ''
    runHook preBuild
    mkdir tarsum
    cd tarsum
    cp ${./tarsum.go} tarsum.go
    export GOPATH=$(pwd)
    export GOCACHE="$TMPDIR/go-cache"
    mkdir -p src/github.com/docker/docker/daemon/builder/remotecontext
    # We need to drop the internal as otherwise go refuses to use it.
    ln -sT ${docker.moby-src}/daemon/builder/remotecontext/internal/tarsum src/github.com/docker/docker/daemon/builder/remotecontext/tarsum
    go build
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall
    mkdir -p $out/bin
    cp tarsum $out/bin/
    runHook postInstall
  '';

  passthru = {
    tests = {
      dockerTools = nixosTests.docker-tools;
    };
  };

  meta.platforms = go.meta.platforms;
  meta.mainProgram = "tarsum";
}