diff options
author | Qyriad <qyriad@qyriad.me> | 2024-03-21 13:41:23 -0600 |
---|---|---|
committer | Qyriad <qyriad@qyriad.me> | 2024-03-22 08:36:50 -0600 |
commit | b4d07656ff2c43b1144eb97658b9528dd39418ce (patch) | |
tree | d6aeb04613749884ca328f41bdbab16a4585e17f /package.nix | |
parent | a7161b6c0f6f9640acc065f0bd18579babacb0cf (diff) |
build: optionally build and install with meson
This commit adds several meson.build, which successfully build and
install Lix executables, libraries, and headers. Meson does not yet
build docs, Perl bindings, or run tests, which will be added in
following commits. As such, this commit does not remove the existing
build system, or make it the default, and also as such, this commit has
several FIXMEs and TODOs as notes for what should be done before the
existing autoconf + make buildsystem can be removed and Meson made the
default. This commit does not modify any source files.
A Meson-enabled build is also added as a Hydra job, and to
`nix flake check`.
Change-Id: I667c8685b13b7bab91e281053f807a11616ae3d4
Diffstat (limited to 'package.nix')
-rw-r--r-- | package.nix | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/package.nix b/package.nix index 8d33759b7..4b4c35731 100644 --- a/package.nix +++ b/package.nix @@ -24,10 +24,13 @@ libcpuid, libseccomp, libsodium, + lsof, lowdown, mdbook, mdbook-linkcheck, mercurial, + meson, + ninja, openssl, pkg-config, rapidcheck, @@ -47,6 +50,10 @@ # Avoid setting things that would interfere with a functioning devShell forDevShell ? false, + # FIXME(Qyriad): build Lix using Meson instead of autoconf and make. + # This flag will be removed when the migration to Meson is complete. + buildWithMeson ? false, + # Not a real argument, just the only way to approximate let-binding some # stuff for argument defaults. __forDefaults ? { @@ -86,12 +93,16 @@ ./README.md ]; - topLevelBuildFiles = fileset.unions [ + topLevelBuildFiles = fileset.unions ([ ./local.mk ./Makefile ./Makefile.config.in ./mk - ]; + ] ++ lib.optionals buildWithMeson [ + ./meson.build + ./meson.options + ./meson/cleanup-install.bash + ]); functionalTestFiles = fileset.unions [ ./tests/functional @@ -126,6 +137,11 @@ in stdenv.mkDerivation (finalAttrs: { dontBuild = false; + # FIXME(Qyriad): see if this is still needed once the migration to Meson is completed. + mesonFlags = lib.optionals (buildWithMeson && stdenv.hostPlatform.isLinux) [ + "-Dsandbox-shell=${lib.getBin busybox-sandbox-shell}/bin/busybox" + ]; + nativeBuildInputs = [ bison flex @@ -134,17 +150,21 @@ in stdenv.mkDerivation (finalAttrs: { mdbook mdbook-linkcheck autoconf-archive - autoreconfHook + ] ++ lib.optional (!buildWithMeson) autoreconfHook ++ [ pkg-config # Tests git mercurial jq + lsof ] ++ lib.optional stdenv.hostPlatform.isLinux util-linuxMinimal ++ lib.optional (!officialRelease && buildUnreleasedNotes) changelog-d ++ lib.optional internalApiDocs doxygen - ; + ++ lib.optionals buildWithMeson [ + meson + ninja + ]; buildInputs = [ curl @@ -159,7 +179,7 @@ in stdenv.mkDerivation (finalAttrs: { lowdown libsodium ] - ++ lib.optionals stdenv.isLinux [ libseccomp ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ libseccomp busybox-sandbox-shell ] ++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid # There have been issues building these dependencies ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) aws-sdk-cpp-nix @@ -177,6 +197,13 @@ in stdenv.mkDerivation (finalAttrs: { boost ]; + # Needed for Meson to find Boost. + # https://github.com/NixOS/nixpkgs/issues/86131. + env = lib.optionalAttrs (buildWithMeson || forDevShell) { + BOOST_INCLUDEDIR = "${lib.getDev boost}/include"; + BOOST_LIBRARYDIR = "${lib.getLib boost}/lib"; + }; + preConfigure = lib.optionalString (!finalAttrs.dontBuild && !stdenv.hostPlatform.isStatic) '' # Copy libboost_context so we don't get all of Boost in our closure. # https://github.com/NixOS/nixpkgs/issues/45462 @@ -214,6 +241,8 @@ in stdenv.mkDerivation (finalAttrs: { ++ [ (lib.enableFeature internalApiDocs "internal-api-docs") ] ++ lib.optional (!forDevShell) "--sysconfdir=/etc"; + mesonBuildType = lib.optional (buildWithMeson || forDevShell) "debugoptimized"; + installTargets = lib.optional internalApiDocs "internal-api-html"; enableParallelBuilding = true; @@ -231,10 +260,12 @@ in stdenv.mkDerivation (finalAttrs: { mkdir -p $out/nix-support echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products '' + lib.optionalString stdenv.isDarwin '' - install_name_tool \ - -change ${boost}/lib/libboost_context.dylib \ - $out/lib/libboost_context.dylib \ - $out/lib/libnixutil.dylib + for lib in libnixutil.dylib libnixexpr.dylib; do + install_name_tool \ + -change "${lib.getLib boost}/lib/libboost_context.dylib" \ + "$out/lib/libboost_context.dylib" \ + "$out/lib/$lib" + done '' + lib.optionalString internalApiDocs '' mkdir -p $out/nix-support echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> "$out/nix-support/hydra-build-products" |