summary refs log tree commit diff
path: root/pkgs/games/opensupaplex/default.nix
blob: dc5d9aae690ced81a049719ab2f09be96a4e0f71 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{ lib
, stdenv
, fetchFromGitHub
, fetchurl
, makeDesktopItem
, copyDesktopItems
, testers
, opensupaplex
, SDL2
, SDL2_mixer
}:

let
  # Doesn't seem to be included in tagged releases, but does exist on master.
  icon = fetchurl {
    url = "https://raw.githubusercontent.com/sergiou87/open-supaplex/b102548699cf16910b59559f689ecfad88d2a7d2/open-supaplex.svg";
    sha256 = "sha256-nKeSBUGjSulbEP7xxc6smsfCRjyc/xsLykH0o3Rq5wo=";
  };
in
stdenv.mkDerivation rec {
  pname = "opensupaplex";
  version = "7.1.2";

  src = fetchFromGitHub {
    owner = "sergiou87";
    repo = "open-supaplex";
    rev = "v${version}";
    sha256 = "sha256-hP8dJlLXE5J/oxPhRkrrBl1Y5e9MYbJKi8OApFM3+GU=";
  };

  nativeBuildInputs = [
    SDL2 # For "sdl2-config"
    copyDesktopItems
  ];
  buildInputs = [ SDL2_mixer ];

  enableParallelBuilding = true;

  NIX_CFLAGS_COMPILE = [
    "-DFILE_DATA_PATH=${placeholder "out"}/lib/opensupaplex"
    "-DFILE_FHS_XDG_DIRS"
  ];

  preBuild = ''
    # Makefile is located in this directory
    pushd linux
  '';

  postBuild = ''
    popd
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/{bin,lib,share/icons/hicolor/scalable/apps}

    install -D ./linux/opensupaplex $out/bin/opensupaplex
    cp -R ./resources $out/lib/opensupaplex
    cp ${icon} $out/share/icons/hicolor/scalable/apps/open-supaplex.svg

    runHook postInstall
  '';

  passthru.tests.version = testers.testVersion {
    package = opensupaplex;
    command = "opensupaplex --help";
    version = "v${version}";
  };

  desktopItems = [(makeDesktopItem {
    name = "opensupaplex";
    exec = meta.mainProgram;
    icon = "open-supaplex";
    desktopName = "OpenSupaplex";
    comment = meta.description;
    categories = [ "Application" "Game" ];
  })];

  meta = with lib; {
    description = "A decompilation of Supaplex in C and SDL";
    homepage = "https://github.com/sergiou87/open-supaplex";
    changelog = "https://github.com/sergiou87/open-supaplex/blob/master/changelog/v${version}.txt";
    license = licenses.gpl3Only;
    maintainers = [ maintainers.ivar ];
    platforms = platforms.linux; # Many more are supported upstream, but only linux is tested.
    mainProgram = "opensupaplex";
  };
}