about summary refs log tree commit diff
path: root/pkgs/applications/misc/pattypan/default.nix
blob: c1f5aa84b0eb5c09f07ab3e3ca9612ac7987345a (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
{ lib
, stdenv
, fetchFromGitHub
, ant
, jdk
, makeWrapper
, wrapGAppsHook
, makeDesktopItem
, copyDesktopItems
, stripJavaArchivesHook
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "pattypan";
  version = "22.03";

  src = fetchFromGitHub {
    owner = "yarl";
    repo = "pattypan";
    rev = "v${finalAttrs.version}";
    hash = "sha256-wMQrBg+rEV1W7NgtWFXZr3pAxpyqdbEBKLNwDDGju2I=";
  };

  nativeBuildInputs = [
    ant
    jdk
    makeWrapper
    wrapGAppsHook
    copyDesktopItems
    stripJavaArchivesHook
  ];

  dontWrapGApps = true;

  env.JAVA_TOOL_OPTIONS = "-Dfile.encoding=UTF8"; # needed for jdk versions below jdk19

  buildPhase = ''
    runHook preBuild
    ant
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall
    install -Dm644 pattypan.jar -t $out/share/pattypan
    install -Dm644 src/pattypan/resources/logo.png $out/share/pixmaps/pattypan.png
    runHook postInstall
  '';

  # gappsWrapperArgs is set in preFixup
  postFixup = ''
    makeWrapper ${jdk}/bin/java $out/bin/pattypan \
        ''${gappsWrapperArgs[@]} \
        --add-flags "-jar $out/share/pattypan/pattypan.jar"
  '';

  desktopItems = [
    (makeDesktopItem {
      name = "pattypan";
      exec = "pattypan";
      icon = "pattypan";
      desktopName = "Pattypan";
      genericName = "An uploader for Wikimedia Commons";
      categories = [ "Utility" ];
    })
  ];

  meta = with lib; {
    description = "An uploader for Wikimedia Commons";
    homepage = "https://commons.wikimedia.org/wiki/Commons:Pattypan";
    license = licenses.mit;
    mainProgram = "pattypan";
    maintainers = with maintainers; [ fee1-dead ];
    platforms = platforms.all;
    sourceProvenance = with sourceTypes; [
      fromSource
      binaryBytecode # source bundles dependencies as jars
    ];
  };
})