From 5ee4899006f015119d37c0238be3a3a92766bffc Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 20 Apr 2025 08:11:28 +0000 Subject: [PATCH] blueprint-compiler: wrap with required dependencies without this, `blueprint-compiler` fails when trying to import GIR files required by the compiler itself -- even for basic commands like `blueprint-compiler --help` or `blueprint-compiler --version`. `passthru.tests.version` passes because blueprint-compiler propagates `gobject-introspection`, which has a setup hook that configures `GI_TYPELIB_PATH` to have the required GIR files. but setup hooks are only run within nix builds, and conditional on the hook being in `nativeBuildInputs`. the result is that the following previously _didn't_ work: ``` $ nix-build -A blueprint-compiler $ ./result/bin/blueprint-compiler --help ``` an additional consequence of this patch is that several consumers of blueprint-compiler now cross compile correctly: - blanket - komikku - ... previously, blueprint-compiler did not work in a cross compiling environment, because the gobject-introspection setup-hook configures GI_TYPELIB_PATH for the _host_, which is generally not the same host on which blueprint-compiler is being run (i.e. the build machine). a consumer of blueprint-compiler has (in effect) build inputs like: ``` nativeBuildInputs | buildInputs ----------------------------------- blueprint-compiler | gobject-introspection | | glib | gtk | adwaita ... | ... ``` gobject-introspection's setup-hook populates GI_TYPELIB_PATH from the buildInputs; this is correct when blueprint-compiler is querying typelibs to generate code against, however before it gets to that point it needs to import its _own_ typelib dependencies (glib and gobject-introspection). this is made possible by wrapGAppsNoGuiHook, which wraps blueprint-compiler with a copy of those typelibs built for the same platform as it. --- pkgs/by-name/bl/blueprint-compiler/package.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/bl/blueprint-compiler/package.nix b/pkgs/by-name/bl/blueprint-compiler/package.nix index 6ffd8a7337f6..b66748db09c9 100644 --- a/pkgs/by-name/bl/blueprint-compiler/package.nix +++ b/pkgs/by-name/bl/blueprint-compiler/package.nix @@ -7,8 +7,10 @@ meson, ninja, python3, + runCommand, stdenv, testers, + wrapGAppsNoGuiHook, xvfb-run, }: stdenv.mkDerivation (finalAttrs: { @@ -30,6 +32,7 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ meson ninja + wrapGAppsNoGuiHook ]; buildInputs = [ @@ -64,8 +67,17 @@ stdenv.mkDerivation (finalAttrs: { runHook postCheck ''; - passthru.tests.version = testers.testVersion { - package = finalAttrs.finalPackage; + passthru.tests = { + version = testers.testVersion { + package = finalAttrs.finalPackage; + }; + # regression test that `blueprint-compiler` can be used in a standalone + # context outside of nix builds, and doesn't rely on the setup hooks of + # its propagated inputs for basic functionality. + # see https://github.com/NixOS/nixpkgs/pull/400415 + standalone = runCommand "blueprint-compiler-test-standalone" { } '' + ${lib.getExe finalAttrs.finalPackage} --help && touch $out + ''; }; meta = with lib; {