keepass: load plugins from store paths, fixes #11206
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user