Integrate perl with the other meson builds

One big dev shell!
This commit is contained in:
John Ericson 2024-06-04 18:10:25 -04:00
parent e0b4691754
commit a83d95e26e
20 changed files with 52 additions and 27 deletions

View File

@ -192,14 +192,14 @@
libgit2 = final.libgit2-nix;
libseccomp = final.libseccomp-nix;
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell;
} // {
# this is a proper separate downstream package, but put
# here also for back compat reasons.
perl-bindings = final.nix-perl-bindings;
};
nix-perl-bindings = final.callPackage ./perl {
inherit fileset stdenv;
nix-perl-bindings = final.callPackage ./src/perl/package.nix {
inherit
fileset
stdenv
versionSuffix
;
};
# See https://github.com/NixOS/nixpkgs/pull/214409
@ -213,7 +213,7 @@
in {
# A Nixpkgs overlay that overrides the 'nix' and
# 'nix.perl-bindings' packages.
# 'nix-perl-bindings' packages.
overlays.default = overlayFor (p: p.stdenv);
hydraJobs = import ./maintainers/hydra.nix {
@ -245,7 +245,11 @@
# Some perl dependencies are broken on i686-linux.
# Since the support is only best-effort there, disable the perl
# bindings
perlBindings = self.hydraJobs.perlBindings.${system};
# Temporarily disabled because GitHub Actions OOM issues. Once
# the old build system is gone and we are back to one build
# system, we should reenable this.
#perlBindings = self.hydraJobs.perlBindings.${system};
} // devFlake.checks.${system} or {}
);
@ -297,6 +301,13 @@
makeShell = pkgs: stdenv: (pkgs.nix.override { inherit stdenv; forDevShell = true; }).overrideAttrs (attrs:
let
modular = devFlake.getSystem stdenv.buildPlatform.system;
transformFlag = prefix: flag:
assert builtins.isString flag;
let
rest = builtins.substring 2 (builtins.stringLength flag) flag;
in
"-D${prefix}:${rest}";
havePerl = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform.isUnix;
in {
pname = "shell-for-" + attrs.pname;
@ -327,11 +338,16 @@
"${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml" modular.pre-commit.settings.rawConfig}";
};
mesonFlags = pkgs.nix-util.mesonFlags ++ pkgs.nix-store.mesonFlags;
mesonFlags =
map (transformFlag "libutil") pkgs.nix-util.mesonFlags
++ map (transformFlag "libstore") pkgs.nix-store.mesonFlags
++ lib.optionals havePerl (map (transformFlag "perl") pkgs.nix-perl-bindings.mesonFlags)
;
nativeBuildInputs = attrs.nativeBuildInputs or []
++ pkgs.nix-util.nativeBuildInputs
++ pkgs.nix-store.nativeBuildInputs
++ lib.optionals havePerl pkgs.nix-perl-bindings.nativeBuildInputs
++ [
modular.pre-commit.settings.package
(pkgs.writeScriptBin "pre-commit-hooks-install"
@ -341,6 +357,10 @@
# https://github.com/NixOS/nixpkgs/pull/291814 is available
++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) pkgs.buildPackages.bear
++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) pkgs.buildPackages.clang-tools;
buildInputs = attrs.buildInputs or []
++ lib.optional havePerl pkgs.perl
;
});
in
forAllSystems (system:

View File

@ -75,7 +75,7 @@ in
);
# Perl bindings for various platforms.
perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nix.perl-bindings);
perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nix-perl-bindings);
# Binary tarball for various platforms, containing a Nix store
# with the closure of 'nix' package, and the second half of

View File

@ -8,3 +8,4 @@ project('nix-dev-shell', 'cpp',
subproject('libutil')
subproject('libstore')
subproject('perl')

View File

@ -180,7 +180,7 @@ in {
./doc
./misc
./precompiled-headers.h
./src
(fileset.difference ./src ./src/perl)
./COPYING
./scripts/local.mk
] ++ lib.optionals buildUnitTests [
@ -192,7 +192,7 @@ in {
] ++ lib.optionals (enableInternalAPIDocs || enableExternalAPIDocs) [
# Source might not be compiled, but still must be available
# for Doxygen to gather comments.
./src
(fileset.difference ./src ./src/perl)
./tests/unit
] ++ lib.optionals buildUnitTests [
./tests/unit

1
src/perl/.version Symbolic link
View File

@ -0,0 +1 @@
../../.version

View File

@ -1,4 +1,5 @@
#include "nix/config.h"
#include "config-util.h"
#include "config-store.h"
#include "EXTERN.h"
#include "perl.h"

View File

@ -7,17 +7,17 @@
project (
'nix-perl',
'cpp',
meson_version : '>= 0.64.0',
version : files('.version'),
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
# setup env
#-------------------------------------------------
fs = import('fs')
nix_version = get_option('version')
cpp = meson.get_compiler('cpp')
nix_perl_conf = configuration_data()
nix_perl_conf.set('PACKAGE_VERSION', nix_version)
nix_perl_conf.set('PACKAGE_VERSION', meson.project_version())
# set error arguments
@ -64,7 +64,7 @@ yath = find_program('yath', required : false)
bzip2_dep = dependency('bzip2')
curl_dep = dependency('libcurl')
libsodium_dep = dependency('libsodium')
# nix_util_dep = dependency('nix-util')
nix_store_dep = dependency('nix-store')

View File

@ -5,11 +5,6 @@
# compiler args
#============================================================================
option(
'version',
type : 'string',
description : 'nix-perl version')
option(
'tests',
type : 'feature',

View File

@ -6,17 +6,19 @@
, meson
, ninja
, pkg-config
, nix
, nix-store
, curl
, bzip2
, xz
, boost
, libsodium
, darwin
, versionSuffix ? ""
}:
perl.pkgs.toPerlModule (stdenv.mkDerivation (finalAttrs: {
name = "nix-perl-${nix.version}";
pname = "nix-perl";
version = lib.fileContents ./.version + versionSuffix;
src = fileset.toSource {
root = ./.;
@ -24,7 +26,7 @@ perl.pkgs.toPerlModule (stdenv.mkDerivation (finalAttrs: {
./MANIFEST
./lib
./meson.build
./meson_options.txt
./meson.options
] ++ lib.optionals finalAttrs.doCheck [
./.yath.rc.in
./t
@ -38,7 +40,7 @@ perl.pkgs.toPerlModule (stdenv.mkDerivation (finalAttrs: {
];
buildInputs = [
nix
nix-store
curl
bzip2
xz
@ -55,8 +57,13 @@ perl.pkgs.toPerlModule (stdenv.mkDerivation (finalAttrs: {
perlPackages.Test2Harness
];
preConfigure =
# "Inline" .version so its not a symlink, and includes the suffix
''
echo ${finalAttrs.version} > .version
'';
mesonFlags = [
(lib.mesonOption "version" (builtins.readFile ../.version))
(lib.mesonOption "dbi_path" "${perlPackages.DBI}/${perl.libPrefix}")
(lib.mesonOption "dbd_sqlite_path" "${perlPackages.DBDSQLite}/${perl.libPrefix}")
(lib.mesonEnable "tests" finalAttrs.doCheck)