summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ab/abuild/package.nix
blob: d5eb80d3ccfab30cffdc9a925817461f27340a1b (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{
  lib,
  stdenv,
  fetchFromGitLab,
  gitUpdater,
  makeWrapper,
  pkg-config,
  file,
  scdoc,
  openssl,
  zlib,
  busybox,
  apk-tools,
  perl,
  findutils,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "abuild";
  version = "3.17.0";

  src = fetchFromGitLab {
    domain = "gitlab.alpinelinux.org";
    owner = "alpine";
    repo = "abuild";
    tag = finalAttrs.version;
    hash = "sha256-CiKOvYEidpykufpEwZLvLys97VRhpEabiVEJ6NJexb4=";
  };

  buildInputs = [
    openssl
    zlib
    busybox
    # for $out/bin/apkbuild-cpan and $out/bin/apkbuild-pypi
    (perl.withPackages (
      ps: with ps; [
        LWP
        JSON
        ModuleBuildTiny
        LWPProtocolHttps
        IPCSystemSimple
      ]
    ))
  ];

  nativeBuildInputs = [
    pkg-config
    scdoc
    makeWrapper
    file
    findutils
  ];

  patchPhase = ''
    substituteInPlace ./Makefile \
      --replace-fail 'chmod 4555' '#chmod 4555' \
      --replace-fail 'pkg-config' "$PKG_CONFIG"
  '';

  makeFlags = [
    "prefix=${placeholder "out"}"
    "CFLAGS=-Wno-error"
  ];

  installFlags = [
    "sysconfdir=${placeholder "out"}/etc"
  ];

  postInstall = ''
    # this script requires unpackaged 'augeas' rubygem, no reason
    # to ship it if we can't provide the dependencies for it
    rm -f ${placeholder "out"}/bin/apkbuild-gem-resolver

    # Find all executables that are not compiled binaries and wrap
    # them, make `apk-tools` available in their PATH and also the
    # $out directory since many of the binaries provided call into
    # other binaries
    for prog in \
      $(find ${placeholder "out"}/bin -type f -exec ${file}/bin/file -i '{}' + \
      | grep -v x-executable | cut -d : -f1); do
      wrapProgram $prog \
        --prefix PATH : "${lib.makeBinPath [ apk-tools ]}" \
        --prefix PATH : "${placeholder "out"}/bin"
    done
  '';

  passthru.updateScript = gitUpdater {
    ignoredVersions = "_rc";
  };

  meta = {
    description = "Alpine Linux build tools";
    homepage = "https://gitlab.alpinelinux.org/alpine/abuild";
    license = lib.licenses.gpl2Plus;
    maintainers = with lib.maintainers; [ onny ];
    platforms = lib.platforms.unix;
  };
})