2021-01-25 08:26:54 +00:00
|
|
|
{ lib, fetchurl, buildDotnetPackage, substituteAll, makeWrapper, makeDesktopItem,
|
2020-05-19 09:00:59 +00:00
|
|
|
unzip, icoutils, gtk2, xorg, xdotool, xsel, coreutils, unixtools, glib, plugins ? [] }:
|
2022-08-23 23:02:47 +00:00
|
|
|
let
|
|
|
|
inherit (builtins) add length readFile replaceStrings unsafeDiscardStringContext toString map;
|
|
|
|
in buildDotnetPackage rec {
|
2021-11-08 16:12:26 +00:00
|
|
|
pname = "keepass";
|
2021-12-01 12:11:40 +00:00
|
|
|
version = "2.49";
|
2013-06-09 21:17:09 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2015-05-22 13:25:02 +00:00
|
|
|
url = "mirror://sourceforge/keepass/KeePass-${version}-Source.zip";
|
2021-12-01 12:11:40 +00:00
|
|
|
sha256 = "sha256-1hg4bRuQSG+UzEQGeQcSURTmTxt5ITGQqfg0IS7RWt0=";
|
2013-06-09 21:17:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
sourceRoot = ".";
|
|
|
|
|
2021-02-20 21:01:53 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper unzip ];
|
|
|
|
buildInputs = [ icoutils ];
|
2015-05-22 13:25:02 +00:00
|
|
|
|
2018-02-22 15:25:20 +00:00
|
|
|
patches = [
|
|
|
|
(substituteAll {
|
|
|
|
src = ./fix-paths.patch;
|
|
|
|
xsel = "${xsel}/bin/xsel";
|
|
|
|
xprop = "${xorg.xprop}/bin/xprop";
|
|
|
|
xdotool = "${xdotool}/bin/xdotool";
|
2020-05-19 09:00:59 +00:00
|
|
|
uname = "${coreutils}/bin/uname";
|
|
|
|
whereis = "${unixtools.whereis}/bin/whereis";
|
|
|
|
gsettings = "${glib}/bin/gsettings";
|
2018-02-22 15:25:20 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2018-02-24 06:38:36 +00: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.
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2016-01-29 20:10:26 +00: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 21:17:09 +00:00
|
|
|
|
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = "keepass";
|
|
|
|
exec = "keepass";
|
|
|
|
comment = "Password manager";
|
2015-09-20 02:04:16 +00:00
|
|
|
icon = "keepass";
|
2013-06-09 21:17:09 +00:00
|
|
|
desktopName = "Keepass";
|
2015-11-22 17:21:13 +00:00
|
|
|
genericName = "Password manager";
|
2022-02-22 14:56:15 +00:00
|
|
|
categories = [ "Utility" ];
|
|
|
|
mimeTypes = [ "application/x-keepass2" ];
|
2013-06-09 21:17:09 +00:00
|
|
|
};
|
|
|
|
|
2021-12-01 11:56:22 +00:00
|
|
|
outputFiles = [
|
|
|
|
"Build/KeePass/Release/*"
|
|
|
|
"Build/KeePassLib/Release/*"
|
|
|
|
"Ext/KeePass.config.xml" # contains <PreferUserConfiguration>true</PreferUserConfiguration>
|
|
|
|
];
|
2015-05-22 13:25:02 +00:00
|
|
|
dllFiles = [ "KeePassLib.dll" ];
|
|
|
|
exeFiles = [ "KeePass.exe" ];
|
2013-06-09 21:17:09 +00:00
|
|
|
|
2015-11-22 17:21:13 +00: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.
|
2021-08-28 15:18:03 +00:00
|
|
|
binPaths = lib.concatStringsSep ":" (map (x: x + "/bin") plugins);
|
2015-11-22 17:21:13 +00:00
|
|
|
|
2021-01-15 05:42:41 +00:00
|
|
|
dynlibPath = lib.makeLibraryPath [ gtk2 ];
|
2016-05-05 09:25:24 +00:00
|
|
|
|
2020-09-19 09:13:56 +00:00
|
|
|
postInstall =
|
2015-09-20 02:04:16 +00:00
|
|
|
let
|
|
|
|
extractFDeskIcons = ./extractWinRscIconsToStdFreeDesktopDir.sh;
|
|
|
|
in
|
|
|
|
''
|
2014-06-30 12:56:10 +00:00
|
|
|
mkdir -p "$out/share/applications"
|
2013-06-09 21:17:09 +00:00
|
|
|
cp ${desktopItem}/share/applications/* $out/share/applications
|
2016-05-05 09:25:24 +00:00
|
|
|
wrapProgram $out/bin/keepass \
|
|
|
|
--prefix PATH : "$binPaths" \
|
|
|
|
--prefix LD_LIBRARY_PATH : "$dynlibPath"
|
2015-09-20 02:04:16 +00: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 21:17:09 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "GUI password manager with strong cryptography";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "http://www.keepass.info/";
|
2021-01-28 22:27:46 +00:00
|
|
|
maintainers = with lib.maintainers; [ amorsillo obadz ];
|
2021-01-15 05:42:41 +00:00
|
|
|
platforms = with lib.platforms; all;
|
|
|
|
license = lib.licenses.gpl2;
|
2013-06-09 21:17:09 +00:00
|
|
|
};
|
|
|
|
}
|