about summary refs log tree commit diff
path: root/pkgs/applications/misc/ns-usbloader/default.nix
blob: 8ab52711a6cee780fbef46c7271fcc58f183a0d0 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{ lib
, stdenv
, fetchFromGitHub
, copyDesktopItems
, makeDesktopItem
, makeWrapper
, wrapGAppsHook3
, gvfs
, maven
, jre
}:
let
  pkgDescription = "All-in-one tool for managing Nintendo Switch homebrew";

  selectSystem = attrs:
    attrs.${stdenv.hostPlatform.system}
      or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

  jreWithJavaFX = jre.override { enableJavaFX = true; };
in
maven.buildMavenPackage rec {
  pname = "ns-usbloader";
  version = "7.1";

  src = fetchFromGitHub {
    owner = "developersu";
    repo = "ns-usbloader";
    rev = "v${version}";
    sha256 = "sha256-gSf5SCIhcUEYGsYssXVGjUweVU+guxOI+lzD3ANr96w=";
  };

  patches = [ ./no-launch4j.patch ./make-deterministic.patch ];

  # JavaFX pulls in architecture dependent jar dependencies. :(
  # May be possible to unify these, but could lead to huge closure sizes.
  mvnHash = selectSystem {
    x86_64-linux = "sha256-vXZAlZOh9pXNF1RL78oQRal5pkXFRKDz/7SP9LibgiA=";
    aarch64-linux = "sha256-xC+feb41EPi30gBrVR8usanVULI2Pt0knztzNagPQiw=";
  };
  mvnParameters = "-DskipTests";

  nativeBuildInputs = [
    copyDesktopItems
    makeWrapper
    wrapGAppsHook3
    gvfs
  ];

  # Don't wrap binaries twice.
  dontWrapGApps = true;

  ### Issues:
  # * Set us to only use software rendering with `-Dprism.order=sw`, had a hard time
  #   getting `prism_es2` happy with NixOS's GL/GLES.
  # * Currently, there's also a lot of `Failed to build parent project for org.openjfx:javafx-*`
  #   at build, but jar runs fine when using `jreWithJavaFX`.

  installPhase = ''
    runHook preInstall

    mkdir -p $out/share/java
    install -Dm644 target/ns-usbloader-${version}.jar $out/share/java/ns-usbloader.jar

    mkdir -p $out/lib/udev/rules.d
    install -Dm644 ${./99-ns-usbloader.rules} $out/lib/udev/rules.d/99-ns-usbloader.rules

    mkdir -p $out/share/icons/hicolor
    install -Dm644 target/classes/res/app_icon32x32.png $out/share/icons/hicolor/32x32/apps/ns-usbloader.png
    install -Dm644 target/classes/res/app_icon48x48.png $out/share/icons/hicolor/48x48/apps/ns-usbloader.png
    install -Dm644 target/classes/res/app_icon64x64.png $out/share/icons/hicolor/64x64/apps/ns-usbloader.png
    install -Dm644 target/classes/res/app_icon128x128.png $out/share/icons/hicolor/128x128/apps/ns-usbloader.png

    runHook postInstall
  '';

  preFixup = ''
    mkdir -p $out/bin
    makeWrapper ${jreWithJavaFX}/bin/java $out/bin/ns-usbloader \
      --append-flags "-Dprism.order=sw -jar $out/share/java/ns-usbloader.jar" \
      "''${gappsWrapperArgs[@]}"
  '';

  desktopItems = [
    (makeDesktopItem {
      type = "Application";
      name = "ns-usbloader";
      desktopName = "NS-USBLoader";
      comment = pkgDescription;
      exec = "ns-usbloader";
      icon = "ns-usbloader";
      categories = [ "Game" ];
      terminal = false;
      keywords = [ "nintendo" "switch" ];
    })
  ];

  meta = with lib; {
    description = pkgDescription;
    homepage = "https://github.com/developersu/ns-usbloader";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ soupglasses ];
    platforms = [ "x86_64-linux" "aarch64-linux" ];
    mainProgram = "ns-usbloader";
  };
}