Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 118da86ad4ad
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 36f084b2bbcb
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Jan 13, 2020

  1. mindustry: init at 102 (and updates) (#72306)

    * mindustry: init at 99
    
    * mindustry: 99 -> 100
    
    * mindustry: 100 -> 101
    
    * mindustry: 101 -> 101.1
    
    * mindustry: 101.1 -> 102
    fgaz authored and peterhoeg committed Jan 13, 2020

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    36f084b View commit details
Showing with 108 additions and 0 deletions.
  1. +106 −0 pkgs/games/mindustry/default.nix
  2. +2 −0 pkgs/top-level/all-packages.nix
106 changes: 106 additions & 0 deletions pkgs/games/mindustry/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{ stdenv
, makeWrapper
, makeDesktopItem
, fetchFromGitHub
, gradle_5
, perl
, jre
, libpulseaudio

# Make the build version easily overridable.
# Server and client build versions must match, and an empty build version means
# any build is allowed, so this parameter acts as a simple whitelist.
# Takes the package version and returns the build version.
, makeBuildVersion ? (v: v)
}:

let
pname = "mindustry";
# Note: when raising the version, ensure that all SNAPSHOT versions in
# build.gradle are replaced by a fixed version
# (the current one at the time of release) (see postPatch).
version = "102";
buildVersion = makeBuildVersion version;

src = fetchFromGitHub {
owner = "Anuken";
repo = "Mindustry";
rev = "v${version}";
sha256 = "0g4zy2zlynv6f427pq1ngnl0zpr6nnih10wd2l8vl9bxwzjygwdr";
};

desktopItem = makeDesktopItem {
type = "Application";
name = "Mindustry";
desktopName = "Mindustry";
exec = "mindustry";
icon = "mindustry";
};

postPatch = ''
# Remove unbuildable iOS stuff
sed -i '/^project(":ios"){/,/^}/d' build.gradle
sed -i '/robo(vm|VM)/d' build.gradle
rm ios/build.gradle
# Pin 'SNAPSHOT' versions
sed -i 's/com.github.anuken:packr:-SNAPSHOT/com.github.anuken:packr:034efe51781d2d8faa90370492133241bfb0283c/' build.gradle
'';

# fake build to pre-download deps into fixed-output derivation
deps = stdenv.mkDerivation {
pname = "${pname}-deps";
inherit version src postPatch;
nativeBuildInputs = [ gradle_5 perl ];
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d)
gradle --no-daemon desktop:dist -Pbuildversion=${buildVersion}
gradle --no-daemon server:dist -Pbuildversion=${buildVersion}
'';
# perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
installPhase = ''
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
| sh
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "1sscxrr32f2agwz34pm491xqkz7m4bwdc1p3g64kcnl3p6rg7r7k";
};

in stdenv.mkDerivation rec {
inherit pname version src postPatch;

nativeBuildInputs = [ gradle_5 makeWrapper ];

buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d)
# point to offline repo
sed -ie "s#mavenLocal()#mavenLocal(); maven { url '${deps}' }#g" build.gradle
gradle --offline --no-daemon desktop:dist -Pbuildversion=${buildVersion}
gradle --offline --no-daemon server:dist -Pbuildversion=${buildVersion}
'';

installPhase = ''
install -Dm644 desktop/build/libs/Mindustry.jar $out/share/mindustry.jar
install -Dm644 server/build/libs/server-release.jar $out/share/mindustry-server.jar
mkdir $out/bin
makeWrapper ${jre}/bin/java $out/bin/mindustry \
--prefix LD_LIBRARY_PATH : ${libpulseaudio}/lib \
--add-flags "-jar $out/share/mindustry.jar"
makeWrapper ${jre}/bin/java $out/bin/mindustry-server \
--add-flags "-jar $out/share/mindustry-server.jar"
install -Dm644 core/assets/icons/icon_64.png $out/share/icons/hicolor/64x64/apps/mindustry.png
install -Dm644 ${desktopItem}/share/applications/Mindustry.desktop $out/share/applications/Mindustry.desktop
'';

meta = with stdenv.lib; {
homepage = "https://mindustrygame.github.io/";
downloadPage = "https://github.com/Anuken/Mindustry/releases";
description = "A sandbox tower defense game";
license = licenses.gpl3;
maintainers = with maintainers; [ fgaz ];
platforms = platforms.all;
};
}

2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
@@ -23023,6 +23023,8 @@ in

megaglest = callPackage ../games/megaglest {};

mindustry = callPackage ../games/mindustry { };

minecraft = callPackage ../games/minecraft { };

minecraft-server = callPackage ../games/minecraft-server { };