From 298409f4ab9ac0e1d67ea73c3dd4692f933523a5 Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Fri, 5 Jan 2018 22:06:15 +0100 Subject: [PATCH] vdrift: split data into separate derivation This allows vdrift to be built on hydra without taking up a large amount of space. --- ...Ignore-missing-data-for-installation.patch | 27 ++++++ pkgs/games/vdrift/default.nix | 83 ++++++++++++------- pkgs/top-level/all-packages.nix | 3 + 3 files changed, 81 insertions(+), 32 deletions(-) create mode 100644 pkgs/games/vdrift/0001-Ignore-missing-data-for-installation.patch diff --git a/pkgs/games/vdrift/0001-Ignore-missing-data-for-installation.patch b/pkgs/games/vdrift/0001-Ignore-missing-data-for-installation.patch new file mode 100644 index 00000000000..6794e8018af --- /dev/null +++ b/pkgs/games/vdrift/0001-Ignore-missing-data-for-installation.patch @@ -0,0 +1,27 @@ +From 7ebe252a8488a63675d1c50c0faa1bdc5ff97889 Mon Sep 17 00:00:00 2001 +From: Linus Heckemann +Date: Fri, 5 Jan 2018 21:27:28 +0100 +Subject: [PATCH] Ignore missing data for installation + +This is for packaging vdrift separately from its data in nixpkgs. +--- + SConstruct | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/SConstruct b/SConstruct +index 4394de0b..beef29a4 100644 +--- a/SConstruct ++++ b/SConstruct +@@ -511,9 +511,6 @@ env.Alias(target = 'bin-package', source = bin_archive) + #----------------# + Export(['env', 'version', 'src_dir', 'bin_dir']) + if 'install' in COMMAND_LINE_TARGETS: +- if not os.path.isfile('data/SConscript'): +- raise 'VDrift data not found. Please make sure data is placed in vdrift directory. See README.md and http://wiki.vdrift.net.' +- SConscript('data/SConscript') + # desktop appdata installation + install_desktop = env.Install(env['destdir'] + env['prefix'] + '/share/applications', 'vdrift.desktop') + install_appdata = env.Install(env['destdir'] + env['prefix'] + '/share/appdata', 'vdrift.appdata.xml') +-- +2.15.0 + diff --git a/pkgs/games/vdrift/default.nix b/pkgs/games/vdrift/default.nix index 92b823eee33..81b95ddb9e1 100644 --- a/pkgs/games/vdrift/default.nix +++ b/pkgs/games/vdrift/default.nix @@ -1,41 +1,60 @@ -{ stdenv, fetchFromGitHub, fetchsvn, pkgconfig, scons, mesa, SDL2, SDL2_image, libvorbis, - bullet, curl, gettext }: +{ stdenv, fetchFromGitHub, fetchsvn, pkgconfig, scons, mesa, SDL2, SDL2_image +, libvorbis, bullet, curl, gettext, writeTextFile, writeShellScriptBin -stdenv.mkDerivation rec { - version = "git"; - name = "vdrift-${version}"; - - src = fetchFromGitHub { - owner = "vdrift"; - repo = "vdrift"; - rev = "12d444ed18395be8827a21b96cc7974252fce6d1"; - sha256 = "001wq3c4n9wzxqfpq40b1jcl16sxbqv2zbkpy9rq2wf9h417q6hg"; - }; - - data = fetchsvn { +, data ? fetchsvn { url = "svn://svn.code.sf.net/p/vdrift/code/vdrift-data"; rev = 1386; sha256 = "0ka6zir9hg0md5p03dl461jkvbk05ywyw233hnc3ka6shz3vazi1"; + } +}: +let + version = "git"; + bin = stdenv.mkDerivation { + name = "vdrift-${version}"; + + src = fetchFromGitHub { + owner = "vdrift"; + repo = "vdrift"; + rev = "12d444ed18395be8827a21b96cc7974252fce6d1"; + sha256 = "001wq3c4n9wzxqfpq40b1jcl16sxbqv2zbkpy9rq2wf9h417q6hg"; + }; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ scons mesa SDL2 SDL2_image libvorbis bullet curl gettext ]; + + patches = [ ./0001-Ignore-missing-data-for-installation.patch ]; + + buildPhase = '' + sed -i -e s,/usr/local,$out, SConstruct + export CXXFLAGS="$(pkg-config --cflags SDL2_image)" + scons -j$NIX_BUILD_CORES + ''; + installPhase = "scons install"; + + meta = { + description = "Car racing game"; + homepage = http://vdrift.net/; + license = stdenv.lib.licenses.gpl2Plus; + maintainers = with stdenv.lib.maintainers; [viric]; + platforms = stdenv.lib.platforms.linux; + }; }; - - nativeBuildInputs = [ pkgconfig ]; - buildInputs = [ scons mesa SDL2 SDL2_image libvorbis bullet curl gettext ]; - - buildPhase = '' - cp -r --reflink=auto $data data - chmod -R +w data - sed -i -e s,/usr/local,$out, SConstruct - export CXXFLAGS="$(pkg-config --cflags SDL2_image)" - scons -j$NIX_BUILD_CORES + wrappedName = "vdrift-${version}-with-data-${toString data.rev}"; +in writeTextFile { + name = wrappedName; + text = '' + export VDRIFT_DATA_DIRECTORY="${data}" + exec ${bin}/bin/vdrift "$@" ''; - installPhase = "scons install"; - - meta = { - description = "Car racing game"; - homepage = http://vdrift.net/; - license = stdenv.lib.licenses.gpl2Plus; - maintainers = with stdenv.lib.maintainers; [viric lheckemann]; - platforms = stdenv.lib.platforms.linux; + destination = "/bin/vdrift"; + executable = true; + checkPhase = '' + ${stdenv.shell} -n $out/bin/vdrift + ''; +} // { + meta = bin.meta // { hydraPlatforms = []; }; + unwrapped = bin; + inherit bin data; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0572fbc0293..90b622d9ee7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18533,6 +18533,9 @@ with pkgs; vdrift = callPackage ../games/vdrift { }; + # To ensure vdrift's code is built on hydra + vdrift-bin = vdrift.bin; + vectoroids = callPackage ../games/vectoroids { }; vessel = callPackage_i686 ../games/vessel { };