1{ lib
2, stdenv
3, fetchFromGitLab
4, makeWrapper
5, pkg-config
6, file
7, scdoc
8, openssl
9, zlib
10, busybox
11, apk-tools
12, perl
13}:
14
15stdenv.mkDerivation rec {
16 pname = "abuild";
17 version = "3.11.1";
18
19 src = fetchFromGitLab {
20 domain = "gitlab.alpinelinux.org";
21 owner = "alpine";
22 repo = pname;
23 rev = version;
24 sha256 = "sha256-hxk3EsoY6qvHsIyNv2qbttWYAvn0qNojSi8Y3pXl/p4=";
25 };
26
27 buildInputs = [
28 openssl
29 zlib
30 busybox
31 # for $out/bin/apkbuild-cpan and $out/bin/apkbuild-pypi
32 (perl.withPackages (ps: with ps; [
33 LWP
34 JSON
35 ModuleBuildTiny
36 LWPProtocolHttps
37 IPCSystemSimple
38 ]))
39 ];
40
41 nativeBuildInputs = [
42 pkg-config
43 scdoc
44 makeWrapper
45 file
46 ];
47
48 patchPhase = ''
49 substituteInPlace ./Makefile \
50 --replace 'chmod 4555' '#chmod 4555'
51 '';
52
53 makeFlags = [
54 "prefix=${placeholder "out"}"
55 "CFLAGS=-Wno-error"
56 ];
57
58 installFlags = [
59 "sysconfdir=${placeholder "out"}/etc"
60 ];
61
62 postInstall = ''
63 # this script requires unpackaged 'augeas' rubygem, no reason
64 # to ship it if we can't provide the dependencies for it
65 rm -f ${placeholder "out"}/bin/apkbuild-gem-resolver
66
67 # Find all executables that are not compiled binaries and wrap
68 # them, make `apk-tools` available in their PATH and also the
69 # $out directory since many of the binaries provided call into
70 # other binaries
71 for prog in \
72 $(find ${placeholder "out"}/bin -type f -exec ${file}/bin/file -i '{}' + \
73 | grep -v x-executable | cut -d : -f1); do
74 wrapProgram $prog \
75 --prefix PATH : "${lib.makeBinPath [ apk-tools ]}" \
76 --prefix PATH : "${placeholder "out"}/bin"
77 done
78 '';
79
80 meta = with lib; {
81 description = "Alpine Linux build tools";
82 homepage = "https://gitlab.alpinelinux.org/alpine/abuild";
83 license = licenses.gpl2Plus;
84 maintainers = with maintainers; [ onny ];
85 platforms = platforms.unix;
86 };
87
88}