about summary refs log tree commit diff
path: root/pkgs/applications/science/machine-learning/sc2-headless/default.nix
blob: 517edd0d7799c9bf08b8d91aee85d6575b1b08be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ stdenv
, callPackage
, lib
, fetchurl
, unzip
, licenseAccepted ? false
}:

if !licenseAccepted then throw ''
    You must accept the Blizzard® Starcraft® II AI and Machine Learning License at
    https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html
    by setting nixpkgs config option 'sc2-headless.accept_license = true;'
  ''
else assert licenseAccepted;
let maps = callPackage ./maps.nix {};
in stdenv.mkDerivation rec {
  version = "3.17";
  name = "sc2-headless-${version}";

  src = fetchurl {
    url = "https://blzdistsc2-a.akamaihd.net/Linux/SC2.${version}.zip";
    sha256 = "1biyxpf7n95hali1pw30h91rhzrj6sbwrx6s52d00mlnwdhmf2v0";
  };

  unpackCmd = ''
    unzip -P 'iagreetotheeula' $curSrc
  '';

  nativeBuildInputs = [ unzip ];

  installPhase = ''
    mkdir -p $out
    cp -r . "$out"
    rm -r $out/Libs

    cp -r "${maps.minigames}"/* "$out"/Maps/
  '';

  preFixup = ''
    find $out -type f -print0 | while IFS=''' read -d ''' -r file; do
      isELF "$file" || continue
      patchelf \
        --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
        --set-rpath ${lib.makeLibraryPath [stdenv.cc.cc stdenv.cc.libc]} \
        "$file"
    done
  '';

  meta = {
    platforms = stdenv.lib.platforms.linux;
    description = "Starcraft II headless linux client for machine learning research";
    license = {
      fullName = "BLIZZARD® STARCRAFT® II AI AND MACHINE LEARNING LICENSE";
      url = "https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html";
      free = false;
    };
    maintainers = with lib.maintainers; [ danharaj ];
  };
}