1{ lib
2, pkg-config
3, buildGoModule
4, fetchFromGitHub
5, makeWrapper
6, coreutils
7, gnupg
8, gnutar
9, squashfsTools
10, debootstrap
11, fetchpatch
12}:
13
14let
15 bins = [
16 coreutils
17 gnupg
18 gnutar
19 squashfsTools
20 debootstrap
21 ];
22in
23buildGoModule rec {
24 pname = "distrobuilder";
25 version = "2.1";
26
27 vendorHash = "sha256-yRMsf8KfpNmVUX4Rn4ZPLUPFZCT/g78MKAfgbFDPVkE=";
28
29 src = fetchFromGitHub {
30 owner = "lxc";
31 repo = "distrobuilder";
32 rev = "distrobuilder-${version}";
33 sha256 = "sha256-t3ECLtb0tvIzTWgjmVQDFza+kcm3abTZZMSGYjvw1qQ=";
34 fetchSubmodules = false;
35 };
36
37 buildInputs = bins;
38
39 patches = [
40 # go.mod update: needed to to include a newer lxd which contains
41 # https://github.com/canonical/lxd/commit/d83f061a21f509d42b7a334b97403d2a019a7b52
42 # which is needed to fix the build w/glibc-2.36.
43 (fetchpatch {
44 url = "https://github.com/lxc/distrobuilder/commit/5346bcc77dd7f141a36a8da851f016d0b929835e.patch";
45 sha256 = "sha256-H6cSbY0v/FThx72AvoAvUCs2VCYN/PQ0W4H82mQQ3SI=";
46 })
47 # Fixup to keep it building after go.mod update.
48 (fetchpatch {
49 url = "https://github.com/lxc/distrobuilder/commit/2c8cbfbf603e7446efce9f30812812336ccf4f2c.patch";
50 sha256 = "sha256-qqofghcHGosR2qycGb02c8rwErFyRRhsRKdQfyah8Ds=";
51 })
52 ];
53
54 # tests require a local keyserver (mkg20001/nixpkgs branch distrobuilder-with-tests) but gpg is currently broken in tests
55 doCheck = false;
56
57 nativeBuildInputs = [
58 pkg-config
59 makeWrapper
60 ] ++ bins;
61
62 postInstall = ''
63 wrapProgram $out/bin/distrobuilder --prefix PATH ":" ${lib.makeBinPath bins}
64 '';
65
66 meta = with lib; {
67 description = "System container image builder for LXC and LXD";
68 homepage = "https://github.com/lxc/distrobuilder";
69 license = licenses.asl20;
70 maintainers = with maintainers; [ megheaiulian ];
71 platforms = platforms.linux;
72 };
73}