summary refs log tree commit diff
path: root/pkgs/applications/misc/keepass/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/misc/keepass/default.nix')
-rw-r--r--pkgs/applications/misc/keepass/default.nix29
1 files changed, 23 insertions, 6 deletions
diff --git a/pkgs/applications/misc/keepass/default.nix b/pkgs/applications/misc/keepass/default.nix
index 911be6721ac..5e492fc621f 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' {} \;