biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / misc / glava / default.nix
blobdf5d6138d35f674eba81f22df890b33b4e749e0d
1 { lib, stdenv, writeScript, fetchFromGitHub
2 , libGL, libX11, libXext, python3, libXrandr, libXrender, libpulseaudio, libXcomposite
3 , enableGlfw ? false, glfw, runtimeShell }:
5 let
6   inherit (lib) optional makeLibraryPath;
8   wrapperScript = writeScript "glava" ''
9     #!${runtimeShell}
10     case "$1" in
11       --copy-config|-C)
12         # The binary would symlink it, which won't work in Nix because the
13         # garbage collector will eventually remove the original files after
14         # updates
15         echo "Nix wrapper: Copying glava config to ~/.config/glava"
16         cp -r --no-preserve=all @out@/etc/xdg/glava ~/.config/glava
17         ;;
18       *)
19         exec @out@/bin/.glava-unwrapped "$@"
20     esac
21   '';
23   stdenv.mkDerivation rec {
24     pname = "glava";
25     version = "1.6.3";
27     src = fetchFromGitHub {
28       owner = "wacossusca34";
29       repo = "glava";
30       rev = "v${version}";
31       sha256 = "0kqkjxmpqkmgby05lsf6c6iwm45n33jk5qy6gi3zvjx4q4yzal1i";
32     };
34     buildInputs = [
35       libX11
36       libXext
37       libXrandr
38       libXrender
39       libpulseaudio
40       libXcomposite
41     ] ++ optional enableGlfw glfw;
43     nativeBuildInputs = [
44       python3
45     ];
47     preConfigure = ''
48       for f in $(find -type f);do
49         substituteInPlace $f \
50           --replace /etc/xdg $out/etc/xdg
51       done
53       substituteInPlace Makefile \
54         --replace '$(DESTDIR)$(SHADERDIR)' '$(SHADERDIR)'
56       substituteInPlace Makefile \
57         --replace 'unknown' 'v${version}'
58     '';
60     makeFlags = optional (!enableGlfw) "DISABLE_GLFW=1";
62     installFlags = [
63       "DESTDIR=$(out)"
64     ];
66     fixupPhase = ''
67       mkdir -p $out/bin
68       mv $out/usr/bin/glava $out/bin/.glava-unwrapped
69       rm -rf $out/usr
71       patchelf \
72         --set-rpath "$(patchelf --print-rpath $out/bin/.glava-unwrapped):${makeLibraryPath [ libGL ]}" \
73         $out/bin/.glava-unwrapped
75       substitute ${wrapperScript} $out/bin/glava --subst-var out
76       chmod +x $out/bin/glava
77     '';
79     meta = with lib; {
80       description = ''
81         OpenGL audio spectrum visualizer
82       '';
83       mainProgram = "glava";
84       homepage = "https://github.com/wacossusca34/glava";
85       platforms = platforms.linux;
86       license = licenses.gpl3;
87       maintainers = with maintainers; [
88         eadwu
89       ];
90     };
91   }