19 atLeast223 = lib.versionAtLeast nix.version "2.23";
20 atLeast224 = lib.versionAtLeast nix.version "2.24";
22 mkConfigureOption = { mesonOption, autoconfOption, value }:
24 setFlagTo = if atLeast223
25 then lib.mesonOption mesonOption
26 else lib.withFeatureAs true autoconfOption;
29 in stdenv.mkDerivation (finalAttrs: {
31 inherit (nix) version src;
33 postUnpack = "sourceRoot=$sourceRoot/${lib.optionalString atLeast224 "src"}/perl";
35 # TODO: Remove this once the nix build also uses meson
36 postPatch = lib.optionalString atLeast224 ''
37 substituteInPlace lib/Nix/Store.xs \
38 --replace-fail 'config-util.hh' 'nix/config.h' \
39 --replace-fail 'config-store.hh' 'nix/config.h'
50 ] ++ lib.optional (stdenv.hostPlatform.isDarwin) Security;
52 # Not cross-safe since Nix checks for curl/perl via
53 # NEED_PROG/find_program, but both seem to be needed at runtime
59 ] ++ (if atLeast223 then [
67 # `perlPackages.Test2Harness` is marked broken for Darwin
68 doCheck = !stdenv.hostPlatform.isDarwin;
71 perl.pkgs.Test2Harness
74 ${if atLeast223 then "mesonFlags" else "configureFlags"} = [
76 mesonOption = "dbi_path";
77 autoconfOption = "dbi";
78 value = "${perl.pkgs.DBI}/${perl.libPrefix}";
81 mesonOption = "dbd_sqlite_path";
82 autoconfOption = "dbd-sqlite";
83 value = "${perl.pkgs.DBDSQLite}/${perl.libPrefix}";
85 ] ++ lib.optionals atLeast223 [
86 (lib.mesonEnable "tests" finalAttrs.finalPackage.doCheck)
89 preConfigure = "export NIX_STATE_DIR=$TMPDIR";
91 passthru = { inherit perl; };