1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00
nix/src/libflake-tests/package.nix
Robert Hensing 96e550efc5 Format .nix files
... with nixfmt (rfc style)
2025-01-24 17:04:02 +01:00

87 lines
1.8 KiB
Nix

{
lib,
buildPackages,
stdenv,
mkMesonExecutable,
nix-flake,
nix-flake-c,
nix-expr-test-support,
rapidcheck,
gtest,
runCommand,
# Configuration Options
version,
resolvePath,
}:
let
inherit (lib) fileset;
in
mkMesonExecutable (finalAttrs: {
pname = "nix-flake-tests";
inherit version;
workDir = ./.;
fileset = fileset.unions [
../../nix-meson-build-support
./nix-meson-build-support
../../.version
./.version
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
buildInputs = [
nix-flake
nix-flake-c
nix-expr-test-support
rapidcheck
gtest
];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';
mesonFlags = [
];
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}
export NIX_CONFIG="extra-experimental-features = flakes"
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
touch $out
''
);
};
};
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
};
})