about summary refs log tree commit diff
path: root/pkgs/development/tools/scenebuilder/default.nix
blob: 14d6c872590483824d83513f96d3ed5383731647 (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
{ lib
, jdk21
, maven
, fetchFromGitHub
, makeDesktopItem
, copyDesktopItems
, glib
, makeWrapper
, wrapGAppsHook3
}:

let
  jdk = jdk21.override {
    enableJavaFX = true;
  };
  maven' = maven.override {
    inherit jdk;
  };
in
maven'.buildMavenPackage rec {
  pname = "scenebuilder";
  version = "21.0.1";

  src = fetchFromGitHub {
    owner = "gluonhq";
    repo = "scenebuilder";
    rev = version;
    hash = "sha256-YEcW1yQK6RKDqSstsrpdOqMt972ZagenGDxcJ/gP+SA=";
  };

  patches = [
    # makes the mvnHash platform-independent
    ./pom-remove-javafx.patch

    # makes sure that maven upgrades don't change the mvnHash
    ./fix-default-maven-plugin-versions.patch
  ];

  postPatch = ''
    # set the build timestamp to $SOURCE_DATE_EPOCH
    substituteInPlace app/pom.xml \
        --replace-fail "\''${maven.build.timestamp}" "$(date -d "@$SOURCE_DATE_EPOCH" '+%Y-%m-%d %H:%M:%S')"
  '';

  mvnParameters = toString [
    "-Dmaven.test.skip"
    "-Dproject.build.outputTimestamp=1980-01-01T00:00:02Z"
  ];

  mvnHash = "sha256-fS7dS2Q4ORThLBwDOzJJnRboNNRmhp0RG6Dae9fl+pw=";

  nativeBuildInputs = [
    copyDesktopItems
    glib
    makeWrapper
    wrapGAppsHook3
  ];

  dontWrapGApps = true; # prevent double wrapping

  installPhase = ''
    runHook preInstall

    install -Dm644 app/target/lib/scenebuilder-${version}-SNAPSHOT-all.jar $out/share/scenebuilder/scenebuilder.jar
    install -Dm644 app/src/main/resources/com/oracle/javafx/scenebuilder/app/SB_Logo.png $out/share/icons/hicolor/128x128/apps/scenebuilder.png

    runHook postInstall
  '';

  postFixup = ''
    makeWrapper ${jdk}/bin/java $out/bin/scenebuilder \
      --add-flags "--add-modules javafx.web,javafx.fxml,javafx.swing,javafx.media" \
      --add-flags "--add-opens=javafx.fxml/javafx.fxml=ALL-UNNAMED" \
      --add-flags "-jar $out/share/scenebuilder/scenebuilder.jar" \
      "''${gappsWrapperArgs[@]}"
  '';

  desktopItems = [
    (makeDesktopItem {
      name = "scenebuilder";
      exec = "scenebuilder";
      icon = "scenebuilder";
      comment = "A visual, drag'n'drop, layout tool for designing JavaFX application user interfaces.";
      desktopName = "Scene Builder";
      mimeTypes = [ "application/java" "application/java-vm" "application/java-archive" ];
      categories = [ "Development" ];
    })
  ];

  meta = with lib; {
    changelog = "https://github.com/gluonhq/scenebuilder/releases/tag/${src.rev}";
    description = "A visual, drag'n'drop, layout tool for designing JavaFX application user interfaces.";
    homepage = "https://gluonhq.com/products/scene-builder/";
    license = licenses.bsd3;
    mainProgram = "scenebuilder";
    maintainers = with maintainers; [ wirew0rm ];
    platforms = jdk.meta.platforms;
    sourceProvenance = with sourceTypes; [
      fromSource
      binaryBytecode # deps
    ];
  };
}