keepass: load plugins from store paths, fixes #11206

This commit is contained in:
Nicole Angel 2015-11-22 18:21:13 +01:00 committed by Rok Garbas
parent e99beec0e1
commit 90e881eece
4 changed files with 50 additions and 4 deletions

View File

@ -1,6 +1,12 @@
{ stdenv, fetchurl, buildDotnetPackage, makeWrapper, unzip, makeDesktopItem }:
{ stdenv, lib, fetchurl, buildDotnetPackage, makeWrapper, unzip, makeDesktopItem, plugins ? [] }:
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.
with builtins; buildDotnetPackage rec {
baseName = "keepass";
version = "2.30";
@ -11,10 +17,26 @@ buildDotnetPackage rec {
sourceRoot = ".";
buildInputs = [ unzip ];
buildInputs = [ unzip makeWrapper ];
patches = [ ./keepass.patch ];
pluginLoadPathsPatch =
let outputLc = toString (add 8 (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 = ''
patch --binary -p1 <$pluginLoadPathsPatchPath
'';
preConfigure = "rm -rvf Build/*";
desktopItem = makeDesktopItem {
@ -22,7 +44,7 @@ buildDotnetPackage rec {
exec = "keepass";
comment = "Password manager";
desktopName = "Keepass";
genericName = "Password manager";
genericName = "Password manager";
categories = "Application;Other;";
};
@ -30,9 +52,16 @@ buildDotnetPackage rec {
dllFiles = [ "KeePassLib.dll" ];
exeFiles = [ "KeePass.exe" ];
# plgx plugin like keefox requires mono to compile at runtime
# after loading. It is brought into plugins bin/ directory using
# buildEnv in the plugin derivation. Wrapper below makes sure it
# is found and does not pollute output path.
binPaths = lib.concatStrings (lib.intersperse ":" (map (x: x + "/bin") plugins));
postInstall = ''
mkdir -p "$out/share/applications"
cp ${desktopItem}/share/applications/* $out/share/applications
wrapProgram $out/bin/keepass --prefix PATH : "$binPaths"
'';
meta = {

View File

@ -0,0 +1 @@
+ m_pluginManager.LoadAllPlugins("$PATH$/lib/dotnet/keepass");

View File

@ -0,0 +1,14 @@
--- old/KeePass/Forms/MainForm.cs
+++ new/KeePass/Forms/MainForm.cs
@@ -384,9 +384,$OUTPUT_LC$ @@ namespace KeePass.Forms
m_pluginManager.Initialize(m_pluginDefaultHost);
m_pluginManager.UnloadAllPlugins();
- if(AppPolicy.Current.Plugins)
- m_pluginManager.LoadAllPlugins(UrlUtil.GetFileDirectory(
- WinUtil.GetExecutable(), false, true));
+ if(AppPolicy.Current.Plugins) {
$DO_LOADS$+ }
// Delete old files *after* loading plugins (when timestamps
// of loaded plugins have been updated already)

View File

@ -11695,6 +11695,8 @@ let
keepass = callPackage ../applications/misc/keepass { };
keepass-keefox = callPackage ../applications/misc/keepass-plugins/keefox { };
exrdisplay = callPackage ../applications/graphics/exrdisplay {
fltk = fltk20;
};