factorio: refactor alpha/headless split

This commit is contained in:
Eric Litak 2016-04-27 03:32:23 -07:00 committed by Joachim Fasting
parent 23fd70b719
commit f6b645206f
No known key found for this signature in database
GPG Key ID: 4330820E1E04DCF4
1 changed files with 59 additions and 62 deletions

View File

@ -1,10 +1,7 @@
{ stdenv, callPackage, fetchurl, makeWrapper { stdenv, callPackage, fetchurl, makeWrapper
# Begin libraries
, alsaLib, libX11, libXcursor, libXinerama, libXrandr, libXi, mesa_noglu , alsaLib, libX11, libXcursor, libXinerama, libXrandr, libXi, mesa_noglu
# Begin download parameters
, username ? ""
, password ? ""
, releaseType , releaseType
, username ? "" , password ? ""
}: }:
assert releaseType == "alpha" || releaseType == "headless"; assert releaseType == "alpha" || releaseType == "headless";
@ -55,15 +52,51 @@ let
fi fi
''; '';
in base = {
name = "factorio-${releaseType}-${version}";
stdenv.mkDerivation rec { src = fetch.${arch.inTar}.${releaseType};
name = "factorio-${releaseType}-${version}";
src = fetch.${arch.inTar}.${releaseType}; dontBuild = true;
libPath = stdenv.lib.makeLibraryPath ( # TODO detangle headless/normal mode wrapping, libs, etc. test all urls 32/64/headless/gfx
optionals (! isHeadless) [ installPhase = ''
mkdir -p $out/{bin,share/factorio}
cp -a data $out/share/factorio
cp -a bin/${arch.inTar}/factorio $out/bin/factorio
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
$out/bin/factorio
'';
preferLocalBuild = true;
meta = {
description = "A game in which you build and maintain factories";
longDescription = ''
Factorio is a game in which you build and maintain factories.
You will be mining resources, researching technologies, building
infrastructure, automating production and fighting enemies. Use your
imagination to design your factory, combine simple elements into
ingenious structures, apply management skills to keep it working and
finally protect it from the creatures who don't really like you.
Factorio has been in development since spring of 2012 and it is
currently in late alpha.
'';
homepage = https://www.factorio.com/;
license = stdenv.lib.licenses.unfree;
maintainers = with stdenv.lib.maintainers; [ Baughn elitak ];
platforms = [ "i686-linux" "x86_64-linux" ];
};
};
headless = base;
alpha = base // {
buildInputs = [ makeWrapper ];
libPath = stdenv.lib.makeLibraryPath [
alsaLib alsaLib
libX11 libX11
libXcursor libXcursor
@ -71,61 +104,25 @@ stdenv.mkDerivation rec {
libXrandr libXrandr
libXi libXi
mesa_noglu mesa_noglu
] ];
);
buildInputs = [ makeWrapper ]; installPhase = base.installPhase + ''
wrapProgram $out/bin/factorio \
--prefix LD_LIBRARY_PATH : /run/opengl-driver/lib:$libPath \
--run "$out/share/factorio/update-config.sh" \
--add-flags "-c \$HOME/.factorio/config.cfg"
dontBuild = true; install -m0644 <(cat << EOF
${configBaseCfg}
EOF
) $out/share/factorio/config-base.cfg
# TODO detangle headless/normal mode wrapping, libs, etc. test all urls 32/64/headless/gfx install -m0755 <(cat << EOF
installPhase = '' ${updateConfigSh}
mkdir -p $out/{bin,share/factorio} EOF
cp -a data $out/share/factorio ) $out/share/factorio/update-config.sh
cp -a bin/${arch.inTar}/factorio $out/bin/factorio
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
$out/bin/factorio
'' + optionalString (! isHeadless) ('' cp -a doc-html $out/share/factorio
mv $out/bin/factorio $out/bin/factorio.${arch.inTar}
makeWrapper $out/bin/factorio.${arch.inTar} $out/bin/factorio \
--prefix LD_LIBRARY_PATH : /run/opengl-driver/lib:$libPath \
--run "$out/share/factorio/update-config.sh" \
--add-flags "-c \$HOME/.factorio/config.cfg"
# Fortunately, Factorio already supports system-wide installs.
# Unfortunately it's a bit inconvenient to set the paths.
install -m0644 <(cat << EOF
'' + configBaseCfg + ''
EOF
) $out/share/factorio/config-base.cfg
install -m0755 <(cat << EOF
'' + updateConfigSh + ''
EOF
) $out/share/factorio/update-config.sh
cp -a doc-html $out/share/factorio
'');
preferLocalBuild = true;
meta = {
description = "A game in which you build and maintain factories";
longDescription = ''
Factorio is a game in which you build and maintain factories.
You will be mining resources, researching technologies, building
infrastructure, automating production and fighting enemies. Use your
imagination to design your factory, combine simple elements into
ingenious structures, apply management skills to keep it working and
finally protect it from the creatures who don't really like you.
Factorio has been in development since spring of 2012 and it is
currently in late alpha.
''; '';
homepage = https://www.factorio.com/;
license = stdenv.lib.licenses.unfree;
maintainers = with stdenv.lib.maintainers; [ Baughn elitak ];
platforms = [ "i686-linux" "x86_64-linux" ];
}; };
} in stdenv.mkDerivation (if isHeadless then headless else alpha)