nix/tests/unit/libexpr/package.nix

99 lines
1.9 KiB
Nix
Raw Permalink Normal View History

2024-06-27 21:44:34 +00:00
{ lib
, buildPackages
2024-06-27 21:44:34 +00:00
, stdenv
2024-07-01 18:36:46 +00:00
, mkMesonDerivation
2024-06-27 21:44:34 +00:00
, releaseTools
, meson
, ninja
, pkg-config
, nix-expr
, nix-expr-c
, nix-expr-test-support
, rapidcheck
, gtest
, runCommand
# Configuration Options
2024-07-06 15:36:31 +00:00
, version
, resolvePath
2024-06-27 21:44:34 +00:00
}:
let
inherit (lib) fileset;
in
2024-07-01 18:36:46 +00:00
mkMesonDerivation (finalAttrs: {
pname = "nix-expr-tests";
2024-06-27 21:44:34 +00:00
inherit version;
2024-07-01 18:36:46 +00:00
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
2024-07-01 18:36:46 +00:00
./build-utils-meson
../../../.version
2024-07-01 18:36:46 +00:00
./.version
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
2024-06-27 21:44:34 +00:00
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
''
2024-07-01 18:36:46 +00:00
chmod u+w ./.version
echo ${version} > ../../../.version
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";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
passthru = {
tests = {
run = runCommand "${finalAttrs.pname}-run" {
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
} (lib.optionalString stdenv.hostPlatform.isWindows ''
export HOME="$PWD/home-dir"
mkdir -p "$HOME"
'' + ''
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
2024-06-27 21:44:34 +00:00
touch $out
'');
2024-06-27 21:44:34 +00:00
};
};
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
2024-06-27 21:44:34 +00:00
};
})