diff options
-rw-r--r-- | pkgs/build-support/opengl/mesa-switch.sh | 41 | ||||
-rw-r--r-- | pkgs/games/quake3/wrapper/builder.sh | 5 | ||||
-rw-r--r-- | pkgs/games/quake3/wrapper/default.nix | 6 | ||||
-rw-r--r-- | pkgs/system/all-packages-generic.nix | 3 | ||||
-rw-r--r-- | pkgs/system/populate-cache.nix | 2 |
5 files changed, 53 insertions, 4 deletions
diff --git a/pkgs/build-support/opengl/mesa-switch.sh b/pkgs/build-support/opengl/mesa-switch.sh new file mode 100644 index 000000000000..bc9445319dd9 --- /dev/null +++ b/pkgs/build-support/opengl/mesa-switch.sh @@ -0,0 +1,41 @@ +profileName=opengl +profileDir=/nix/var/nix/profiles +profile=$profileDir/$profileName + +if test -z "$OPENGL_DRIVER"; then + if test -d "$profile/lib"; then + OPENGL_DRIVER=$profile + fi +fi + +if test -z "$OPENGL_DRIVER"; then + + cat <<EOF +====================================================================== +This program uses OpenGL for 3D graphics. For best performance, you +should use a hardware-accelerated implementation of OpenGL. Since you +have not enabled one, a software implementation (Mesa) will be used. +This will probably be quite slow. + +This program will look for a hardware-accelerated implementation of +OpenGL in the "$profileName" profile of your Nix installation. For +instance, to enable NVidia's accelerated driver on non-NixOS systems, +try + + $ nix-env -p $profile -i nvidia-sys-opengl + +Alternatively, you can set the OPENGL_DRIVER environment variable to +point at the package containing the OpenGL implementation. +====================================================================== + +EOF + + OPENGL_DRIVER=$mesa +fi + +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH${LD_LIBRARY_PATH:+:}$OPENGL_DRIVER/lib + +hook="$OPENGL_DRIVER/nix-support/opengl-hook" +if test -e "$hook"; then + source "$hook" +fi diff --git a/pkgs/games/quake3/wrapper/builder.sh b/pkgs/games/quake3/wrapper/builder.sh index 6162adfa824c..3042e7548f09 100644 --- a/pkgs/games/quake3/wrapper/builder.sh +++ b/pkgs/games/quake3/wrapper/builder.sh @@ -12,8 +12,13 @@ done ensureDir $out/bin cat >$out/bin/quake3 <<EOF +mesa=$mesa + +$(cat $mesaSwitch) + exec $game/ioquake3.i386 \ +set fs_basepath $out \ + +set r_allowSoftwareGL 1 \ "\$@" EOF diff --git a/pkgs/games/quake3/wrapper/default.nix b/pkgs/games/quake3/wrapper/default.nix index 512ff21d7ce4..315516f037f4 100644 --- a/pkgs/games/quake3/wrapper/default.nix +++ b/pkgs/games/quake3/wrapper/default.nix @@ -1,7 +1,7 @@ -{stdenv, fetchurl, game, paks}: +{stdenv, fetchurl, game, paks, mesa, name}: stdenv.mkDerivation { - name = "quake3"; builder = ./builder.sh; - inherit game paks; + inherit game paks mesa name; + mesaSwitch = ../../../build-support/opengl/mesa-switch.sh; } diff --git a/pkgs/system/all-packages-generic.nix b/pkgs/system/all-packages-generic.nix index ed135cebe5bb..631051f43da3 100644 --- a/pkgs/system/all-packages-generic.nix +++ b/pkgs/system/all-packages-generic.nix @@ -2095,7 +2095,8 @@ rec { }; quake3demo = import ../games/quake3/wrapper { - inherit fetchurl stdenv; + name = "quake3-demo"; + inherit fetchurl stdenv mesa; game = quake3game; paks = [quake3demodata]; }; diff --git a/pkgs/system/populate-cache.nix b/pkgs/system/populate-cache.nix index 489c1324620d..c5146391a755 100644 --- a/pkgs/system/populate-cache.nix +++ b/pkgs/system/populate-cache.nix @@ -128,6 +128,8 @@ let { ecj jre jetty + + quake3demo ;}; i686FreeBSDPkgs = {inherit (allPackages {system = "i686-freebsd";}) |