Skip to content

Commit

Permalink
Integrate perl with the other meson builds
Browse files Browse the repository at this point in the history
One big dev shell!
  • Loading branch information
Ericson2314 committed Jun 4, 2024
1 parent d5400d8 commit d63b491
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 20 deletions.
26 changes: 23 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,12 @@
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
Expand Down Expand Up @@ -304,6 +308,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;
installFlags = "sysconfdir=$(out)/etc";
Expand All @@ -329,11 +340,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"
Expand All @@ -343,6 +359,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:
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ project('nix-dev-shell', 'cpp',

subproject('libutil')
subproject('libstore')
subproject('perl')
4 changes: 2 additions & 2 deletions package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ in {
./doc
./misc
./precompiled-headers.h
./src
(fileset.difference ./src ./src/perl)
./COPYING
./scripts/local.mk
] ++ lib.optionals buildUnitTests [
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/perl/.version
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion perl/lib/Nix/Store.xs → src/perl/lib/Nix/Store.xs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "nix/config.h"
#include "config-util.h"
#include "config-store.h"

#include "EXTERN.h"
#include "perl.h"
Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 7 additions & 4 deletions perl/meson.build → src/perl/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
project (
'nix-perl',
'cpp',
version : run_command('cat', './.version', check : true).stdout().strip(),
meson_version : '>= 0.64.0',
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
Expand Down Expand Up @@ -64,8 +64,11 @@ 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')

nix_store_dep = dependency('nix-store', required : false)
if not nix_store_dep.found()
nix_store_dep = subproject('libstore').get_variable('nix_store')
endif


# Finding Perl Headers is a pain. as they do not have
Expand Down
5 changes: 0 additions & 5 deletions perl/meson_options.txt → src/perl/meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
# compiler args
#============================================================================

option(
'version',
type : 'string',
description : 'nix-perl version')

option(
'tests',
type : 'feature',
Expand Down
21 changes: 16 additions & 5 deletions perl/default.nix → src/perl/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@
, meson
, ninja
, pkg-config
, nix
, nix-store
, curl
, bzip2
, xz
, boost
, libsodium
, darwin
, versionSuffix ? ""
}:

let
version = lib.fileContents ./.version + versionSuffix;
in

perl.pkgs.toPerlModule (stdenv.mkDerivation (finalAttrs: {
name = "nix-perl-${nix.version}";
pname = "nix-perl";
inherit version;

src = fileset.toSource {
root = ./.;
fileset = fileset.unions ([
./MANIFEST
./lib
./meson.build
./meson_options.txt
./meson.options
] ++ lib.optionals finalAttrs.doCheck [
./.yath.rc.in
./t
Expand All @@ -38,7 +44,7 @@ perl.pkgs.toPerlModule (stdenv.mkDerivation (finalAttrs: {
];

buildInputs = [
nix
nix-store
curl
bzip2
xz
Expand All @@ -55,8 +61,13 @@ perl.pkgs.toPerlModule (stdenv.mkDerivation (finalAttrs: {
perlPackages.Test2Harness
];

preConfigure =
# "Inline" .version so its not a symlink, and includes the suffix
''
echo ${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)
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit d63b491

Please sign in to comment.