2024-03-01 21:15:44 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
aws-sdk-cpp,
|
2024-04-06 23:44:27 +02:00
|
|
|
# If the patched version of Boehm isn't passed, then patch it based off of
|
|
|
|
# pkgs.boehmgc. This allows `callPackage`ing this file without needing to
|
|
|
|
# to implement behavior that this package flat out doesn't build without
|
|
|
|
# anyway, but also allows easily overriding the patch logic.
|
|
|
|
boehmgc-nix ? __forDefaults.boehmgc-nix,
|
2024-03-01 21:15:44 +01:00
|
|
|
boehmgc,
|
|
|
|
nlohmann_json,
|
|
|
|
bison,
|
2024-05-07 22:40:18 +02:00
|
|
|
build-release-notes ? __forDefaults.build-release-notes,
|
2024-03-01 21:15:44 +01:00
|
|
|
boost,
|
|
|
|
brotli,
|
|
|
|
bzip2,
|
2024-03-27 03:36:17 +01:00
|
|
|
cmake,
|
2024-03-01 21:15:44 +01:00
|
|
|
curl,
|
2024-03-09 05:09:11 +01:00
|
|
|
doxygen,
|
2024-03-01 21:15:44 +01:00
|
|
|
editline,
|
|
|
|
flex,
|
|
|
|
git,
|
|
|
|
gtest,
|
|
|
|
jq,
|
|
|
|
libarchive,
|
|
|
|
libcpuid,
|
|
|
|
libseccomp,
|
|
|
|
libsodium,
|
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
2024-03-21 20:41:23 +01:00
|
|
|
lsof,
|
2024-03-01 21:15:44 +01:00
|
|
|
lowdown,
|
|
|
|
mdbook,
|
|
|
|
mdbook-linkcheck,
|
|
|
|
mercurial,
|
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
2024-03-21 20:41:23 +01:00
|
|
|
meson,
|
|
|
|
ninja,
|
2024-03-01 21:15:44 +01:00
|
|
|
openssl,
|
|
|
|
pkg-config,
|
2024-04-06 06:28:27 +02:00
|
|
|
python3,
|
2024-03-01 21:15:44 +01:00
|
|
|
rapidcheck,
|
|
|
|
sqlite,
|
2024-03-27 03:36:17 +01:00
|
|
|
toml11,
|
2024-03-01 21:15:44 +01:00
|
|
|
util-linuxMinimal ? utillinuxMinimal,
|
|
|
|
utillinuxMinimal ? null,
|
|
|
|
xz,
|
|
|
|
|
2024-03-09 09:22:06 +01:00
|
|
|
busybox-sandbox-shell,
|
2024-03-01 21:15:44 +01:00
|
|
|
|
2024-04-08 01:16:21 +02:00
|
|
|
# internal fork of nix-doc providing :doc in the repl
|
|
|
|
lix-doc ? __forDefaults.lix-doc,
|
2024-03-18 01:01:05 +01:00
|
|
|
|
2024-03-01 21:15:44 +01:00
|
|
|
pname ? "nix",
|
|
|
|
versionSuffix ? "",
|
2024-05-16 00:01:38 +02:00
|
|
|
officialRelease ? false,
|
2024-03-01 21:15:44 +01:00
|
|
|
# Set to true to build the release notes for the next release.
|
2024-05-16 00:01:38 +02:00
|
|
|
buildUnreleasedNotes ? true,
|
2024-03-09 05:09:11 +01:00
|
|
|
internalApiDocs ? false,
|
2024-03-01 21:15:44 +01:00
|
|
|
|
|
|
|
# Not a real argument, just the only way to approximate let-binding some
|
|
|
|
# stuff for argument defaults.
|
|
|
|
__forDefaults ? {
|
|
|
|
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
2024-04-06 23:44:27 +02:00
|
|
|
|
2024-04-05 01:07:44 +02:00
|
|
|
boehmgc-nix = (boehmgc.override { enableLargeConfig = true; }).overrideAttrs {
|
2024-04-06 23:44:27 +02:00
|
|
|
patches = [
|
|
|
|
# We do *not* include prev.patches (which doesn't exist in normal pkgs.boehmgc anyway)
|
|
|
|
# because if the caller of this package passed a patched boehm as `boehmgc` instead of
|
|
|
|
# `boehmgc-nix` then this will almost certainly have duplicate patches, which means
|
|
|
|
# the patches won't apply and we'll get a build failure.
|
|
|
|
./boehmgc-coroutine-sp-fallback.diff
|
|
|
|
# https://github.com/ivmai/bdwgc/pull/586
|
|
|
|
./boehmgc-traceable_allocator-public.diff
|
|
|
|
];
|
|
|
|
};
|
2024-04-08 01:16:21 +02:00
|
|
|
|
|
|
|
lix-doc = pkgs.callPackage ./lix-doc/package.nix { };
|
2024-05-07 22:40:18 +02:00
|
|
|
build-release-notes = pkgs.callPackage ./maintainers/build-release-notes.nix { };
|
2024-03-01 21:15:44 +01:00
|
|
|
},
|
2024-04-05 01:07:44 +02:00
|
|
|
}:
|
|
|
|
let
|
2024-03-01 21:15:44 +01:00
|
|
|
inherit (__forDefaults) canRunInstalled;
|
2024-04-07 02:12:35 +02:00
|
|
|
inherit (lib) fileset;
|
2024-03-01 21:15:44 +01:00
|
|
|
|
|
|
|
version = lib.fileContents ./.version + versionSuffix;
|
|
|
|
|
2024-03-05 21:51:49 +01:00
|
|
|
aws-sdk-cpp-nix = aws-sdk-cpp.override {
|
2024-04-05 01:07:44 +02:00
|
|
|
apis = [
|
|
|
|
"s3"
|
|
|
|
"transfer"
|
|
|
|
];
|
2024-03-05 21:51:49 +01:00
|
|
|
customMemoryManagement = false;
|
|
|
|
};
|
|
|
|
|
2024-04-22 23:39:22 +02:00
|
|
|
# Reimplementation of Nixpkgs' Meson cross file, with some additions to make
|
|
|
|
# it actually work.
|
|
|
|
mesonCrossFile =
|
|
|
|
let
|
|
|
|
cpuFamily =
|
|
|
|
platform:
|
|
|
|
with platform;
|
|
|
|
if isAarch32 then
|
|
|
|
"arm"
|
|
|
|
else if isx86_32 then
|
|
|
|
"x86"
|
|
|
|
else
|
|
|
|
platform.uname.processor;
|
|
|
|
in
|
|
|
|
builtins.toFile "lix-cross-file.conf" ''
|
|
|
|
[properties]
|
|
|
|
# Meson is convinced that if !buildPlatform.canExecute hostPlatform then we cannot
|
|
|
|
# build anything at all, which is not at all correct. If we can't execute the host
|
|
|
|
# platform, we'll just disable tests and doc gen.
|
|
|
|
needs_exe_wrapper = false
|
|
|
|
|
|
|
|
[binaries]
|
|
|
|
# Meson refuses to consider any CMake binary during cross compilation if it's
|
|
|
|
# not explicitly specified here, in the cross file.
|
|
|
|
# https://github.com/mesonbuild/meson/blob/0ed78cf6fa6d87c0738f67ae43525e661b50a8a2/mesonbuild/cmake/executor.py#L72
|
|
|
|
cmake = 'cmake'
|
|
|
|
'';
|
|
|
|
|
2024-03-09 05:09:11 +01:00
|
|
|
# The internal API docs need these for the build, but if we're not building
|
|
|
|
# Nix itself, then these don't need to be propagated.
|
|
|
|
maybePropagatedInputs = [
|
2024-04-06 23:44:27 +02:00
|
|
|
boehmgc-nix
|
2024-03-09 05:09:11 +01:00
|
|
|
nlohmann_json
|
|
|
|
];
|
|
|
|
|
2024-03-01 21:15:44 +01:00
|
|
|
# .gitignore has already been processed, so any changes in it are irrelevant
|
|
|
|
# at this point. It is not represented verbatim for test purposes because
|
|
|
|
# that would interfere with repo semantics.
|
|
|
|
baseFiles = fileset.fileFilter (f: f.name != ".gitignore") ./.;
|
2024-03-05 21:51:49 +01:00
|
|
|
|
2024-05-07 21:34:36 +02:00
|
|
|
configureFiles = fileset.unions [ ./.version ];
|
2024-03-05 21:51:49 +01:00
|
|
|
|
2024-05-07 21:34:36 +02:00
|
|
|
topLevelBuildFiles = fileset.unions ([
|
|
|
|
./meson.build
|
|
|
|
./meson.options
|
|
|
|
./meson
|
|
|
|
./scripts/meson.build
|
|
|
|
]);
|
2024-04-05 01:07:44 +02:00
|
|
|
|
|
|
|
functionalTestFiles = fileset.unions [
|
2024-03-05 21:51:49 +01:00
|
|
|
./tests/functional
|
|
|
|
./tests/unit
|
|
|
|
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts)
|
2024-04-05 01:07:44 +02:00
|
|
|
];
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2024-03-05 21:51:49 +01:00
|
|
|
inherit pname version;
|
|
|
|
|
2024-03-01 21:15:44 +01:00
|
|
|
src = fileset.toSource {
|
|
|
|
root = ./.;
|
2024-04-05 01:07:44 +02:00
|
|
|
fileset = fileset.intersection baseFiles (
|
|
|
|
fileset.unions (
|
|
|
|
[
|
|
|
|
configureFiles
|
|
|
|
topLevelBuildFiles
|
|
|
|
functionalTestFiles
|
|
|
|
]
|
|
|
|
++ lib.optionals (!finalAttrs.dontBuild || internalApiDocs) [
|
|
|
|
./boehmgc-coroutine-sp-fallback.diff
|
|
|
|
./doc
|
|
|
|
./misc
|
|
|
|
./precompiled-headers.h
|
|
|
|
./src
|
|
|
|
./COPYING
|
|
|
|
]
|
|
|
|
)
|
|
|
|
);
|
2024-03-01 21:15:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
VERSION_SUFFIX = versionSuffix;
|
|
|
|
|
2024-04-05 01:07:44 +02:00
|
|
|
outputs =
|
|
|
|
[ "out" ]
|
|
|
|
++ lib.optionals (!finalAttrs.dontBuild) [
|
|
|
|
"dev"
|
|
|
|
"doc"
|
|
|
|
];
|
2024-03-05 21:51:49 +01:00
|
|
|
|
|
|
|
dontBuild = false;
|
2024-03-01 21:15:44 +01:00
|
|
|
|
2024-04-11 20:17:19 +02:00
|
|
|
mesonFlags =
|
2024-05-07 21:34:36 +02:00
|
|
|
lib.optionals stdenv.hostPlatform.isLinux [
|
|
|
|
# You'd think meson could just find this in PATH, but busybox is in buildInputs,
|
|
|
|
# which don't actually get added to PATH. And buildInputs is correct over
|
|
|
|
# nativeBuildInputs since this should be a busybox executable on the host.
|
|
|
|
"-Dsandbox-shell=${lib.getExe' busybox-sandbox-shell "busybox"}"
|
2024-04-11 20:17:19 +02:00
|
|
|
]
|
2024-04-19 00:15:24 +02:00
|
|
|
++ lib.optional stdenv.hostPlatform.isStatic "-Denable-embedded-sandbox-shell=true"
|
2024-04-11 20:17:19 +02:00
|
|
|
++ lib.optional (finalAttrs.dontBuild) "-Denable-build=false"
|
2024-04-22 23:39:22 +02:00
|
|
|
++ [
|
|
|
|
# mesonConfigurePhase automatically passes -Dauto_features=enabled,
|
|
|
|
# so we must explicitly enable or disable features that we are not passing
|
|
|
|
# dependencies for.
|
|
|
|
(lib.mesonEnable "internal-api-docs" internalApiDocs)
|
|
|
|
(lib.mesonBool "enable-tests" finalAttrs.doCheck)
|
|
|
|
(lib.mesonBool "enable-docs" canRunInstalled)
|
|
|
|
]
|
|
|
|
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "--cross-file=${mesonCrossFile}";
|
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
2024-03-21 20:41:23 +01:00
|
|
|
|
2024-03-27 03:36:17 +01:00
|
|
|
# We only include CMake so that Meson can locate toml11, which only ships CMake dependency metadata.
|
|
|
|
dontUseCmakeConfigure = true;
|
|
|
|
|
2024-04-05 01:07:44 +02:00
|
|
|
nativeBuildInputs =
|
|
|
|
[
|
|
|
|
bison
|
|
|
|
flex
|
|
|
|
python3
|
2024-05-07 21:34:36 +02:00
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
cmake
|
2024-04-05 01:07:44 +02:00
|
|
|
]
|
|
|
|
++ [
|
|
|
|
(lib.getBin lowdown)
|
|
|
|
mdbook
|
|
|
|
mdbook-linkcheck
|
|
|
|
]
|
|
|
|
++ [
|
|
|
|
pkg-config
|
|
|
|
|
|
|
|
# Tests
|
|
|
|
git
|
|
|
|
mercurial
|
|
|
|
jq
|
|
|
|
lsof
|
|
|
|
]
|
|
|
|
++ lib.optional stdenv.hostPlatform.isLinux util-linuxMinimal
|
2024-03-26 18:32:25 +01:00
|
|
|
++ lib.optional (!officialRelease && buildUnreleasedNotes) build-release-notes
|
2024-05-07 23:25:08 +02:00
|
|
|
++ lib.optional internalApiDocs doxygen;
|
2024-03-01 21:15:44 +01:00
|
|
|
|
2024-04-05 01:07:44 +02:00
|
|
|
buildInputs =
|
|
|
|
[
|
|
|
|
curl
|
|
|
|
bzip2
|
|
|
|
xz
|
|
|
|
brotli
|
|
|
|
editline
|
|
|
|
openssl
|
|
|
|
sqlite
|
|
|
|
libarchive
|
|
|
|
boost
|
|
|
|
lowdown
|
|
|
|
libsodium
|
|
|
|
toml11
|
|
|
|
lix-doc
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isLinux [
|
2024-05-08 10:00:56 +02:00
|
|
|
libseccomp
|
2024-04-05 01:07:44 +02:00
|
|
|
busybox-sandbox-shell
|
|
|
|
]
|
2024-04-11 20:17:19 +02:00
|
|
|
++ lib.optional internalApiDocs rapidcheck
|
2024-03-01 21:15:44 +01:00
|
|
|
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid
|
|
|
|
# There have been issues building these dependencies
|
|
|
|
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) aws-sdk-cpp-nix
|
2024-04-05 01:07:44 +02:00
|
|
|
++ lib.optionals (finalAttrs.dontBuild) maybePropagatedInputs;
|
2024-03-01 21:15:44 +01:00
|
|
|
|
2024-03-09 09:22:06 +01:00
|
|
|
checkInputs = [
|
2024-03-01 21:15:44 +01:00
|
|
|
gtest
|
|
|
|
rapidcheck
|
|
|
|
];
|
|
|
|
|
2024-03-09 05:09:11 +01:00
|
|
|
propagatedBuildInputs = lib.optionals (!finalAttrs.dontBuild) maybePropagatedInputs;
|
2024-03-01 21:15:44 +01:00
|
|
|
|
2024-04-05 01:07:44 +02:00
|
|
|
disallowedReferences = [ boost ];
|
2024-03-01 21:15:44 +01:00
|
|
|
|
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
2024-03-21 20:41:23 +01:00
|
|
|
# Needed for Meson to find Boost.
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/86131.
|
2024-05-07 21:34:36 +02:00
|
|
|
env = {
|
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
2024-03-21 20:41:23 +01:00
|
|
|
BOOST_INCLUDEDIR = "${lib.getDev boost}/include";
|
|
|
|
BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";
|
|
|
|
};
|
|
|
|
|
2024-04-05 01:07:44 +02:00
|
|
|
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
|
|
|
|
mkdir -p $out/lib
|
|
|
|
cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
|
|
|
|
rm -f $out/lib/*.a
|
|
|
|
''
|
|
|
|
+ lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isLinux) ''
|
|
|
|
chmod u+w $out/lib/*.so.*
|
|
|
|
patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
|
|
|
|
''
|
|
|
|
+ lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isDarwin) ''
|
|
|
|
for LIB in $out/lib/*.dylib; do
|
|
|
|
chmod u+w $LIB
|
|
|
|
install_name_tool -id $LIB $LIB
|
|
|
|
install_name_tool -delete_rpath ${boost}/lib/ $LIB || true
|
|
|
|
done
|
|
|
|
install_name_tool -change ${boost}/lib/libboost_system.dylib $out/lib/libboost_system.dylib $out/lib/libboost_thread.dylib
|
|
|
|
''
|
|
|
|
+ ''
|
|
|
|
# Workaround https://github.com/NixOS/nixpkgs/issues/294890.
|
|
|
|
if [[ -n "''${doCheck:-}" ]]; then
|
|
|
|
appendToVar configureFlags "--enable-tests"
|
|
|
|
else
|
|
|
|
appendToVar configureFlags "--disable-tests"
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2024-05-07 21:34:36 +02:00
|
|
|
mesonBuildType = "debugoptimized";
|
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
2024-03-21 20:41:23 +01:00
|
|
|
|
2024-03-09 05:09:11 +01:00
|
|
|
installTargets = lib.optional internalApiDocs "internal-api-html";
|
|
|
|
|
2024-03-01 21:15:44 +01:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2024-04-22 23:39:22 +02:00
|
|
|
doCheck = canRunInstalled;
|
2024-03-01 21:15:44 +01:00
|
|
|
|
2024-05-07 21:34:36 +02:00
|
|
|
mesonCheckFlags = [ "--suite=check" ];
|
2024-03-01 21:15:44 +01:00
|
|
|
|
2024-04-11 20:17:19 +02:00
|
|
|
# Make sure the internal API docs are already built, because mesonInstallPhase
|
|
|
|
# won't let us build them there. They would normally be built in buildPhase,
|
|
|
|
# but the internal API docs are conventionally built with doBuild = false.
|
2024-05-07 21:34:36 +02:00
|
|
|
preInstall = lib.optional internalApiDocs ''
|
2024-04-11 20:17:19 +02:00
|
|
|
meson ''${mesonBuildFlags:-} compile "$installTargets"
|
|
|
|
'';
|
|
|
|
|
2024-04-05 01:07:44 +02:00
|
|
|
postInstall =
|
|
|
|
lib.optionalString (!finalAttrs.dontBuild) ''
|
|
|
|
mkdir -p $doc/nix-support
|
|
|
|
echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
|
|
|
|
''
|
|
|
|
+ lib.optionalString stdenv.hostPlatform.isStatic ''
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
|
|
|
|
''
|
|
|
|
+ lib.optionalString stdenv.isDarwin ''
|
|
|
|
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"
|
|
|
|
'';
|
2024-03-01 21:15:44 +01:00
|
|
|
|
|
|
|
doInstallCheck = finalAttrs.doCheck;
|
|
|
|
|
2024-04-05 01:07:44 +02:00
|
|
|
mesonInstallCheckFlags = [ "--suite=installcheck" ];
|
2024-03-25 19:12:56 +01:00
|
|
|
|
2024-05-07 21:34:36 +02:00
|
|
|
installCheckPhase = ''
|
2024-03-25 19:12:56 +01:00
|
|
|
runHook preInstallCheck
|
|
|
|
flagsArray=($mesonInstallCheckFlags "''${mesonInstallCheckFlagsArray[@]}")
|
|
|
|
meson test --no-rebuild "''${flagsArray[@]}"
|
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
2024-03-05 21:51:49 +01:00
|
|
|
separateDebugInfo = !stdenv.hostPlatform.isStatic && !finalAttrs.dontBuild;
|
2024-03-01 21:15:44 +01:00
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
|
2024-03-25 07:45:25 +01:00
|
|
|
# strictoverflow is disabled because we trap on signed overflow instead
|
2024-04-05 01:07:44 +02:00
|
|
|
hardeningDisable = [ "strictoverflow" ] ++ lib.optional stdenv.hostPlatform.isStatic "pie";
|
2024-03-01 21:15:44 +01:00
|
|
|
|
|
|
|
meta.platforms = lib.platforms.unix;
|
|
|
|
|
2024-05-07 21:34:36 +02:00
|
|
|
passthru.perl-bindings = pkgs.callPackage ./perl { inherit fileset stdenv; };
|
2024-04-06 23:44:27 +02:00
|
|
|
|
2024-05-08 10:00:56 +02:00
|
|
|
# Export the patched version of boehmgc.
|
2024-04-06 23:44:27 +02:00
|
|
|
# flake.nix exports that into its overlay.
|
libstore/local-derivation-goal: prohibit creating setuid/setgid binaries
With Linux kernel >=6.6 & glibc 2.39 a `fchmodat2(2)` is available that
isn't filtered away by the libseccomp sandbox.
Being able to use this to bypass that restriction has surprising results
for some builds such as lxc[1]:
> With kernel ≥6.6 and glibc 2.39, lxc's install phase uses fchmodat2,
> which slips through https://github.com/NixOS/nix/blob/9b88e5284608116b7db0dbd3d5dd7a33b90d52d7/src/libstore/build/local-derivation-goal.cc#L1650-L1663.
> The fixupPhase then uses fchmodat, which fails.
> With older kernel or glibc, setting the suid bit fails in the
> install phase, which is not treated as fatal, and then the
> fixup phase does not try to set it again.
Please note that there are still ways to bypass this sandbox[2] and this is
mostly a fix for the breaking builds.
This change works by creating a syscall filter for the `fchmodat2`
syscall (number 452 on most systems). The problem is that glibc 2.39
is needed to have the correct syscall number available via
`__NR_fchmodat2` / `__SNR_fchmodat2`, but this flake is still on
nixpkgs 23.11. To have this change everywhere and not dependent on the
glibc this package is built against, I added a header
"fchmodat2-compat.hh" that sets the syscall number based on the
architecture. On most platforms its 452 according to glibc with a few
exceptions:
$ rg --pcre2 'define __NR_fchmodat2 (?!452)'
sysdeps/unix/sysv/linux/x86_64/x32/arch-syscall.h
58:#define __NR_fchmodat2 1073742276
sysdeps/unix/sysv/linux/mips/mips64/n32/arch-syscall.h
67:#define __NR_fchmodat2 6452
sysdeps/unix/sysv/linux/mips/mips64/n64/arch-syscall.h
62:#define __NR_fchmodat2 5452
sysdeps/unix/sysv/linux/mips/mips32/arch-syscall.h
70:#define __NR_fchmodat2 4452
sysdeps/unix/sysv/linux/alpha/arch-syscall.h
59:#define __NR_fchmodat2 562
I added a small regression-test to the setuid integration-test that
attempts to set the suid bit on a file using the fchmodat2 syscall.
I confirmed that the test fails without the change in
local-derivation-goal.
Additionally, we require libseccomp 2.5.5 or greater now: as it turns
out, libseccomp maintains an internal syscall table and
validates each rule against it. This means that when using libseccomp
2.5.4 or older, one may pass `452` as syscall number against it, but
since it doesn't exist in the internal structure, `libseccomp` will refuse
to create a filter for that. This happens with nixpkgs-23.11, i.e. on
stable NixOS and when building Lix against the project's flake.
To work around that
* a backport of libseccomp 2.5.5 on upstream nixpkgs has been
scheduled[3].
* the package now uses libseccomp 2.5.5 on its own already. This is to
provide a quick fix since the correct fix for 23.11 is still a staging cycle
away.
We still need the compat header though since `SCMP_SYS(fchmodat2)`
internally transforms this into `__SNR_fchmodat2` which points to
`__NR_fchmodat2` from glibc 2.39, so it wouldn't build on glibc 2.38.
The updated syscall table from libseccomp 2.5.5 is NOT used for that
step, but used later, so we need both, our compat header and their
syscall table 🤷
Relevant PRs in CppNix:
* https://github.com/NixOS/nix/pull/10591
* https://github.com/NixOS/nix/pull/10501
[1] https://github.com/NixOS/nixpkgs/issues/300635#issuecomment-2031073804
[2] https://github.com/NixOS/nixpkgs/issues/300635#issuecomment-2030844251
[3] https://github.com/NixOS/nixpkgs/pull/306070
(cherry picked from commit ba6804518772e6afb403dd55478365d4b863c854)
Change-Id: I6921ab5a363188c6bff617750d00bb517276b7fe
2024-04-14 14:10:23 +02:00
|
|
|
passthru = {
|
2024-05-08 10:00:56 +02:00
|
|
|
inherit (__forDefaults) boehmgc-nix build-release-notes;
|
2024-05-07 23:25:08 +02:00
|
|
|
|
|
|
|
# The collection of dependency logic for this derivation is complicated enough that
|
|
|
|
# it's easier to parameterize the devShell off an already called package.nix.
|
|
|
|
mkDevShell =
|
|
|
|
{
|
|
|
|
mkShell,
|
|
|
|
just,
|
|
|
|
nixfmt,
|
|
|
|
glibcLocales,
|
|
|
|
bear,
|
|
|
|
pre-commit-checks,
|
|
|
|
clang-tools,
|
|
|
|
llvmPackages,
|
|
|
|
clangbuildanalyzer,
|
|
|
|
contribNotice,
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
glibcFix = lib.optionalAttrs (stdenv.buildPlatform.isLinux && glibcLocales != null) {
|
|
|
|
# Required to make non-NixOS Linux not complain about missing locale files during configure in a dev shell
|
|
|
|
LOCALE_ARCHIVE = "${lib.getLib pkgs.glibcLocales}/lib/locale/locale-archive";
|
|
|
|
};
|
|
|
|
# for some reason that seems accidental and was changed in
|
|
|
|
# NixOS 24.05-pre, clang-tools is pinned to LLVM 14 when
|
|
|
|
# default LLVM is newer.
|
|
|
|
clang-tools_llvm = clang-tools.override { inherit llvmPackages; };
|
|
|
|
|
|
|
|
# pkgs.mkShell uses pkgs.stdenv by default, regardless of inputsFrom.
|
|
|
|
actualMkShell = mkShell.override { inherit stdenv; };
|
|
|
|
in
|
|
|
|
actualMkShell (
|
|
|
|
glibcFix
|
|
|
|
// {
|
|
|
|
|
|
|
|
inputsFrom = [ finalAttrs ];
|
|
|
|
|
|
|
|
# For Meson to find Boost.
|
|
|
|
env = finalAttrs.env;
|
|
|
|
|
|
|
|
packages =
|
|
|
|
lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) clang-tools_llvm
|
|
|
|
++ [
|
|
|
|
just
|
|
|
|
nixfmt
|
|
|
|
# Load-bearing order. Must come before clang-unwrapped below, but after clang_tools above.
|
|
|
|
stdenv.cc
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.cc.isClang [
|
|
|
|
# Required for clang-tidy checks.
|
|
|
|
llvmPackages.llvm
|
|
|
|
llvmPackages.clang-unwrapped.dev
|
|
|
|
]
|
|
|
|
++ lib.optional (pre-commit-checks ? enabledPackages) pre-commit-checks.enabledPackages
|
|
|
|
++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) bear
|
|
|
|
++ lib.optional (lib.meta.availableOn stdenv.buildPlatform clangbuildanalyzer) clangbuildanalyzer
|
|
|
|
++ finalAttrs.checkInputs;
|
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
PATH=$prefix/bin:$PATH
|
|
|
|
unset PYTHONPATH
|
|
|
|
export MANPATH=$out/share/man:$MANPATH
|
|
|
|
|
|
|
|
# Make bash completion work.
|
|
|
|
XDG_DATA_DIRS+=:$out/share
|
|
|
|
|
|
|
|
${lib.optionalString (pre-commit-checks ? shellHook) pre-commit-checks.shellHook}
|
|
|
|
# Allow `touch .nocontribmsg` to turn this notice off.
|
|
|
|
if ! [[ -f .nocontribmsg ]]; then
|
|
|
|
cat ${contribNotice}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install the Gerrit commit-msg hook.
|
|
|
|
# (git common dir is the main .git, including for worktrees)
|
|
|
|
if gitcommondir=$(git rev-parse --git-common-dir 2>/dev/null) && [[ ! -f "$gitcommondir/hooks/commit-msg" ]]; then
|
|
|
|
echo 'Installing Gerrit commit-msg hook (adds Change-Id to commit messages)' >&2
|
|
|
|
mkdir -p "$gitcommondir/hooks"
|
|
|
|
curl -s -Lo "$gitcommondir/hooks/commit-msg" https://gerrit.lix.systems/tools/hooks/commit-msg
|
|
|
|
chmod u+x "$gitcommondir/hooks/commit-msg"
|
|
|
|
fi
|
|
|
|
unset gitcommondir
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
);
|
libstore/local-derivation-goal: prohibit creating setuid/setgid binaries
With Linux kernel >=6.6 & glibc 2.39 a `fchmodat2(2)` is available that
isn't filtered away by the libseccomp sandbox.
Being able to use this to bypass that restriction has surprising results
for some builds such as lxc[1]:
> With kernel ≥6.6 and glibc 2.39, lxc's install phase uses fchmodat2,
> which slips through https://github.com/NixOS/nix/blob/9b88e5284608116b7db0dbd3d5dd7a33b90d52d7/src/libstore/build/local-derivation-goal.cc#L1650-L1663.
> The fixupPhase then uses fchmodat, which fails.
> With older kernel or glibc, setting the suid bit fails in the
> install phase, which is not treated as fatal, and then the
> fixup phase does not try to set it again.
Please note that there are still ways to bypass this sandbox[2] and this is
mostly a fix for the breaking builds.
This change works by creating a syscall filter for the `fchmodat2`
syscall (number 452 on most systems). The problem is that glibc 2.39
is needed to have the correct syscall number available via
`__NR_fchmodat2` / `__SNR_fchmodat2`, but this flake is still on
nixpkgs 23.11. To have this change everywhere and not dependent on the
glibc this package is built against, I added a header
"fchmodat2-compat.hh" that sets the syscall number based on the
architecture. On most platforms its 452 according to glibc with a few
exceptions:
$ rg --pcre2 'define __NR_fchmodat2 (?!452)'
sysdeps/unix/sysv/linux/x86_64/x32/arch-syscall.h
58:#define __NR_fchmodat2 1073742276
sysdeps/unix/sysv/linux/mips/mips64/n32/arch-syscall.h
67:#define __NR_fchmodat2 6452
sysdeps/unix/sysv/linux/mips/mips64/n64/arch-syscall.h
62:#define __NR_fchmodat2 5452
sysdeps/unix/sysv/linux/mips/mips32/arch-syscall.h
70:#define __NR_fchmodat2 4452
sysdeps/unix/sysv/linux/alpha/arch-syscall.h
59:#define __NR_fchmodat2 562
I added a small regression-test to the setuid integration-test that
attempts to set the suid bit on a file using the fchmodat2 syscall.
I confirmed that the test fails without the change in
local-derivation-goal.
Additionally, we require libseccomp 2.5.5 or greater now: as it turns
out, libseccomp maintains an internal syscall table and
validates each rule against it. This means that when using libseccomp
2.5.4 or older, one may pass `452` as syscall number against it, but
since it doesn't exist in the internal structure, `libseccomp` will refuse
to create a filter for that. This happens with nixpkgs-23.11, i.e. on
stable NixOS and when building Lix against the project's flake.
To work around that
* a backport of libseccomp 2.5.5 on upstream nixpkgs has been
scheduled[3].
* the package now uses libseccomp 2.5.5 on its own already. This is to
provide a quick fix since the correct fix for 23.11 is still a staging cycle
away.
We still need the compat header though since `SCMP_SYS(fchmodat2)`
internally transforms this into `__SNR_fchmodat2` which points to
`__NR_fchmodat2` from glibc 2.39, so it wouldn't build on glibc 2.38.
The updated syscall table from libseccomp 2.5.5 is NOT used for that
step, but used later, so we need both, our compat header and their
syscall table 🤷
Relevant PRs in CppNix:
* https://github.com/NixOS/nix/pull/10591
* https://github.com/NixOS/nix/pull/10501
[1] https://github.com/NixOS/nixpkgs/issues/300635#issuecomment-2031073804
[2] https://github.com/NixOS/nixpkgs/issues/300635#issuecomment-2030844251
[3] https://github.com/NixOS/nixpkgs/pull/306070
(cherry picked from commit ba6804518772e6afb403dd55478365d4b863c854)
Change-Id: I6921ab5a363188c6bff617750d00bb517276b7fe
2024-04-14 14:10:23 +02:00
|
|
|
};
|
2024-03-01 21:15:44 +01:00
|
|
|
})
|