about summary refs log tree commit diff
path: root/pkgs/tools/package-management/nix/nix-perl.nix
blob: 8fc2657657afb2929b55fd6788908b04c9ab5a99 (plain) (blame)
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
{ stdenv
, lib
, perl
, pkg-config
, curl
, nix
, libsodium
, boost
, autoreconfHook
, autoconf-archive
, nlohmann_json
, xz
, Security
, meson
, ninja
, bzip2
}:

let
  atLeast223 = lib.versionAtLeast nix.version "2.23";

  mkConfigureOption = { mesonOption, autoconfOption, value }:
    let
      setFlagTo = if atLeast223
        then lib.mesonOption mesonOption
        else lib.withFeatureAs true autoconfOption;
    in
    setFlagTo value;
in stdenv.mkDerivation (finalAttrs: {
  pname = "nix-perl";
  inherit (nix) version src;

  postUnpack = "sourceRoot=$sourceRoot/perl";

  buildInputs = [
    boost
    bzip2
    curl
    libsodium
    nix
    perl
    xz
  ] ++ lib.optional (stdenv.isDarwin) Security;

  # Not cross-safe since Nix checks for curl/perl via
  # NEED_PROG/find_program, but both seem to be needed at runtime
  # as well.
  nativeBuildInputs = [
    pkg-config
    perl
    curl
  ] ++ (if atLeast223 then [
    meson
    ninja
  ] else [
    autoconf-archive
    autoreconfHook
  ]);

  # `perlPackages.Test2Harness` is marked broken for Darwin
  doCheck = !stdenv.isDarwin;

  nativeCheckInputs = [
    perl.pkgs.Test2Harness
  ];

  ${if atLeast223 then "mesonFlags" else "configureFlags"} = [
    (mkConfigureOption {
      mesonOption = "dbi_path";
      autoconfOption = "dbi";
      value = "${perl.pkgs.DBI}/${perl.libPrefix}";
    })
    (mkConfigureOption {
      mesonOption = "dbd_sqlite_path";
      autoconfOption = "dbd-sqlite";
      value = "${perl.pkgs.DBDSQLite}/${perl.libPrefix}";
    })
  ] ++ lib.optionals atLeast223 [
    (lib.mesonEnable "tests" finalAttrs.doCheck)
  ];

  preConfigure = "export NIX_STATE_DIR=$TMPDIR";
})