summary refs log tree commit diff
path: root/pkgs/applications/editors/xxe-pe/default.nix
blob: 6df56b9773bd530f7ae048e7465875e64340a96e (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
{ stdenv
, fetchurl
, lib
, unzip
, makeWrapper
, openjdk11
, makeDesktopItem
, icoutils
, config
, acceptLicense ? config.xxe-pe.acceptLicense or false
}:

let
  pkg_path = "$out/lib/xxe";

  desktopItem = makeDesktopItem {
    name = "XMLmind XML Editor Personal Edition";
    exec = "xxe";
    icon = "xxe";
    desktopName = "xxe";
    genericName = "XML Editor";
    categories = [ "Development" "IDE" "TextEditor" "Java" ];
  };
in
stdenv.mkDerivation rec {
  pname = "xxe-pe";
  version = "10.2.0";

  src =
    assert !acceptLicense -> throw ''
      You must accept the XMLmind XML Editor Personal Edition License at
      https://www.xmlmind.com/xmleditor/license_xxe_perso.html
      by setting nixpkgs config option `xxe-pe.acceptLicense = true;`
      or by using `xxe-pe.override { acceptLicense = true; }` package.
    '';
      fetchurl {
        url = "https://www.xmlmind.com/xmleditor/_download/xxe-perso-${builtins.replaceStrings [ "." ] [ "_" ] version}.zip";
        sha256 = "sha256-JZ9nQwMrQL/1HKGwvXoWlnTx55ZK/UYjMJAddCtm0rw=";
      };

  nativeBuildInputs = [
    unzip
    makeWrapper
    icoutils
  ];

  dontStrip = true;

  installPhase = ''
    mkdir -p "${pkg_path}"
    mkdir -p "${pkg_path}" "$out/share/applications"
    cp -a * "${pkg_path}"
    ln -s ${desktopItem}/share/applications/* $out/share/applications

    icotool -x "${pkg_path}/bin/icon/xxe.ico"
    ls
    for f in xxe_*.png; do
      res=$(basename "$f" ".png" | cut -d"_" -f3 | cut -d"x" -f1-2)
      mkdir -pv "$out/share/icons/hicolor/$res/apps"
      mv "$f" "$out/share/icons/hicolor/$res/apps/xxe.png"
    done;
  '';

  postFixup = ''
    mkdir -p "$out/bin"
    makeWrapper "${pkg_path}/bin/xxe" "$out/bin/xxe" \
      --prefix PATH : ${lib.makeBinPath [ openjdk11 ]}
  '';

  meta = with lib; {
    description = "Strictly validating, near WYSIWYG, XML editor with DocBook support";
    homepage = "https://www.xmlmind.com/xmleditor/";
    license = licenses.unfree;
    maintainers = [ ];
    platforms = [ "x86_64-linux" ];
  };
}