2024-06-27 21:44:34 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, releaseTools
|
|
|
|
|
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, pkg-config
|
|
|
|
|
|
|
|
, nix-expr
|
|
|
|
, nix-expr-c
|
|
|
|
, nix-expr-test-support
|
|
|
|
|
|
|
|
, rapidcheck
|
|
|
|
, gtest
|
|
|
|
, runCommand
|
|
|
|
|
|
|
|
# Configuration Options
|
|
|
|
|
|
|
|
, versionSuffix ? ""
|
|
|
|
|
|
|
|
# Check test coverage of Nix. Probably want to use with at least
|
|
|
|
# one of `doCheck` or `doInstallCheck` enabled.
|
|
|
|
, withCoverageChecks ? false
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) fileset;
|
|
|
|
|
|
|
|
version = lib.fileContents ./.version + versionSuffix;
|
|
|
|
|
|
|
|
mkDerivation =
|
|
|
|
if withCoverageChecks
|
|
|
|
then
|
|
|
|
# TODO support `finalAttrs` args function in
|
|
|
|
# `releaseTools.coverageAnalysis`.
|
|
|
|
argsFun:
|
|
|
|
releaseTools.coverageAnalysis (let args = argsFun args; in args)
|
|
|
|
else stdenv.mkDerivation;
|
|
|
|
in
|
|
|
|
|
|
|
|
mkDerivation (finalAttrs: {
|
2024-06-29 14:31:08 +00:00
|
|
|
pname = "nix-expr-tests";
|
2024-06-27 21:44:34 +00:00
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fileset.toSource {
|
|
|
|
root = ./.;
|
|
|
|
fileset = fileset.unions [
|
|
|
|
./meson.build
|
|
|
|
# ./meson.options
|
|
|
|
(fileset.fileFilter (file: file.hasExt "cc") ./.)
|
|
|
|
(fileset.fileFilter (file: file.hasExt "hh") ./.)
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
nix-expr
|
|
|
|
nix-expr-c
|
|
|
|
nix-expr-test-support
|
|
|
|
rapidcheck
|
|
|
|
gtest
|
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure =
|
2024-06-27 23:19:32 +00:00
|
|
|
# "Inline" .version so it's not a symlink, and includes the suffix.
|
|
|
|
# Do the meson utils, without modification.
|
2024-06-27 21:44:34 +00:00
|
|
|
''
|
|
|
|
echo ${version} > .version
|
2024-06-27 23:19:32 +00:00
|
|
|
cp -r ${../../build-utils-meson} build-utils-meson
|
2024-06-27 21:44:34 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
mesonFlags = [
|
|
|
|
];
|
|
|
|
|
|
|
|
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
|
|
|
|
LDFLAGS = "-fuse-ld=gold";
|
|
|
|
};
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
|
|
|
|
|
|
|
# TODO Always true after https://github.com/NixOS/nixpkgs/issues/318564
|
|
|
|
strictDeps = !withCoverageChecks;
|
|
|
|
|
|
|
|
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
tests = {
|
|
|
|
run = runCommand "${finalAttrs.pname}-run" {
|
|
|
|
} ''
|
|
|
|
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
|
|
|
|
export _NIX_TEST_UNIT_DATA=${./data}
|
2024-06-29 14:31:08 +00:00
|
|
|
nix-expr-tests
|
2024-06-27 21:44:34 +00:00
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // lib.optionalAttrs withCoverageChecks {
|
|
|
|
lcovFilter = [ "*/boost/*" "*-tab.*" ];
|
|
|
|
|
|
|
|
hardeningDisable = [ "fortify" ];
|
|
|
|
})
|