anchor.diff:      # 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
  +      --set-rpath "${libPath}:$out/opt/pencil" \
  +      $out/opt/pencil/pencil
   
       # 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
  +    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; {
  
positive.code: { 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 \
  
negative.code:       --replace /opt/ $out/opt/
  
      # symlink the binary to bin/
      ln -s $out/opt/pencil/pencil $out/bin/pencil
    '';
  
  
    preFixup = let
      packages = deps;
      libPathNative = lib.makeLibraryPath packages;
      libPath64 = lib.makeSearchPathOutput "lib" "lib64" packages;
      libPath = "${libPathNative}:${libPath64}";
  