5 , gobject-introspection
16 name = "wrap-gapps-hook";
17 propagatedBuildInputs = [
18 # We use the wrapProgram function.
20 ] ++ lib.optionals isGraphical [
21 # TODO: remove this, packages should depend on GTK explicitly.
27 # depsTargetTargetPropagated will essentially be buildInputs when wrapGAppsHook3 is placed into nativeBuildInputs
28 # the librsvg and gtk3 above should be removed but kept to not break anything that implicitly depended on its binaries
29 depsTargetTargetPropagated = assert (lib.assertMsg (!targetPackages ? raw) "wrapGAppsHook3 must be in nativeBuildInputs"); lib.optionals isGraphical [
30 # librsvg provides a module for gdk-pixbuf to allow rendering
31 # SVG icons. Most icon themes are SVG-based and so are some
32 # graphics in GTK (e.g. cross for closing window in window title bar)
33 # so it is pretty much required for applications using GTK.
36 # TODO: remove this, packages should depend on GTK explicitly.
38 ] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
39 # It is highly probable that a program will use GSettings,
40 # at minimum through GTK file chooser dialogue.
41 # Let’s add a GIO module for “dconf” GSettings backend
42 # to avoid falling back to “memory” backend. This is
43 # required for GSettings-based settings to be persisted.
44 # Unfortunately, it also requires the user to have dconf
45 # D-Bus service enabled globally (e.g. through a NixOS module).
50 sample-project = ./tests/sample-project;
52 testLib = callPackage ./tests/lib.nix { };
53 inherit (testLib) expectSomeLineContainingYInFileXToMentionZ;
55 # Simple derivation containing a program and a daemon.
56 basic = stdenv.mkDerivation {
62 nativeBuildInputs = [ wrapGAppsHook3 ];
64 installFlags = [ "bin-foo" "libexec-bar" ];
67 # The wrapper for executable files should add path to dconf GIO module.
68 basic-contains-dconf = let
70 in testLib.runTest "basic-contains-dconf" (
71 testLib.skip stdenv.hostPlatform.isDarwin ''
72 ${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GIO_EXTRA_MODULES" "${dconf.lib}/lib/gio/modules"}
73 ${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GIO_EXTRA_MODULES" "${dconf.lib}/lib/gio/modules"}
77 basic-contains-gdk-pixbuf = let
79 in testLib.runTest "basic-contains-gdk-pixbuf" (
80 testLib.skip stdenv.hostPlatform.isDarwin ''
81 ${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GDK_PIXBUF_MODULE_FILE" "${lib.getLib librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"}
82 ${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GDK_PIXBUF_MODULE_FILE" "${lib.getLib librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"}
86 # Simple derivation containing a gobject-introspection typelib.
87 typelib-Mahjong = stdenv.mkDerivation {
88 name = "typelib-Mahjong";
94 installFlags = [ "typelib-Mahjong" ];
97 # Simple derivation using a typelib.
98 typelib-user = stdenv.mkDerivation {
99 name = "typelib-user";
101 src = sample-project;
104 nativeBuildInputs = [
105 gobject-introspection
113 installFlags = [ "bin-foo" "libexec-bar" ];
116 # Testing cooperation with gobject-introspection setup hook,
117 # which should populate GI_TYPELIB_PATH variable with paths
118 # to typelibs among the derivation’s dependencies.
119 # The resulting GI_TYPELIB_PATH should be picked up by the wrapper.
120 typelib-user-has-gi-typelib-path = let
121 tested = typelib-user;
122 in testLib.runTest "typelib-user-has-gi-typelib-path" ''
123 ${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GI_TYPELIB_PATH" "${typelib-Mahjong}/lib/girepository-1.0"}
124 ${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GI_TYPELIB_PATH" "${typelib-Mahjong}/lib/girepository-1.0"}
127 # Simple derivation containing a gobject-introspection typelib in lib output.
128 typelib-Bechamel = stdenv.mkDerivation {
129 name = "typelib-Bechamel";
131 outputs = [ "out" "lib" ];
133 src = sample-project;
138 "LIBDIR=${placeholder "lib"}/lib"
141 installFlags = [ "typelib-Bechamel" ];
144 # Simple derivation using a typelib from non-default output.
145 typelib-multiout-user = stdenv.mkDerivation {
146 name = "typelib-multiout-user";
148 src = sample-project;
151 nativeBuildInputs = [
152 gobject-introspection
160 installFlags = [ "bin-foo" "libexec-bar" ];
163 # Testing cooperation with gobject-introspection setup hook,
164 # which should populate GI_TYPELIB_PATH variable with paths
165 # to typelibs among the derivation’s dependencies,
166 # even when they are not in default output.
167 # The resulting GI_TYPELIB_PATH should be picked up by the wrapper.
168 typelib-multiout-user-has-gi-typelib-path = let
169 tested = typelib-multiout-user;
170 in testLib.runTest "typelib-multiout-user-has-gi-typelib-path" ''
171 ${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GI_TYPELIB_PATH" "${typelib-Bechamel.lib}/lib/girepository-1.0"}
172 ${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GI_TYPELIB_PATH" "${typelib-Bechamel.lib}/lib/girepository-1.0"}
175 # Simple derivation that contains a typelib as well as a program using it.
176 typelib-self-user = stdenv.mkDerivation {
177 name = "typelib-self-user";
179 src = sample-project;
182 nativeBuildInputs = [
183 gobject-introspection
187 installFlags = [ "typelib-Cow" "bin-foo" "libexec-bar" ];
190 # Testing cooperation with gobject-introspection setup hook,
191 # which should add the path to derivation’s own typelibs
192 # to GI_TYPELIB_PATH variable.
193 # The resulting GI_TYPELIB_PATH should be picked up by the wrapper.
194 # https://github.com/NixOS/nixpkgs/issues/85515
195 typelib-self-user-has-gi-typelib-path = let
196 tested = typelib-self-user;
197 in testLib.runTest "typelib-self-user-has-gi-typelib-path" ''
198 ${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GI_TYPELIB_PATH" "${typelib-self-user}/lib/girepository-1.0"}
199 ${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GI_TYPELIB_PATH" "${typelib-self-user}/lib/girepository-1.0"}
203 } ./wrap-gapps-hook.sh