about summary refs log tree commit diff
path: root/pkgs/by-name/an/antimatter-dimensions/package.nix
blob: 388faf9d41cc57a8d42d807a54a3d029c4d1bdec (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
{ buildNpmPackage
, copyDesktopItems
, electron
, fetchFromGitHub
, lib
, makeDesktopItem
, unstableGitUpdater
, writeScriptBin
, electronAppName ? "Antimatter Dimensions"
}:

let
  # build doesn't provide app.js, only index.html as entry point.
  # app.js is used to change the directory where data is stored
  # instead of default Electron. This workaround will be removed
  # when this file will be available in upstream repository.
  dummyElectronApp = ./app.js;
in
buildNpmPackage rec {
  pname = "antimatter-dimensions";
  version = "0-unstable-2024-05-11";
  src = fetchFromGitHub {
    owner = "IvarK";
    repo = "AntimatterDimensionsSourceCode";
    rev = "b3a254af60207a03d04473bb81726e921f5b2c61";
    hash = "sha256-+G9mNilt5Ewja5P+Bt312EcCJknMu7FOMn5b4FseAyQ=";
  };
  nativeBuildInputs = [
    copyDesktopItems
    # build script calls git to get git hash, message and author
    # since fetchFromGitHub doesn't provide this information
    # and in order to keep determinism (#8567), create a dummy git
    (writeScriptBin "git" ''
      echo "unknown"
    '')
  ];

  npmDepsHash = "sha256-aG+oysgitQvdFM0QyzJ3DBxsanBHYI+UPJPhj6bf00Q=";
  npmFlags = [ "--legacy-peer-deps" ];
  npmBuildScript = "build:release";

  installPhase = ''
    runHook preInstall

    mkdir -p $out/share/antimatter-dimensions
    cp -Tr dist $out/share/antimatter-dimensions
    mkdir -p $out/share/icons/hicolor/256x256/apps
    ln -rs $out/share/antimatter-dimensions/icon.png $out/share/icons/hicolor/256x256/apps/antimatter-dimensions.png
    cp ${dummyElectronApp} $out/share/antimatter-dimensions/app.js

    makeWrapper ${lib.getExe electron} $out/bin/antimatter-dimensions \
      --add-flags $out/share/antimatter-dimensions/app.js \
      --set ELECTRON_APP_NAME "${electronAppName}"

    runHook postInstall
  '';

  desktopItems = [
    (makeDesktopItem {
      name = "antimatter-dimensions";
      exec = "antimatter-dimensions";
      icon = "antimatter-dimensions";
      desktopName = electronAppName;
      comment = meta.description;
      categories = [ "Game" ];
      terminal = false;
    })
  ];

  passthru.updateScript = unstableGitUpdater {
    hardcodeZeroVersion = true;
  };

  meta = {
    homepage = "https://github.com/IvarK/AntimatterDimensionsSourceCode";
    description = "Idle incremental game with multiple prestige layers.";
    license = lib.licenses.mit;
    mainProgram = "antimatter-dimensions";
    maintainers = with lib.maintainers; [ amozeo ];
    inherit (electron.meta) platforms;
  };
}