Unverified Commit db8fa111 authored by Maximilian Marx's avatar Maximilian Marx
Browse files

standardnotes: patch pre-built node modules

parent bf0a52da
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@
, dpkg
, makeWrapper
, electron
, libsecret
, asar
, glib
, desktop-file-utils
, callPackage
}:
@@ -28,16 +31,28 @@ stdenv.mkDerivation rec {

  dontBuild = true;

  nativeBuildInputs = [ makeWrapper dpkg desktop-file-utils ];
  nativeBuildInputs = [ makeWrapper dpkg desktop-file-utils asar ];

  unpackPhase = "dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner";

  installPhase = ''
  installPhase = let
    libPath = lib.makeLibraryPath [
      libsecret
      glib
      stdenv.cc.cc.lib
    ];
  in
    ''
    runHook preInstall

    mkdir -p $out/bin $out/share/standardnotes
    cp -R usr/share/{applications,icons} $out/share
    cp -R opt/Standard\ Notes/resources/app.asar $out/share/standardnotes/
    asar e $out/share/standardnotes/app.asar asar-unpacked
    find asar-unpacked -name '*.node' -exec patchelf \
      --add-rpath "${libPath}" \
      {} \;
    asar p asar-unpacked $out/share/standardnotes/app.asar

    makeWrapper ${electron}/bin/electron $out/bin/standardnotes \
      --add-flags $out/share/standardnotes/app.asar