about summary refs log tree commit diff
path: root/pkgs/by-name/ol/olvid/package.nix
blob: bd0eb63a9af71f785e87d72f479a6a317bb098e6 (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
106
107
108
{ stdenv
, lib
, fetchurl
, zlib
, libXext
, libX11
, libXrender
, libXtst
, libXi
, freetype
, alsa-lib
, jdk21
, openjfx21
, autoPatchelfHook
, makeBinaryWrapper
, wrapGAppsHook
}:

let
  repo = "olvid";

  javafxModules = [ "swing" "controls" "media" "fxml" "graphics" "base" ];

  classpath =
    lib.concatMap (mod: [
      "${openjfx21}/modules_src/javafx.${mod}/module-info.java"
      "${openjfx21}/modules/javafx.${mod}"
      "${openjfx21}/modules_libs/javafx.${mod}"
    ]) javafxModules ++
    [ "$out/share/${repo}/*" ];

  jvmArgs = [
    "-cp" (lib.concatStringsSep ":" classpath)
    "-Djpackage.app-version=$version"
    "-Dolvid.sqlcipher=true"
    "-Dolvid.dev=false"
    "-Dolvid.packaged=true"
    "-Dolvid.multiuser=false"
    "-Dolvid.debug=false"
    "-Dolvid.version=$version"
    "-Djava.net.useSystemProxies=true"
    "-Djava.library.path=$out/lib/"
    "-Xss8M"
    "-XX:+ShowCodeDetailsInExceptionMessages"
    "--add-opens=java.desktop/java.awt=ALL-UNNAMED"
    "--add-opens=java.desktop/java.awt.geom=ALL-UNNAMED"
    "--add-opens=java.desktop/sun.awt.geom=ALL-UNNAMED"
    "--add-opens=java.base/java.util=ALL-UNNAMED"
    "--add-opens=java.desktop/javax.swing=ALL-UNNAMED"
    "--add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED"
  ];
in

stdenv.mkDerivation (finalAttrs: {
  pname = "olvid";
  version = "1.5.2";

  dontUnpack = true;
  dontWrapGApps = true;

  src = fetchurl {
    url = "https://static.olvid.io/linux/${repo}-${finalAttrs.version}.tar.gz";
    hash = "sha256-WjIOk3dPSXQdAR2fdXseV0NdOjld0PzyqnUx/VbvQio=";
  };

  nativeBuildInputs = [
    autoPatchelfHook
    makeBinaryWrapper
    wrapGAppsHook
  ];

  buildInputs = [
    zlib
    libXext
    libX11
    libXrender
    libXtst
    libXi
    freetype
    alsa-lib
  ];

  installPhase = ''
    runHook preInstall

    install -dm755 "$out/share/${repo}"
    tar -xf "$src" -C "$out/share/${repo}" --wildcards --strip-components 3 olvid/lib/app/'*.jar'

    install -dm755 "$out/lib"
    tar -xf "$src" -C "$out/lib" --strip-components 4 olvid/lib/runtime/lib/

    install -dm755 "$out/bin"
    makeBinaryWrapper ${jdk21}/bin/java $out/bin/${repo} \
      "''${gappsWrapperArgs[@]}" \
      --add-flags "${lib.concatStringsSep " " jvmArgs} io.olvid.windows.messenger.start_up.Launcher"

    runHook postInstall
  '';

  meta = with lib; {
    description = "The secure french messenger";
    homepage = "https://www.olvid.io";
    license = licenses.agpl3Only;
    mainProgram = "olvid";
    maintainers = with maintainers; [ rookeur ];
    platforms = platforms.linux;
  };
})