1{ buildGoModule
2, fetchFromGitHub
3, lib
4, makeWrapper
5, runc
6, wrapperDir ? "/run/wrappers/bin" # Default for NixOS, other systems might need customization.
7}:
8
9buildGoModule rec {
10 pname = "img";
11 version = "0.5.11";
12
13 src = fetchFromGitHub {
14 owner = "genuinetools";
15 repo = "img";
16 rev = "v${version}";
17 sha256 = "0r5hihzp2679ki9hr3p0f085rafy2hc8kpkdhnd4m5k4iibqib08";
18 };
19
20 vendorSha256 = null;
21
22 postPatch = ''
23 V={newgidmap,newgidmap} \
24 substituteInPlace ./internal/unshare/unshare.c \
25 --replace "/usr/bin/$V" "${wrapperDir}/$V"
26 '';
27
28 nativeBuildInputs = [
29 makeWrapper
30 ];
31
32 tags = [
33 "seccomp"
34 "noembed" # disables embedded `runc`
35 ];
36
37 ldflags = [
38 "-X github.com/genuinetools/img/version.VERSION=v${version}"
39 "-s -w"
40 ];
41
42 postInstall = ''
43 wrapProgram "$out/bin/img" --prefix PATH : ${lib.makeBinPath [ runc ]}
44 '';
45
46 # Tests fail as: internal/binutils/install.go:57:15: undefined: Asset
47 doCheck = false;
48
49 meta = with lib; {
50 description = "Standalone, daemon-less, unprivileged Dockerfile and OCI compatible container image builder. ";
51 license = licenses.mit;
52 homepage = "https://github.com/genuinetools/img";
53 maintainers = with maintainers; [ bryanasdev000 ];
54 };
55}