From a83d95e26ebdbe996a9cafc106538e5ada283fe5 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 4 Jun 2024 18:10:25 -0400 Subject: [PATCH] Integrate perl with the other meson builds One big dev shell! --- flake.nix | 38 ++++++++++++++----- maintainers/hydra.nix | 2 +- meson.build | 1 + package.nix | 4 +- src/perl/.version | 1 + {perl => src/perl}/.yath.rc.in | 0 {perl => src/perl}/MANIFEST | 0 {perl => src/perl}/lib/Nix/Config.pm.in | 0 {perl => src/perl}/lib/Nix/CopyClosure.pm | 0 {perl => src/perl}/lib/Nix/Manifest.pm | 0 {perl => src/perl}/lib/Nix/SSH.pm | 0 {perl => src/perl}/lib/Nix/Store.pm | 0 {perl => src/perl}/lib/Nix/Store.xs | 3 +- {perl => src/perl}/lib/Nix/Utils.pm | 0 {perl => src/perl}/lib/Nix/meson.build | 0 {perl => src/perl}/meson.build | 8 ++-- .../perl/meson.options | 5 --- perl/default.nix => src/perl/package.nix | 17 ++++++--- {perl => src/perl}/t/init.t | 0 {perl => src/perl}/t/meson.build | 0 20 files changed, 52 insertions(+), 27 deletions(-) create mode 120000 src/perl/.version rename {perl => src/perl}/.yath.rc.in (100%) rename {perl => src/perl}/MANIFEST (100%) rename {perl => src/perl}/lib/Nix/Config.pm.in (100%) rename {perl => src/perl}/lib/Nix/CopyClosure.pm (100%) rename {perl => src/perl}/lib/Nix/Manifest.pm (100%) rename {perl => src/perl}/lib/Nix/SSH.pm (100%) rename {perl => src/perl}/lib/Nix/Store.pm (100%) rename {perl => src/perl}/lib/Nix/Store.xs (99%) rename {perl => src/perl}/lib/Nix/Utils.pm (100%) rename {perl => src/perl}/lib/Nix/meson.build (100%) rename {perl => src/perl}/meson.build (96%) rename perl/meson_options.txt => src/perl/meson.options (88%) rename perl/default.nix => src/perl/package.nix (79%) rename {perl => src/perl}/t/init.t (100%) rename {perl => src/perl}/t/meson.build (100%) diff --git a/flake.nix b/flake.nix index 9f494cb15..2b0e3c613 100644 --- a/flake.nix +++ b/flake.nix @@ -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: diff --git a/maintainers/hydra.nix b/maintainers/hydra.nix index cc0dadac9..6c07e65d4 100644 --- a/maintainers/hydra.nix +++ b/maintainers/hydra.nix @@ -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 diff --git a/meson.build b/meson.build index 10883d832..f1ee7a571 100644 --- a/meson.build +++ b/meson.build @@ -8,3 +8,4 @@ project('nix-dev-shell', 'cpp', subproject('libutil') subproject('libstore') +subproject('perl') diff --git a/package.nix b/package.nix index 5986edeb4..cb9554235 100644 --- a/package.nix +++ b/package.nix @@ -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 diff --git a/src/perl/.version b/src/perl/.version new file mode 120000 index 000000000..b7badcd0c --- /dev/null +++ b/src/perl/.version @@ -0,0 +1 @@ +../../.version \ No newline at end of file diff --git a/perl/.yath.rc.in b/src/perl/.yath.rc.in similarity index 100% rename from perl/.yath.rc.in rename to src/perl/.yath.rc.in diff --git a/perl/MANIFEST b/src/perl/MANIFEST similarity index 100% rename from perl/MANIFEST rename to src/perl/MANIFEST diff --git a/perl/lib/Nix/Config.pm.in b/src/perl/lib/Nix/Config.pm.in similarity index 100% rename from perl/lib/Nix/Config.pm.in rename to src/perl/lib/Nix/Config.pm.in diff --git a/perl/lib/Nix/CopyClosure.pm b/src/perl/lib/Nix/CopyClosure.pm similarity index 100% rename from perl/lib/Nix/CopyClosure.pm rename to src/perl/lib/Nix/CopyClosure.pm diff --git a/perl/lib/Nix/Manifest.pm b/src/perl/lib/Nix/Manifest.pm similarity index 100% rename from perl/lib/Nix/Manifest.pm rename to src/perl/lib/Nix/Manifest.pm diff --git a/perl/lib/Nix/SSH.pm b/src/perl/lib/Nix/SSH.pm similarity index 100% rename from perl/lib/Nix/SSH.pm rename to src/perl/lib/Nix/SSH.pm diff --git a/perl/lib/Nix/Store.pm b/src/perl/lib/Nix/Store.pm similarity index 100% rename from perl/lib/Nix/Store.pm rename to src/perl/lib/Nix/Store.pm diff --git a/perl/lib/Nix/Store.xs b/src/perl/lib/Nix/Store.xs similarity index 99% rename from perl/lib/Nix/Store.xs rename to src/perl/lib/Nix/Store.xs index e751c2be1..15eb5c4f8 100644 --- a/perl/lib/Nix/Store.xs +++ b/src/perl/lib/Nix/Store.xs @@ -1,4 +1,5 @@ -#include "nix/config.h" +#include "config-util.h" +#include "config-store.h" #include "EXTERN.h" #include "perl.h" diff --git a/perl/lib/Nix/Utils.pm b/src/perl/lib/Nix/Utils.pm similarity index 100% rename from perl/lib/Nix/Utils.pm rename to src/perl/lib/Nix/Utils.pm diff --git a/perl/lib/Nix/meson.build b/src/perl/lib/Nix/meson.build similarity index 100% rename from perl/lib/Nix/meson.build rename to src/perl/lib/Nix/meson.build diff --git a/perl/meson.build b/src/perl/meson.build similarity index 96% rename from perl/meson.build rename to src/perl/meson.build index 350e5bd67..06abb4f2e 100644 --- a/perl/meson.build +++ b/src/perl/meson.build @@ -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') diff --git a/perl/meson_options.txt b/src/perl/meson.options similarity index 88% rename from perl/meson_options.txt rename to src/perl/meson.options index 82ca52f37..9b5b6b1d9 100644 --- a/perl/meson_options.txt +++ b/src/perl/meson.options @@ -5,11 +5,6 @@ # compiler args #============================================================================ -option( - 'version', - type : 'string', - description : 'nix-perl version') - option( 'tests', type : 'feature', diff --git a/perl/default.nix b/src/perl/package.nix similarity index 79% rename from perl/default.nix rename to src/perl/package.nix index 45682381e..a31b1b66c 100644 --- a/perl/default.nix +++ b/src/perl/package.nix @@ -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) diff --git a/perl/t/init.t b/src/perl/t/init.t similarity index 100% rename from perl/t/init.t rename to src/perl/t/init.t diff --git a/perl/t/meson.build b/src/perl/t/meson.build similarity index 100% rename from perl/t/meson.build rename to src/perl/t/meson.build