about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/graphics/pencil/default.nix
blob: 37857fc459ea9c2c682e3c8b188671b7a7fe81ab (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
{ stdenv, fetchurl, lib, makeWrapper,
  # build dependencies
  alsaLib, atk, cairo, cups, dbus, expat, fontconfig,
  freetype, gdk-pixbuf, glib, gnome2, nspr, nss, xorg,
  glibc, systemd
}:

stdenv.mkDerivation rec {
  version = "3.0.4";
  pname = "pencil";

  src = fetchurl {
    url    = "http://pencil.evolus.vn/dl/V${version}/Pencil_${version}_amd64.deb";
    sha256 = "58e2b794c615ea8715d8374f177e19c87f7071e359826ec34a59836d537a62fd";
  };

  sourceRoot = ".";

  unpackCmd = ''
    ar p "$src" data.tar.xz | tar xJ
  '';

  dontBuild = true;

  nativeBuildInputs = [ makeWrapper ];

  installPhase = ''
    mkdir -p $out/bin
    cp -R usr/share opt $out/

    # fix the path in the desktop file
    substituteInPlace \
      $out/share/applications/pencil.desktop \
      --replace /opt/ $out/opt/

    # symlink the binary to bin/
    ln -s $out/opt/Pencil/pencil $out/bin/pencil
  '';


  preFixup = let
    packages = [
      alsaLib
      atk
      cairo
      cups
      dbus
      expat
      fontconfig
      freetype
      gdk-pixbuf
      glib
      gnome2.GConf
      gnome2.gtk
      gnome2.pango
      nspr
      nss
      xorg.libX11
      xorg.libXScrnSaver
      xorg.libXcomposite
      xorg.libXcursor
      xorg.libXdamage
      xorg.libXext
      xorg.libXfixes
      xorg.libXi
      xorg.libXrandr
      xorg.libXrender
      xorg.libXtst
      stdenv.cc.cc.lib
      stdenv.cc.cc
      glibc
    ];
    libPathNative = lib.makeLibraryPath packages;
    libPath64 = lib.makeSearchPathOutput "lib" "lib64" packages;
    libPath = "${libPathNative}:${libPath64}";
  in ''
    # patch executable
    patchelf \
      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
      --set-rpath "${libPath}:$out/opt/Pencil" \
      $out/opt/Pencil/pencil

    # patch libnode
    patchelf \
      --set-rpath "${libPath}" \
      $out/opt/Pencil/libnode.so

    # libffmpeg is for some reason  not executable
    chmod a+x $out/opt/Pencil/libffmpeg.so

    # fix missing libudev
    ln -s ${systemd.lib}/lib/libudev.so.1 $out/opt/Pencil/libudev.so.1
    wrapProgram $out/opt/Pencil/pencil \
      --prefix LD_LIBRARY_PATH : $out/opt/Pencil
  '';

  meta = with stdenv.lib; {
    description = "GUI prototyping/mockup tool";
    homepage    = "https://pencil.evolus.vn/";
    license     = licenses.gpl2; # Commercial license is also available
    maintainers = with maintainers; [ bjornfor prikhi mrVanDalo ];
    platforms   = platforms.linux;
  };
}