Files
nixpkgs/pkgs/by-name/bu/buildstream/package.nix
Dom Rodriguez 2151ee2fcb buildstream: run the pytest suite as a NixOS VM test
buildbox-casd finds `buildbox-fuse` on PATH and defaults to real
FUSE-based staging, which needs `/dev/fuse` and a working mount path
that the Nix build sandbox doesn't provide, hence the
`BUILDBOX_STAGER=copy-or-link` workaround forcing the hardlink/copy
fallback stager, and the `/usr/bin/env sh` shebang patch for the dummy
buildbox-casd scripts in tests/internals/cascache.py.

Add nixosTests.buildstream and point passthru.tests.pytest at it
instead: so the suite exercises the actual FUSE-backed staging path.

The main derivation no longer builds the pytest/test-fixture inputs at
all (they're only needed by the VM test), keeping just
`versionCheckHook` for the existing install-check.

`bst` is a buildPythonApplication, so its own site-packages only
contains buildstream's own files, not the propagated runtime deps
(protobuf, grpcio, click, ...) that only reach the wrapped `bst`
script's own PYTHONPATH; `toPythonModule` reinterprets it as a regular
library so `withPackages` pulls in its full dependency closure for
`pytest` to import from.

The default `diskSize = "auto"` only sizes the VM's root filesystem to
fit the system closure, with no scratch space; the suite builds real
CAS/cache artifacts under pytest's basetemp for hundreds of
parametrized cases, easily exceeding that. Bumped disk/memory sizing
to comfortably cover a full run.

Verified this run passes: `nix-build -E 'let pkgs = import ./. {}; in
pkgs.nixosTests.buildstream.test'` completes successfully.

Assisted-by: Claude <noreply@anthropic.com>
2026-10-02 23:27:47 +01:00

113 lines
2.3 KiB
Nix

{
lib,
python3Packages,
fetchFromGitHub,
gitUpdater,
nixosTests,
# buildInputs
buildbox,
fuse3,
lzip,
patch,
# nativeBuildInputs
installShellFiles,
# tests
versionCheckHook,
# Optional features
enableBuildstreamPlugins ? true,
}:
python3Packages.buildPythonApplication (finalAttrs: {
pname = "buildstream";
version = "2.8.1";
pyproject = true;
src = fetchFromGitHub {
owner = "apache";
repo = "buildstream";
tag = finalAttrs.version;
hash = "sha256-i46AdbGk/xGZeyh6bxQd1J3L3EH/oIcjX9cJSDscfH0=";
};
build-system = with python3Packages; [
cython
pdm-pep517
setuptools
setuptools-scm
];
dependencies = [
buildbox
]
++ (with python3Packages; [
click
grpcio
jinja2
markupsafe
packaging
pluginbase
protobuf
psutil
pyroaring
ruamel-yaml
ruamel-yaml-clib
ujson
])
++ lib.optionals enableBuildstreamPlugins [
python3Packages.buildstream-plugins
];
nativeBuildInputs = [
installShellFiles
];
buildInputs = [
fuse3
lzip
patch
];
# /dev/fuse is not available inside the Nix build sandbox, so buildbox-casd's
# default FUSE-based staging strategy cannot work here, and the shebang used
# by tests/internals/cascache.py's dummy buildbox-casd scripts
# (`/usr/bin/env sh`) doesn't exist there either. The pytest suite is run as
# a NixOS VM test instead, where both of those are available; see
# `passthru.tests.pytest`.
pythonImportsCheck = [ "buildstream" ];
nativeCheckInputs = [
versionCheckHook
];
postInstall = ''
installShellCompletion --cmd bst \
--bash src/buildstream/data/bst \
--zsh src/buildstream/data/zsh/_bst
'';
versionCheckProgram = "${placeholder "out"}/bin/bst";
passthru = {
updateScript = gitUpdater {
ignoredVersions = "dev";
};
tests.pytest = nixosTests.buildstream;
};
meta = {
changelog = "https://github.com/apache/buildstream/blob/${finalAttrs.src.tag}/NEWS";
description = "Powerful software integration tool";
downloadPage = "https://buildstream.build/install.html";
homepage = "https://buildstream.build";
license = lib.licenses.asl20;
platforms = lib.platforms.linux;
mainProgram = "bst";
maintainers = with lib.maintainers; [ shymega ];
};
})