mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
libglycin: Introduce setup hook for adding loader paths to wrapper
This setup hook discovers glycin loaders in the inputs list it is placed into, and adds them to `gappsWrapperArgs`. This should simplify glycin-dependent programs’ expressions. Just add `libglycin.setupHook` (for Rust programs) or `libglycin` (for other languages) to `buildInputs`. The latter will also pull in the setup hook. Note, the setup hook needs to go to the `buildInputs` since we cannot have a different offset when used as standalone hook instead of propagated from `libglycin`. We chose `hostOffset` to make it work with the proper placement of `libglycin` in `buildInputs`. Co-authored-by: Seth Flynn <getchoo@tuta.io> Co-authored-by: Jan Tojnar <jtojnar@gmail.com>
This commit is contained in:
committed by
Jan Tojnar
parent
c68c6af86c
commit
1def69720c
@@ -2,7 +2,7 @@
|
||||
|
||||
[Glycin](https://gitlab.gnome.org/GNOME/glycin) is a library for sandboxed and extendable image loading.
|
||||
|
||||
For most applications using it, individual image formats are loaded through binaries provided by `glycin-loaders`. The paths of these loaders must be injected into the environment, e.g. using [`wrapGAppsHook`](#ssec-gnome-hooks).
|
||||
[]{#libglycin-setup-hook} For most applications using it, individual image formats are loaded through binaries provided by `glycin-loaders`. The paths of these loaders must be injected into the environment, e.g. using [`wrapGAppsHook`](#ssec-gnome-hooks). `libglycin.setupHook` will do that.
|
||||
|
||||
[]{#libglycin-patch-vendor-hook} Additionally, for Rust projects `glycin` Rust crate itself requires a patch to become self-contained. `libglycin.patchVendorHook` will do that. This is not needed for projects using the ELF library from `libglycin` package.
|
||||
|
||||
@@ -27,11 +27,10 @@ rustPlatform.buildRustPackage {
|
||||
libglycin.patchVendorHook
|
||||
];
|
||||
|
||||
preFixup = ''
|
||||
gappsWrapperArgs+=(
|
||||
--prefix XDG_DATA_DIRS : "${glycin-loaders}/share"
|
||||
)
|
||||
'';
|
||||
buildInputs = [
|
||||
libglycin.setupHook
|
||||
glycin-loaders
|
||||
];
|
||||
|
||||
# ...
|
||||
}
|
||||
@@ -42,3 +41,7 @@ rustPlatform.buildRustPackage {
|
||||
### `glycinCargoDepsPath` {#glycin-cargo-deps-path}
|
||||
|
||||
Path to a directory containing the `glycin` crate to patch. Defaults to the crate directory created by `cargoSetupHook`, or `./vendor/`.
|
||||
|
||||
### `dontWrapGlycinLoaders` {#glycin-dont-wrap}
|
||||
|
||||
Disable adding the Glycin loaders path `XDG_DATA_DIRS` with `wrapGAppsHook`.
|
||||
|
||||
@@ -129,6 +129,8 @@ The hooks do the following:
|
||||
|
||||
- []{#ssec-gnome-hooks-gst-grl-plugins} Setup hooks of `gst_all_1.gstreamer` and `grilo` will populate the `GST_PLUGIN_SYSTEM_PATH_1_0` and `GRL_PLUGIN_PATH` variables, respectively, which will then be added to the wrapper by `wrapGApps*` hook.
|
||||
|
||||
- []{#ssec-gnome-hooks-libglycin} `libglycin`'s [setup hook](#libglycin-setup-hook) will populate `XDG_DATA_DIRS` with the path to the loaders.
|
||||
|
||||
You can also pass additional arguments to `makeWrapper` using `gappsWrapperArgs` in `preFixup` hook:
|
||||
|
||||
```nix
|
||||
|
||||
@@ -2471,6 +2471,9 @@
|
||||
"libglycin-hooks": [
|
||||
"index.html#libglycin-hooks"
|
||||
],
|
||||
"libglycin-setup-hook": [
|
||||
"index.html#libglycin-setup-hook"
|
||||
],
|
||||
"libglycin-patch-vendor-hook": [
|
||||
"index.html#libglycin-patch-vendor-hook"
|
||||
],
|
||||
@@ -2483,6 +2486,9 @@
|
||||
"glycin-cargo-deps-path": [
|
||||
"index.html#glycin-cargo-deps-path"
|
||||
],
|
||||
"glycin-dont-wrap": [
|
||||
"index.html#glycin-dont-wrap"
|
||||
],
|
||||
"ghc": [
|
||||
"index.html#ghc"
|
||||
],
|
||||
@@ -3173,6 +3179,9 @@
|
||||
"ssec-gnome-hooks-gst-grl-plugins": [
|
||||
"index.html#ssec-gnome-hooks-gst-grl-plugins"
|
||||
],
|
||||
"ssec-gnome-hooks-libglycin": [
|
||||
"index.html#ssec-gnome-hooks-libglycin"
|
||||
],
|
||||
"ssec-gnome-updating": [
|
||||
"index.html#ssec-gnome-updating"
|
||||
],
|
||||
|
||||
@@ -38,6 +38,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"devdoc"
|
||||
];
|
||||
|
||||
setupHook = ./path-hook.sh;
|
||||
|
||||
src = fetchFromGitLab {
|
||||
domain = "gitlab.gnome.org";
|
||||
owner = "GNOME";
|
||||
|
||||
18
pkgs/by-name/li/libglycin/path-hook.sh
Normal file
18
pkgs/by-name/li/libglycin/path-hook.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
find_glycin_loader_paths() {
|
||||
if [ -d "$1/share/glycin-loaders" ]; then
|
||||
addToSearchPath NIX_GLYCIN_LOADER_PATHS $1/share
|
||||
fi
|
||||
}
|
||||
|
||||
addEnvHooks "$hostOffset" find_glycin_loader_paths
|
||||
|
||||
glycinLoadersWrapperArgsHook() {
|
||||
echo "executing glycinLoadersWrapperArgsHook"
|
||||
if [[ -n "$NIX_GLYCIN_LOADER_PATHS" ]]; then
|
||||
gappsWrapperArgs+=(--prefix XDG_DATA_DIRS : "$NIX_GLYCIN_LOADER_PATHS")
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ -z ${dontWrapGlycinLoaders:-} ]]; then
|
||||
preFixupPhases+=(glycinLoadersWrapperArgsHook)
|
||||
fi
|
||||
Reference in New Issue
Block a user