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
glava: init at v1.4.5 #42103
glava: init at v1.4.5 #42103
Conversation
ff0307a
to
5540be9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it would be nice to have this in nixpkgs, it throws an error when I actually run it:
Using backend: 'glx'
Failed to load GLX functions (libGL and libGLX do not exist!)
fixupPhase = '' | ||
mkdir -p $out/bin | ||
|
||
ln -sT $out/usr/bin/glava $out/bin/glava |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Binaries shouldn't be in $out/usr/bin in any case, so you should move it to $out/bin/glava instead and remove the /usr folder
]; | ||
|
||
patchPhase = '' | ||
cp -rt glad --no-preserve=all ${glad}/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more conventional to have the target at the end: cp -r --no-preserve=all ${glad}/* glad
buildInputs = [ | ||
libX11 | ||
libXext | ||
python3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python should be in nativeBuildInputs
(it's only used during the build afaik)
The way I get
|
Seems to work if I just copy the libs from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I figured it out, it apparently uses dlopen to find the library files: https://github.com/wacossusca34/glava/blob/ebade264ea1855afe88421ccc3ec22fc835696dc/glx_wcb.c#L191-L192
To make this work, you need to add patchelf --set-rpath "${makeLibraryPath [ libGL ]}"
in postFixup
. Pretty sure at least. Or you could patch the source directly.
(Having applied the bad fix for now), the next error I get is when running glava --copy-config
, because it expects the default config to be in /etc/xdg/glava
, but it's really in /nix/store/<hash>-glava/etc/xdg/glava
. You can use substituteInPlace
to patch this: https://github.com/wacossusca34/glava/blob/ebade264ea1855afe88421ccc3ec22fc835696dc/glava.c#L57
|
||
fixupPhase = '' | ||
mv $out/usr/bin $out/bin | ||
rm -rf $out/usr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: rmdir $out/usr
, since this dir is empty here
] ++ optional enableGlfw glfw; | ||
|
||
nativeBuildInputs = [ | ||
pkgconfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Builds fine without pkgconfig.
fixupPhase = '' | ||
cp -r ${libGL}/lib $out/lib | ||
mv $out/usr/bin $out/bin | ||
rm -rf $out/usr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Since this directory will be empty, you can use rmdir $out/usr
, also makes sure that we don't accidentally remove something in case it ever installs anything else in /usr.
@@ -0,0 +1,85 @@ | |||
{ stdenv, fetchurl, fetchFromGitHub, pkgconfig | |||
, libGL, libX11, libXext, python3, libXrandr, libXrender, libpulseaudio, libXcomposite | |||
, enableGlfw ? false, glfw }: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know much about OpenGL, but why is this disabled by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem to be a required dependency so I just left it out by default.
GLFW 3.1+ (optional, disable with DISABLE_GLFW=1)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, it runs well :D
Yeah the --copy-config is a problem. I think the easiest solution would be to wrap the binary with a small shell script that catches the --copy-config flag and does its own copying of the config (with no symlinking), without passing the flag onto the actual glava executable. Feel free to create such a wrapper, but I'm fine without one.
Edit: Let me know whether you wanna try to make the wrapper or not, I'll wait with merging.
Actually that just looks like the default behavior so I'll just leave it like that. |
The problem is that the symlinks will be to /nix/store/hash-glava/... which will be garbage collected eventually, breaking the config. |
Currently I have the following, though I can't seem to expand writeScript "glava" ''
#!${stdenv.shell}
case "$1" in
--copy-config)
cp -r $out/etc/xdg/glava ~/.config/glava
;;
*)
$out/usr/bin/glava $@
esac
'' |
Ended up just replacing |
There are a couple things to correct again, I hope you don't mind the constant back-and-forth! Here's a patch: diff --git a/pkgs/applications/misc/glava/default.nix b/pkgs/applications/misc/glava/default.nix
index 64bc20fc11a..d115d1ae1d2 100644
--- a/pkgs/applications/misc/glava/default.nix
+++ b/pkgs/applications/misc/glava/default.nix
@@ -30,10 +30,14 @@ let
#!${stdenv.shell}
case "$1" in
--copy-config)
- cp -r --no-preserve=all $out/etc/xdg/glava ~/.config/glava
+ # The binary would symlink it, which won't work in Nix because the
+ # garbage collector will eventually remove the original files after
+ # updates
+ echo "Nix wrapper: Copying glava config to ~/.config/glava"
+ cp -r --no-preserve=all @out@/etc/xdg/glava ~/.config/glava
;;
*)
- $out/usr/bin/glava $@
+ exec @out@/bin/.glava-unwrapped "$@"
esac
'';
in
@@ -77,11 +81,14 @@ in
fixupPhase = ''
mkdir -p $out/bin
- patchelf \
- --set-rpath "$(patchelf --print-rpath $out/usr/bin/glava):${makeLibraryPath [ libGL ]}" \
- $out/usr/bin/glava
- cp ${wrapperScript} $out/bin/glava
- substituteInPlace $out/bin/glava --replace "\$out" "$out"
+ mv $out/usr/bin/glava $out/bin/.glava-unwrapped
+ rm -rf $out/usr
+
+ patchelf $out/bin/.glava-unwrapped \
+ --set-rpath "$(patchelf --print-rpath $out/bin/.glava-unwrapped):${makeLibraryPath [ libGL ]}" \
+
+ substitute ${wrapperScript} $out/bin/glava --subst-var out
+ chmod +x $out/bin/glava
'';
meta = with stdenv.lib; { Things to note:
|
It's fine, applied patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)