2024-06-28 00:44:34 +03:00
|
|
|
{ lib
|
2024-07-21 19:57:49 +03:00
|
|
|
, buildPackages
|
2024-06-28 00:44:34 +03:00
|
|
|
, stdenv
|
2024-07-01 21:36:46 +03:00
|
|
|
, mkMesonDerivation
|
2024-06-28 00:44:34 +03:00
|
|
|
, releaseTools
|
|
|
|
|
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, pkg-config
|
|
|
|
|
|
|
|
, nix-store
|
|
|
|
, nix-store-c
|
|
|
|
, nix-store-test-support
|
2024-06-28 21:57:10 +03:00
|
|
|
, sqlite
|
2024-06-28 00:44:34 +03:00
|
|
|
|
|
|
|
, rapidcheck
|
|
|
|
, gtest
|
|
|
|
, runCommand
|
|
|
|
|
|
|
|
# Configuration Options
|
|
|
|
|
2024-07-06 18:36:31 +03:00
|
|
|
, version
|
2024-07-06 18:49:58 +03:00
|
|
|
, filesetToSource
|
2024-06-28 00:44:34 +03:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) fileset;
|
|
|
|
in
|
|
|
|
|
2024-07-01 21:36:46 +03:00
|
|
|
mkMesonDerivation (finalAttrs: {
|
2024-06-29 17:31:08 +03:00
|
|
|
pname = "nix-store-tests";
|
2024-06-28 00:44:34 +03:00
|
|
|
inherit version;
|
|
|
|
|
2024-07-01 21:36:46 +03:00
|
|
|
workDir = ./.;
|
|
|
|
fileset = fileset.unions [
|
2024-07-01 07:25:57 +03:00
|
|
|
../../../build-utils-meson
|
2024-07-01 21:36:46 +03:00
|
|
|
./build-utils-meson
|
2024-07-01 07:25:57 +03:00
|
|
|
../../../.version
|
2024-07-01 21:36:46 +03:00
|
|
|
./.version
|
|
|
|
./meson.build
|
|
|
|
# ./meson.options
|
|
|
|
(fileset.fileFilter (file: file.hasExt "cc") ./.)
|
|
|
|
(fileset.fileFilter (file: file.hasExt "hh") ./.)
|
|
|
|
];
|
2024-06-28 00:44:34 +03:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
nix-store
|
|
|
|
nix-store-c
|
|
|
|
nix-store-test-support
|
2024-06-28 21:57:10 +03:00
|
|
|
sqlite
|
2024-06-28 00:44:34 +03:00
|
|
|
rapidcheck
|
|
|
|
gtest
|
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure =
|
2024-06-28 02:19:32 +03:00
|
|
|
# "Inline" .version so it's not a symlink, and includes the suffix.
|
|
|
|
# Do the meson utils, without modification.
|
2024-06-28 00:44:34 +03:00
|
|
|
''
|
2024-07-01 21:36:46 +03:00
|
|
|
chmod u+w ./.version
|
2024-07-01 07:25:57 +03:00
|
|
|
echo ${version} > ../../../.version
|
2024-06-28 00:44:34 +03: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 = {
|
2024-06-28 21:57:10 +03:00
|
|
|
run = let
|
2024-07-01 21:31:04 +03:00
|
|
|
# Some data is shared with the functional tests: they create it,
|
|
|
|
# we consume it.
|
2024-07-06 18:49:58 +03:00
|
|
|
data = filesetToSource {
|
2024-07-01 21:31:04 +03:00
|
|
|
root = ../..;
|
|
|
|
fileset = lib.fileset.unions [
|
|
|
|
./data
|
2024-07-01 07:25:57 +03:00
|
|
|
../../functional/derivation
|
2024-07-01 21:31:04 +03:00
|
|
|
];
|
|
|
|
};
|
2024-07-21 19:57:49 +03:00
|
|
|
in runCommand "${finalAttrs.pname}-run" {
|
|
|
|
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
|
|
|
|
} (lib.optionalString stdenv.hostPlatform.isWindows ''
|
|
|
|
export HOME="$PWD/home-dir"
|
|
|
|
mkdir -p "$HOME"
|
|
|
|
'' + ''
|
2024-07-01 07:25:57 +03:00
|
|
|
export _NIX_TEST_UNIT_DATA=${data + "/unit/libstore/data"}
|
2024-07-21 19:57:49 +03:00
|
|
|
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
|
2024-06-28 00:44:34 +03:00
|
|
|
touch $out
|
2024-07-21 19:57:49 +03:00
|
|
|
'');
|
2024-06-28 00:44:34 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
2024-07-21 19:57:49 +03:00
|
|
|
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
|
2024-06-28 00:44:34 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
})
|