keepass: bring back and update plugins load patches Plugins loading was broken as those patches were removed in latest release. I brought patches back and updated them onto 2.38 release code base.

This closes #35446.

+37 -6
+23 -6
pkgs/applications/misc/keepass/default.nix
··· 1 1 { stdenv, lib, fetchurl, buildDotnetPackage, substituteAll, makeWrapper, makeDesktopItem, 2 2 unzip, icoutils, gtk2, xorg, xdotool, xsel, plugins ? [] }: 3 3 4 - # KeePass looks for plugins in under directory in which KeePass.exe is 5 - # located. It follows symlinks where looking for that directory, so 6 - # buildEnv is not enough to bring KeePass and plugins together. 7 - # 8 - # This derivation patches KeePass to search for plugins in specified 9 - # plugin derivations in the Nix store and nowhere else. 10 4 with builtins; buildDotnetPackage rec { 11 5 baseName = "keepass"; 12 6 version = "2.38"; ··· 28 22 xdotool = "${xdotool}/bin/xdotool"; 29 23 }) 30 24 ]; 25 + 26 + # KeePass looks for plugins in under directory in which KeePass.exe is 27 + # located. It follows symlinks where looking for that directory, so 28 + # buildEnv is not enough to bring KeePass and plugins together. 29 + # 30 + # This derivation patches KeePass to search for plugins in specified 31 + # plugin derivations in the Nix store and nowhere else. 32 + pluginLoadPathsPatch = 33 + let outputLc = toString (add 7 (length plugins)); 34 + patchTemplate = readFile ./keepass-plugins.patch; 35 + loadTemplate = readFile ./keepass-plugins-load.patch; 36 + loads = 37 + lib.concatStrings 38 + (map 39 + (p: replaceStrings ["$PATH$"] [ (unsafeDiscardStringContext (toString p)) ] loadTemplate) 40 + plugins); 41 + in replaceStrings ["$OUTPUT_LC$" "$DO_LOADS$"] [outputLc loads] patchTemplate; 42 + 43 + passAsFile = [ "pluginLoadPathsPatch" ]; 44 + postPatch = '' 45 + sed -i 's/\r*$//' KeePass/Forms/MainForm.cs 46 + patch -p1 <$pluginLoadPathsPatchPath 47 + ''; 31 48 32 49 preConfigure = '' 33 50 rm -rvf Build/*
+1
pkgs/applications/misc/keepass/keepass-plugins-load.patch
··· 1 + + m_pluginManager.LoadAllPlugins("$PATH$/lib/dotnet/keepass", SearchOption.TopDirectoryOnly, new string[] {});
+13
pkgs/applications/misc/keepass/keepass-plugins.patch
··· 1 + diff --git a/KeePass/Forms/MainForm.cs b/KeePass/Forms/MainForm.cs 2 + index 3d5fca0..4c3f3d4 100644 3 + --- a/KeePass/Forms/MainForm.cs 4 + +++ b/KeePass/Forms/MainForm.cs 5 + @@ -406,7 +406,$OUTPUT_LC$ @@ namespace KeePass.Forms 6 + m_pluginManager.Initialize(m_pluginDefaultHost); 7 + 8 + m_pluginManager.UnloadAllPlugins(); 9 + - if(AppPolicy.Current.Plugins) m_pluginManager.LoadAllPlugins(); 10 + $DO_LOADS$+ 11 + 12 + // Delete old files *after* loading plugins (when timestamps 13 + // of loaded plugins have been updated already)