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; libgit2 = final.libgit2-nix;
libseccomp = final.libseccomp-nix; libseccomp = final.libseccomp-nix;
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell; 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 { nix-perl-bindings = final.callPackage ./src/perl/package.nix {
inherit fileset stdenv; inherit
fileset
stdenv
versionSuffix
;
}; };
# See https://github.com/NixOS/nixpkgs/pull/214409 # See https://github.com/NixOS/nixpkgs/pull/214409
@ -213,7 +213,7 @@
in { in {
# A Nixpkgs overlay that overrides the 'nix' and # A Nixpkgs overlay that overrides the 'nix' and
# 'nix.perl-bindings' packages. # 'nix-perl-bindings' packages.
overlays.default = overlayFor (p: p.stdenv); overlays.default = overlayFor (p: p.stdenv);
hydraJobs = import ./maintainers/hydra.nix { hydraJobs = import ./maintainers/hydra.nix {
@ -245,7 +245,11 @@
# Some perl dependencies are broken on i686-linux. # Some perl dependencies are broken on i686-linux.
# Since the support is only best-effort there, disable the perl # Since the support is only best-effort there, disable the perl
# bindings # 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 {} } // devFlake.checks.${system} or {}
); );
@ -297,6 +301,13 @@
makeShell = pkgs: stdenv: (pkgs.nix.override { inherit stdenv; forDevShell = true; }).overrideAttrs (attrs: makeShell = pkgs: stdenv: (pkgs.nix.override { inherit stdenv; forDevShell = true; }).overrideAttrs (attrs:
let let
modular = devFlake.getSystem stdenv.buildPlatform.system; 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 { in {
pname = "shell-for-" + attrs.pname; pname = "shell-for-" + attrs.pname;
@ -327,11 +338,16 @@
"${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml" modular.pre-commit.settings.rawConfig}"; "${(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 [] nativeBuildInputs = attrs.nativeBuildInputs or []
++ pkgs.nix-util.nativeBuildInputs ++ pkgs.nix-util.nativeBuildInputs
++ pkgs.nix-store.nativeBuildInputs ++ pkgs.nix-store.nativeBuildInputs
++ lib.optionals havePerl pkgs.nix-perl-bindings.nativeBuildInputs
++ [ ++ [
modular.pre-commit.settings.package modular.pre-commit.settings.package
(pkgs.writeScriptBin "pre-commit-hooks-install" (pkgs.writeScriptBin "pre-commit-hooks-install"
@ -341,6 +357,10 @@
# https://github.com/NixOS/nixpkgs/pull/291814 is available # 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.buildPlatform.isDarwin) pkgs.buildPackages.bear
++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) pkgs.buildPackages.clang-tools; ++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) pkgs.buildPackages.clang-tools;
buildInputs = attrs.buildInputs or []
++ lib.optional havePerl pkgs.perl
;
}); });
in in
forAllSystems (system: forAllSystems (system:

View File

@ -75,7 +75,7 @@ in
); );
# Perl bindings for various platforms. # 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 # Binary tarball for various platforms, containing a Nix store
# with the closure of 'nix' package, and the second half of # 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('libutil')
subproject('libstore') subproject('libstore')
subproject('perl')

View File

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

View File

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

View File

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

View File

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