summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2018-02-24 11:09:37 +0000
committerGitHub <noreply@github.com>2018-02-24 11:09:37 +0000
commit9c065623d5129d1966aad73b2196a244d7759694 (patch)
tree3640b45a9f4c7de960b0f4f5d11fd6285aa18ba2 /pkgs
parent5df64232e00528f2b56a354103288682129c046d (diff)
parente3c5cf39bcfd8b66017f91ef29bc90f5e4584a67 (diff)
downloadnixlib-9c065623d5129d1966aad73b2196a244d7759694.tar
nixlib-9c065623d5129d1966aad73b2196a244d7759694.tar.gz
nixlib-9c065623d5129d1966aad73b2196a244d7759694.tar.bz2
nixlib-9c065623d5129d1966aad73b2196a244d7759694.tar.lz
nixlib-9c065623d5129d1966aad73b2196a244d7759694.tar.xz
nixlib-9c065623d5129d1966aad73b2196a244d7759694.tar.zst
nixlib-9c065623d5129d1966aad73b2196a244d7759694.zip
Merge pull request #35447 from svsdep/keepass-plugins-patch-back
keepass: bring back and update plugins load patches
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/misc/keepass/default.nix29
-rw-r--r--pkgs/applications/misc/keepass/keepass-plugins-load.patch1
-rw-r--r--pkgs/applications/misc/keepass/keepass-plugins.patch13
3 files changed, 37 insertions, 6 deletions
diff --git a/pkgs/applications/misc/keepass/default.nix b/pkgs/applications/misc/keepass/default.nix
index 911be6721acb..5e492fc621fe 100644
--- a/pkgs/applications/misc/keepass/default.nix
+++ b/pkgs/applications/misc/keepass/default.nix
@@ -1,12 +1,6 @@
 { stdenv, lib, fetchurl, buildDotnetPackage, substituteAll, makeWrapper, makeDesktopItem,
   unzip, icoutils, gtk2, xorg, xdotool, xsel, plugins ? [] }:
 
-# KeePass looks for plugins in under directory in which KeePass.exe is
-# located. It follows symlinks where looking for that directory, so
-# buildEnv is not enough to bring KeePass and plugins together.
-#
-# This derivation patches KeePass to search for plugins in specified
-# plugin derivations in the Nix store and nowhere else.
 with builtins; buildDotnetPackage rec {
   baseName = "keepass";
   version = "2.38";
@@ -29,6 +23,29 @@ with builtins; buildDotnetPackage rec {
     })
   ];
 
+  # KeePass looks for plugins in under directory in which KeePass.exe is
+  # located. It follows symlinks where looking for that directory, so
+  # buildEnv is not enough to bring KeePass and plugins together.
+  #
+  # This derivation patches KeePass to search for plugins in specified
+  # plugin derivations in the Nix store and nowhere else.
+  pluginLoadPathsPatch =
+    let outputLc = toString (add 7 (length plugins));
+        patchTemplate = readFile ./keepass-plugins.patch;
+        loadTemplate  = readFile ./keepass-plugins-load.patch;
+        loads =
+          lib.concatStrings
+            (map
+              (p: replaceStrings ["$PATH$"] [ (unsafeDiscardStringContext (toString p)) ] loadTemplate)
+              plugins);
+    in replaceStrings ["$OUTPUT_LC$" "$DO_LOADS$"] [outputLc loads] patchTemplate;
+
+  passAsFile = [ "pluginLoadPathsPatch" ];
+  postPatch = ''
+    sed -i 's/\r*$//' KeePass/Forms/MainForm.cs
+    patch -p1 <$pluginLoadPathsPatchPath
+  '';
+
   preConfigure = ''
     rm -rvf Build/*
     find . -name "*.sln" -print -exec sed -i 's/Format Version 10.00/Format Version 11.00/g' {} \;
diff --git a/pkgs/applications/misc/keepass/keepass-plugins-load.patch b/pkgs/applications/misc/keepass/keepass-plugins-load.patch
new file mode 100644
index 000000000000..ca52e7ef191a
--- /dev/null
+++ b/pkgs/applications/misc/keepass/keepass-plugins-load.patch
@@ -0,0 +1 @@
++			m_pluginManager.LoadAllPlugins("$PATH$/lib/dotnet/keepass", SearchOption.TopDirectoryOnly, new string[] {});
diff --git a/pkgs/applications/misc/keepass/keepass-plugins.patch b/pkgs/applications/misc/keepass/keepass-plugins.patch
new file mode 100644
index 000000000000..cde6e7252bc3
--- /dev/null
+++ b/pkgs/applications/misc/keepass/keepass-plugins.patch
@@ -0,0 +1,13 @@
+diff --git a/KeePass/Forms/MainForm.cs b/KeePass/Forms/MainForm.cs
+index 3d5fca0..4c3f3d4 100644
+--- a/KeePass/Forms/MainForm.cs
++++ b/KeePass/Forms/MainForm.cs
+@@ -406,7 +406,$OUTPUT_LC$ @@ namespace KeePass.Forms
+ 			m_pluginManager.Initialize(m_pluginDefaultHost);
+ 
+ 			m_pluginManager.UnloadAllPlugins();
+-			if(AppPolicy.Current.Plugins) m_pluginManager.LoadAllPlugins();
+$DO_LOADS$+
+ 
+ 			// Delete old files *after* loading plugins (when timestamps
+ 			// of loaded plugins have been updated already)