diff --git a/cd.nix b/cd.nix index 153857e..9bd2e07 100644 --- a/cd.nix +++ b/cd.nix @@ -3,6 +3,7 @@ , fetchurl , lsb-release , pkg-config +, gtk2 , gtk3 , im , libGL @@ -10,6 +11,7 @@ , lua , ftgl-tecgraf , lib +, withGTK3 ? false }: let @@ -29,7 +31,7 @@ in stdenv.mkDerivation rec { ]; buildInputs = [ - gtk3 + (if withGTK3 then gtk3 else gtk2) libGL libGLU lua @@ -49,12 +51,11 @@ in stdenv.mkDerivation rec { "NO_DEPEND=Yes" "USE_PKGCONFIG=Yes" "USE_LUA_VERSION=52" - "USE_GTK3=Yes" "GTK_DEFAULT=Yes" "FTGL_LIB=${ftgl-tecgraf}/lib" "FTGL_INC=${ftgl-tecgraf}/include" - ]; + ] ++ (if withGTK3 then [ "USE_GTK3=Yes" ] else [ "USE_GTK2=Yes" ]); NIX_CFLAGS_COMPILE = '' -Wno-incompatible-pointer-types @@ -64,12 +65,12 @@ in stdenv.mkDerivation rec { "cd" "A vector graphics toolkit with device independent output" version - "gdk-3.0 pango" + (if withGTK3 then "gdk-3.0 pango" else "gdk-2.0 pango") ); cdcontextplusPc = builtins.toFile "cdcontextplus.pc" (makePc "cdcontextplus" - "A vector graphics toolkit with device independent output (dynamic driver loader" + "A vector graphics toolkit with device independent output (dynamic driver loader)" version "pangocairo cairo" ); diff --git a/iup.nix b/iup.nix index 95dc9e3..627575c 100644 --- a/iup.nix +++ b/iup.nix @@ -4,6 +4,7 @@ , fetchurl , lsb-release , pkg-config +, gtk2 , gtk3 , webkitgtk_4_1 , libsoup_3 @@ -13,6 +14,7 @@ , lua , lib , ftgl-tecgraf +, withGTK3 ? false }: let @@ -32,14 +34,12 @@ in stdenv.mkDerivation rec { ]; buildInputs = [ - gtk3 - webkitgtk_4_1 - libsoup_3 + (if withGTK3 then gtk3 else gtk2) libGL libGLU lua ftgl-tecgraf - ]; + ] ++ lib.optional withGTK3 [ webkitgtk_4_1 libsoup_3 ]; propagatedBuildInputs = [ cd @@ -48,17 +48,19 @@ in stdenv.mkDerivation rec { postPatch = '' sed -i 's/\biupvled\b//g' Makefile - - substituteInPlace srcweb/config.mak \ + '' + lib.optionalString withGTK3 '' + substituteInPlace srcweb/config.mak \ --replace-fail "\$(GTK)/include/webkitgtk-4.1" "${webkitgtk_4_1.dev}/include/webkitgtk-4.1" \ --replace-fail "\$(GTK)/include/libsoup-3.0" "${libsoup_3.dev}/include/libsoup-3.0" + '' + lib.optionalString (!withGTK3) '' + sed -i 's/\biupweb\b//g' Makefile + sed -i 's/\biupluaweb\b//g' srclua5/Makefile ''; makeFlags = [ "NO_DEPEND=Yes" "USE_PKGCONFIG=Yes" "USE_LUA_VERSION=52" - "USE_GTK3=Yes" "GTK_DEFAULT=Yes" "LUA_SFX=" @@ -68,7 +70,7 @@ in stdenv.mkDerivation rec { "LUA_INC=${lua}/include" "FTGL_LIB=${ftgl-tecgraf}/lib" "FTGL_INC=${ftgl-tecgraf}/include" - ]; + ] ++ (if withGTK3 then [ "USE_GTK3=Yes" ] else [ "USE_GTK2=Yes" ]); NIX_CFLAGS_COMPILE = '' -Wno-implicit-function-declaration @@ -79,7 +81,7 @@ in stdenv.mkDerivation rec { "iup" "A portable toolkit for building graphical user interfaces" version - "gtk+-3.0" + (if withGTK3 then "gtk+-3.0" else "gtk+-2.0") ); iupglPc = builtins.toFile "iupgl.pc" (makePc @@ -161,7 +163,6 @@ in stdenv.mkDerivation rec { ln -fs $out/lib/libiuplua_mglplot52.so $out/share/lua/5.2/iuplua_mglplot.so ln -fs $out/lib/libiuplua_scintilla52.so $out/share/lua/5.2/iuplua_scintilla.so ln -fs $out/lib/libiupluascripterdlg52.so $out/share/lua/5.2/iupluascripterdlg.so - ln -fs $out/lib/libiupluaweb52.so $out/share/lua/5.2/iupluaweb.so ln -fs $out/lib/libiupluaimglib52.so $out/share/lua/5.2/iupluaimglib.so cp -v ${iupPc} $out/lib/pkgconfig/iup.pc @@ -171,12 +172,14 @@ in stdenv.mkDerivation rec { cp -v ${iupPlotPc} $out/lib/pkgconfig/iup_plot.pc cp -v ${iupimPc} $out/lib/pkgconfig/iupim.pc cp -v ${iupimglibPc} $out/lib/pkgconfig/iupimglib.pc - cp -v ${iupwebPc} $out/lib/pkgconfig/iupweb.pc cp -vr bin/Linux*/* $out/bin/ chmod +x $out/bin/* cp -r etc/* $out/etc - + '' + lib.optionalString withGTK3 '' + ln -fs $out/lib/libiupluaweb52.so $out/share/lua/5.2/iupluaweb.so + cp -v ${iupwebPc} $out/lib/pkgconfig/iupweb.pc + '' + '' runHook postInstall '';