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