2016-05-05 11:25:24 +02:00
|
|
|
{ stdenv, lib, fetchurl, buildDotnetPackage, makeWrapper, unzip, makeDesktopItem, icoutils, gtk2, plugins ? [] }:
|
2013-06-09 23:17:09 +02:00
|
|
|
|
2015-11-22 18:21:13 +01:00
|
|
|
# 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 {
|
2015-05-22 15:25:02 +02:00
|
|
|
baseName = "keepass";
|
2017-02-18 11:10:50 +01:00
|
|
|
version = "2.35";
|
2013-06-09 23:17:09 +02:00
|
|
|
|
|
|
|
src = fetchurl {
|
2015-05-22 15:25:02 +02:00
|
|
|
url = "mirror://sourceforge/keepass/KeePass-${version}-Source.zip";
|
2017-02-18 11:10:50 +01:00
|
|
|
sha256 = "1pv3x1lr2kymjpm6z26fqx997jivzy0diqsysq4diygj38wdkajz";
|
2013-06-09 23:17:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
sourceRoot = ".";
|
|
|
|
|
2015-09-20 04:04:16 +02:00
|
|
|
buildInputs = [ unzip makeWrapper icoutils ];
|
2015-05-22 15:25:02 +02:00
|
|
|
|
2015-11-22 18:21:13 +01:00
|
|
|
pluginLoadPathsPatch =
|
2016-09-15 22:24:36 +02:00
|
|
|
let outputLc = toString (add 7 (length plugins));
|
2015-11-22 18:21:13 +01:00
|
|
|
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 = ''
|
2016-01-29 21:10:26 +01:00
|
|
|
sed -i 's/\r*$//' KeePass/Forms/MainForm.cs
|
|
|
|
patch -p1 <$pluginLoadPathsPatchPath
|
2015-11-22 18:21:13 +01:00
|
|
|
'';
|
|
|
|
|
2016-01-29 21:10:26 +01:00
|
|
|
preConfigure = ''
|
|
|
|
rm -rvf Build/*
|
|
|
|
find . -name "*.sln" -print -exec sed -i 's/Format Version 10.00/Format Version 11.00/g' {} \;
|
|
|
|
find . -name "*.csproj" -print -exec sed -i '
|
|
|
|
s#ToolsVersion="3.5"#ToolsVersion="4.0"#g
|
|
|
|
s#<TargetFrameworkVersion>.*</TargetFrameworkVersion>##g
|
|
|
|
s#<PropertyGroup>#<PropertyGroup><TargetFrameworkVersion>v4.5</TargetFrameworkVersion>#g
|
|
|
|
s#<SignAssembly>.*$#<SignAssembly>false</SignAssembly>#g
|
|
|
|
s#<PostBuildEvent>.*sgen.exe.*$##
|
|
|
|
' {} \;
|
|
|
|
'';
|
2013-06-09 23:17:09 +02:00
|
|
|
|
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = "keepass";
|
|
|
|
exec = "keepass";
|
|
|
|
comment = "Password manager";
|
2015-09-20 04:04:16 +02:00
|
|
|
icon = "keepass";
|
2013-06-09 23:17:09 +02:00
|
|
|
desktopName = "Keepass";
|
2015-11-22 18:21:13 +01:00
|
|
|
genericName = "Password manager";
|
2015-09-20 04:04:16 +02:00
|
|
|
categories = "Application;Utility;";
|
|
|
|
mimeType = stdenv.lib.concatStringsSep ";" [
|
|
|
|
"application/x-keepass2"
|
|
|
|
""
|
|
|
|
];
|
2013-06-09 23:17:09 +02:00
|
|
|
};
|
|
|
|
|
2015-05-22 15:25:02 +02:00
|
|
|
outputFiles = [ "Build/KeePass/Release/*" "Build/KeePassLib/Release/*" ];
|
|
|
|
dllFiles = [ "KeePassLib.dll" ];
|
|
|
|
exeFiles = [ "KeePass.exe" ];
|
2013-06-09 23:17:09 +02:00
|
|
|
|
2015-11-22 18:21:13 +01:00
|
|
|
# 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));
|
|
|
|
|
2016-05-05 11:25:24 +02:00
|
|
|
dynlibPath = stdenv.lib.makeLibraryPath [ gtk2 ];
|
|
|
|
|
2015-09-20 04:04:16 +02:00
|
|
|
postInstall =
|
|
|
|
let
|
|
|
|
extractFDeskIcons = ./extractWinRscIconsToStdFreeDesktopDir.sh;
|
|
|
|
in
|
|
|
|
''
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p "$out/share/applications"
|
2013-06-09 23:17:09 +02:00
|
|
|
cp ${desktopItem}/share/applications/* $out/share/applications
|
2016-05-05 11:25:24 +02:00
|
|
|
wrapProgram $out/bin/keepass \
|
|
|
|
--prefix PATH : "$binPaths" \
|
|
|
|
--prefix LD_LIBRARY_PATH : "$dynlibPath"
|
2015-09-20 04:04:16 +02:00
|
|
|
|
|
|
|
${extractFDeskIcons} \
|
|
|
|
"./Translation/TrlUtil/Resources/KeePass.ico" \
|
|
|
|
'[^\.]+_[0-9]+_([0-9]+x[0-9]+)x[0-9]+\.png' \
|
|
|
|
'\1' \
|
|
|
|
'([^\.]+).+' \
|
|
|
|
'keepass' \
|
|
|
|
"$out" \
|
|
|
|
"./tmp"
|
2013-06-09 23:17:09 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "GUI password manager with strong cryptography";
|
|
|
|
homepage = http://www.keepass.info/;
|
2015-09-20 04:04:16 +02:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ amorsillo obadz jraygauthier ];
|
2013-06-09 23:17:09 +02:00
|
|
|
platforms = with stdenv.lib.platforms; all;
|
|
|
|
license = stdenv.lib.licenses.gpl2;
|
|
|
|
};
|
|
|
|
}
|