Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup hook of gobject-introspection in nativeBuildInputs does not run with strictDeps #56943

Closed
emmanuelrosa opened this issue Mar 6, 2019 · 17 comments · Fixed by #57385
Closed
Labels
0.kind: bug 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: GNOME GNOME desktop environment and its underlying platform

Comments

@emmanuelrosa
Copy link
Contributor

Issue description

virt-manager fails to load and instead produces the error "Namespace LibvirtGLib not available"

Traceback (most recent call last):
  File "/nix/store/b8na689bifds8z2xg1bragbw54mznppa-virt-manager-2.1.0/share/virt-manager/virt-manager", line 17, in <module>                                                                   
    gi.require_version('LibvirtGLib', '1.0')
  File "/nix/store/kiw47xswi1041sbvbgrlfy0xs0zlwyvk-python3.7-pygobject-3.30.4/lib/python3.7/site-packages/gi/__init__.py", line 129, in require_version                                        
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace LibvirtGLib not available

I'm aware of #33754 and #34000. I have the changes in the merged commit. Yet, I receive the error.

Steps to reproduce

  1. Install virt-manager
  2. Open a terminal and run virt-manager

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.14.104, NixOS, 19.09.git.27cb066 (Loris)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.2
  • channels(root): "nixos-19.09pre171582.26d8a8c0eb2"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

NOTE: My nixpkgs is not as shown above but rather a clone of this repo at commit 27cb066

@jtojnar jtojnar added 0.kind: bug 6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: cross-compilation Building packages on a different platform than they will be used on labels Mar 6, 2019
@jtojnar
Copy link
Member

jtojnar commented Mar 6, 2019

I think this is another issue caused strictDeps being enabled for Python packages (#54182); I also noticed it in #56783 (comment).

strictDeps probably prevents the setup hook in nativeBuildInputs from running; though, I would expect hostOffset to work:

addEnvHooks "$hostOffset" make_gobject_introspection_find_gir_files

We will need to fix the setup hook? cc @Ericson2314 @hedning

@jtojnar jtojnar changed the title virt-manager: Fails to load with the error "Namespace LibvirtGLib not available" setup hook of gobject-introspection in nativeBuildInputs does not run with strictDeps Mar 6, 2019
@Ericson2314
Copy link
Member

Ericson2314 commented Mar 7, 2019

gobject-introspection is a terrible thing that makes cross compilation impossible. Try adding it as both as a buildInput and nativeBuildInput to get native builds working.

CC @eternaleye

@jtojnar
Copy link
Member

jtojnar commented Mar 7, 2019

Is there nothing else we can do to make addEnvHooks "$hostOffset" work with the setup hook?

@jtojnar
Copy link
Member

jtojnar commented Mar 9, 2019

It is even more serious

with import <nixpkgs> {};
stdenv.mkDerivation {
  name = "setup-hook-test";
  unpackPhase = ":";
  dontBuild = true;
  nativeBuildInputs = [ wrapGAppsHook ];
  installPhase = ''
    runHook preInstall
    mkdir -p $out/bin
    touch $out/bin/test
    chmod +x $out/bin/test
    runHook postInstall
  '';
}

does not even pick up the librsvg dependency

wrapGAppsHook = makeSetupHook {
deps = lib.optional (!stdenv.isDarwin) gnome3.dconf.lib ++ [ gtk3 librsvg makeWrapper ];
} ../build-support/setup-hooks/wrap-gapps-hook.sh;

for GDK_PIXBUF_MODULE_FILE. Curiously, it detects dconf; and multiple times at that:

#! /nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23/bin/bash -e
export GIO_EXTRA_MODULES='/nix/store/h9wqk3nx4h020xrvha2si7y01alk337w-dconf-0.30.1-lib/lib/gio/modules'${GIO_EXTRA_MODULES:+':'}$GIO_EXTRA_MODULES
export GIO_EXTRA_MODULES='/nix/store/h9wqk3nx4h020xrvha2si7y01alk337w-dconf-0.30.1-lib/lib/gio/modules'${GIO_EXTRA_MODULES:+':'}$GIO_EXTRA_MODULES
exec -a "$0" "/nix/store/16khixg577v3f2bdfs30mhj6n8l6hsq2-setup-hook-test/bin/.test-wrapped"  "${extraFlagsArray[@]}" "$@"

are setup hooks not propagated any more? If I add gdk-pixbuf, librsvg will suddenly be picked up:

with import <nixpkgs> {};
stdenv.mkDerivation {
  name = "setup-hook-test";
  unpackPhase = ":";
  dontBuild = true;
  buildInputs = [ ];
  nativeBuildInputs = [ wrapGAppsHook gdk_pixbuf ];
  installPhase = ''
    runHook preInstall
    mkdir -p $out/bin
    touch $out/bin/test
    chmod +x $out/bin/test
    runHook postInstall
  '';
}
#! /nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23/bin/bash -e
export GIO_EXTRA_MODULES='/nix/store/h9wqk3nx4h020xrvha2si7y01alk337w-dconf-0.30.1-lib/lib/gio/modules'${GIO_EXTRA_MODULES:+':'}$GIO_EXTRA_MODULES
export GIO_EXTRA_MODULES='/nix/store/h9wqk3nx4h020xrvha2si7y01alk337w-dconf-0.30.1-lib/lib/gio/modules'${GIO_EXTRA_MODULES:+':'}$GIO_EXTRA_MODULES
export GDK_PIXBUF_MODULE_FILE='/nix/store/w073vf5lhf08n1pg77qsinq5qqdaymqy-librsvg-2.44.12/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache'
export XDG_DATA_DIRS='/nix/store/ialw7015yr8wm578d4j09fi3ay5hk96c-gtk+3-3.24.5/share/gsettings-schemas/gtk+3-3.24.5:/nix/store/ialw7015yr8wm578d4j09fi3ay5hk96c-gtk+3-3.24.5/share/gsettings-schemas/gtk+3-3.24.5:/nix/store/ialw7015yr8wm578d4j09fi3ay5hk96c-gtk+3-3.24.5/share/gsettings-schemas/gtk+3-3.24.5'${XDG_DATA_DIRS:+':'}$XDG_DATA_DIRS
exec -a "$0" "/nix/store/pfk5qj7gnhjzkmklyns7svdmqqc8afkh-setup-hook-test/bin/.test-wrapped"  "${extraFlagsArray[@]}" "$@"

But I guess since librsvg is propagated by the hook in nativeBuildInputs it will be the native version. We would need to propagate it to offset -1. All this bash magic makes my head tumble.

@FRidh
Copy link
Member

FRidh commented Mar 10, 2019

As a last resort strictDeps could be disabled for this expression.

@jtojnar
Copy link
Member

jtojnar commented Mar 12, 2019

Still need to fix the underlying issue.

@jtojnar jtojnar reopened this Mar 12, 2019
@Ericson2314
Copy link
Member

Listing twice is not a hack in my mind. It is the proper way to indicate that a dependency is both a build and run time dependency.

@Ericson2314
Copy link
Member

For that second issue, I don't remember setup hooks being automatically propagated ever, but a setup can propagate a dependency that it will itself pick up.

@jtojnar
Copy link
Member

jtojnar commented Mar 13, 2019

Well, in my mind, it is not a run time dependency (at least not a direct one). Most of the time, it is only used during build for the setup hook.

@jtojnar
Copy link
Member

jtojnar commented Mar 13, 2019

After discussion on IRC we have decided to move make_gobject_introspection_find_gir_files and giDiscoverSelf into a separated setup hook and to add make_gobject_introspection_find_gir_files to $targetOffset.

@Artturin
Copy link
Member

Artturin commented Sep 9, 2022

Fixed by 71cbf3b

gobject-introspection has to in nativeBuildInputs for the hook to work properly

if a typelib from gobject-introspection is needed then gobject-introspection has to be added to buildInputs (until #189215 is in master)

$ pwd
/nix/store/j68vcd82l5xx76jqida4zqk0nw55b6cm-gobject-introspection-1.72.0/lib/girepository-1.0
$ \ls
cairo-1.0.typelib  DBusGLib-1.0.typelib    freetype2-2.0.typelib  GIRepository-2.0.typelib  GLib-2.0.typelib	GObject-2.0.typelib  Vulkan-1.0.typelib  xfixes-4.0.typelib  xlib-2.0.typelib
DBus-1.0.typelib   fontconfig-2.0.typelib  Gio-2.0.typelib	 GL-1.0.typelib	   GModule-2.0.typelib  libxml2-2.0.typelib  win32-1.0.typelib   xft-2.0.typelib     xrandr-1.3.typelib

OPNA2608 added a commit to OPNA2608/nixpkgs that referenced this issue Dec 19, 2022
Fixes the following error when trying to run the final script:

Traceback (most recent call last):
  File "/nix/store/z1klbgg6p9v3vszjyvsjix9s4blsl7mv-gkraken-1.2.0/bin/.gkraken-wrapped", line 45, in <module>
    gi.require_version('Gtk', '3.0')
  File "/nix/store/k46f21qglnnl2grkx6gq6j6jlawfkgpw-python3.10-pygobject-3.42.2/lib/python3.10/site-packages/gi/__init__.py", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available

See NixOS#56943
@OPNA2608 OPNA2608 mentioned this issue Dec 19, 2022
13 tasks
github-actions bot pushed a commit that referenced this issue Dec 21, 2022
Fixes the following error when trying to run the final script:

Traceback (most recent call last):
  File "/nix/store/z1klbgg6p9v3vszjyvsjix9s4blsl7mv-gkraken-1.2.0/bin/.gkraken-wrapped", line 45, in <module>
    gi.require_version('Gtk', '3.0')
  File "/nix/store/k46f21qglnnl2grkx6gq6j6jlawfkgpw-python3.10-pygobject-3.42.2/lib/python3.10/site-packages/gi/__init__.py", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available

See #56943

(cherry picked from commit 901a78b)
Artturin added a commit to Artturin/nixpkgs that referenced this issue Feb 10, 2023
checked with diffoscope+difflog and launching the programs

i have fixed that issue in my other gir PRs
Artturin added a commit to Artturin/nixpkgs that referenced this issue Feb 17, 2023
checked with diffoscope+difflog and launching the programs

i have fixed that issue in my other gir PRs
MichaelPachec0 added a commit to MichaelPachec0/flake-playground that referenced this issue Apr 3, 2024
* do not do double wrapping. See: https://github.com/NixOS/nixpkgs/blob/nixos-23.11/doc/languages-frameworks/gnome.section.md#when-using-wrapgappshook-with-special-derivers-you-can-end-up-with-double-wrapped-binaries-ssec-gnome-common-issues-double-wrapped
  there is probably a better of doing this, but for now this works.
* finally fix gi issues, NixOS/nixpkgs#56943 (comment) helped, but including wrapGAppsHook was also part of the fix.
* cleanup dependencies, there is no need for gi to exist in propagatedBuildInputs and BuildInputs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: GNOME GNOME desktop environment and its underlying platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants