summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/im/img/package.nix
blob: 53db507a424a670229ce92d8a51fddd53bec50c7 (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
53
54
55
56
57
{
  buildGoModule,
  fetchFromGitHub,
  lib,
  makeWrapper,
  runc,
  wrapperDir ? "/run/wrappers/bin", # Default for NixOS, other systems might need customization.
}:

buildGoModule (finalAttrs: {
  pname = "img";
  version = "0.5.11";

  src = fetchFromGitHub {
    owner = "genuinetools";
    repo = "img";
    rev = "v${finalAttrs.version}";
    sha256 = "0r5hihzp2679ki9hr3p0f085rafy2hc8kpkdhnd4m5k4iibqib08";
  };

  vendorHash = null;

  postPatch = ''
    V={newgidmap,newgidmap} \
      substituteInPlace ./internal/unshare/unshare.c \
        --replace "/usr/bin/$V" "${wrapperDir}/$V"
  '';

  nativeBuildInputs = [
    makeWrapper
  ];

  tags = [
    "seccomp"
    "noembed" # disables embedded `runc`
  ];

  ldflags = [
    "-X github.com/genuinetools/img/version.VERSION=v${finalAttrs.version}"
    "-s -w"
  ];

  postInstall = ''
    wrapProgram "$out/bin/img" --prefix PATH : ${lib.makeBinPath [ runc ]}
  '';

  # Tests fail as: internal/binutils/install.go:57:15: undefined: Asset
  doCheck = false;

  meta = {
    description = "Standalone, daemon-less, unprivileged Dockerfile and OCI compatible container image builder";
    mainProgram = "img";
    license = lib.licenses.mit;
    homepage = "https://github.com/genuinetools/img";
    maintainers = [ ];
  };
})