2024-01-02 11:29:13 +00:00
|
|
|
{ lib, stdenv, fetchurl
|
|
|
|
, unzip, mono, makeWrapper, icoutils
|
|
|
|
, substituteAll, xsel, xorg, xdotool, coreutils, unixtools, glib
|
|
|
|
, gtk2, makeDesktopItem, plugins ? [] }:
|
|
|
|
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2021-12-24 04:21:11 +00:00
|
|
|
pname = "keepass";
|
2024-06-05 15:53:02 +00:00
|
|
|
version = "2.57";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2024-01-02 11:29:13 +00:00
|
|
|
url = "mirror://sourceforge/keepass/KeePass-${finalAttrs.version}-Source.zip";
|
2024-06-05 15:53:02 +00:00
|
|
|
hash = "sha256-emJ4QhhIaUowG4SAUzRK6hUendc/H6JH09Js2Ji9PQ0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
sourceRoot = ".";
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
unzip
|
|
|
|
mono
|
|
|
|
makeWrapper
|
|
|
|
];
|
2021-03-19 17:17:44 +00:00
|
|
|
buildInputs = [ icoutils ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
patches = [
|
|
|
|
(substituteAll {
|
|
|
|
src = ./fix-paths.patch;
|
|
|
|
xsel = "${xsel}/bin/xsel";
|
|
|
|
xprop = "${xorg.xprop}/bin/xprop";
|
|
|
|
xdotool = "${xdotool}/bin/xdotool";
|
2020-05-29 06:06:01 +00:00
|
|
|
uname = "${coreutils}/bin/uname";
|
|
|
|
whereis = "${unixtools.whereis}/bin/whereis";
|
|
|
|
gsettings = "${glib}/bin/gsettings";
|
2020-04-24 23:36:52 +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.
|
2024-01-02 11:29:13 +00:00
|
|
|
pluginLoadPathsPatch = let
|
|
|
|
inherit (builtins) toString;
|
|
|
|
inherit (lib.strings) readFile concatStrings replaceStrings unsafeDiscardStringContext;
|
|
|
|
inherit (lib.lists) map length;
|
|
|
|
inherit (lib) add;
|
|
|
|
|
|
|
|
outputLc = toString (add 7 (length plugins));
|
|
|
|
patchTemplate = readFile ./keepass-plugins.patch;
|
|
|
|
loadTemplate = readFile ./keepass-plugins-load.patch;
|
|
|
|
loads = concatStrings
|
|
|
|
(map
|
|
|
|
(p: replaceStrings ["$PATH$"] [ (unsafeDiscardStringContext (toString p)) ] loadTemplate)
|
|
|
|
plugins);
|
|
|
|
in
|
|
|
|
replaceStrings ["$OUTPUT_LC$" "$DO_LOADS$"] [outputLc loads] patchTemplate;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
passAsFile = [ "pluginLoadPathsPatch" ];
|
|
|
|
postPatch = ''
|
|
|
|
sed -i 's/\r*$//' KeePass/Forms/MainForm.cs
|
|
|
|
patch -p1 <$pluginLoadPathsPatchPath
|
|
|
|
'';
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
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.*$##
|
|
|
|
' {} \;
|
2024-01-02 11:29:13 +00:00
|
|
|
|
|
|
|
runHook postConfigure
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
xbuild /p:Configuration=Release
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
runHook postBuild
|
2024-01-02 11:29:13 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
outputFiles = [
|
|
|
|
"Build/KeePass/Release/*"
|
|
|
|
"Build/KeePassLib/Release/*"
|
|
|
|
"Ext/KeePass.config.xml" # contains <PreferUserConfiguration>true</PreferUserConfiguration>
|
|
|
|
];
|
2020-04-24 23:36:52 +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-09-18 10:52:07 +00:00
|
|
|
binPaths = lib.concatStringsSep ":" (map (x: x + "/bin") plugins);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
dynlibPath = lib.makeLibraryPath [ gtk2 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
target="$out/lib/dotnet/${finalAttrs.pname}"
|
|
|
|
mkdir -p "$target"
|
|
|
|
|
|
|
|
cp -rv $outputFiles "$target"
|
|
|
|
|
|
|
|
makeWrapper \
|
|
|
|
"${mono}/bin/mono" \
|
|
|
|
"$out/bin/keepass" \
|
|
|
|
--add-flags "$target/KeePass.exe" \
|
2020-04-24 23:36:52 +00:00
|
|
|
--prefix PATH : "$binPaths" \
|
|
|
|
--prefix LD_LIBRARY_PATH : "$dynlibPath"
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
# setup desktop item with icon
|
|
|
|
mkdir -p "$out/share/applications"
|
|
|
|
cp $desktopItem/share/applications/* $out/share/applications
|
|
|
|
|
|
|
|
${./extractWinRscIconsToStdFreeDesktopDir.sh} \
|
2020-04-24 23:36:52 +00:00
|
|
|
"./Translation/TrlUtil/Resources/KeePass.ico" \
|
|
|
|
'[^\.]+_[0-9]+_([0-9]+x[0-9]+)x[0-9]+\.png' \
|
|
|
|
'\1' \
|
|
|
|
'([^\.]+).+' \
|
|
|
|
'keepass' \
|
|
|
|
"$out" \
|
|
|
|
"./tmp"
|
2024-01-02 11:29:13 +00:00
|
|
|
runHook postInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = "keepass";
|
|
|
|
exec = "keepass";
|
|
|
|
comment = "Password manager";
|
|
|
|
icon = "keepass";
|
|
|
|
desktopName = "Keepass";
|
|
|
|
genericName = "Password manager";
|
|
|
|
categories = [ "Utility" ];
|
|
|
|
mimeTypes = [ "application/x-keepass2" ];
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = {
|
|
|
|
description = "GUI password manager with strong cryptography";
|
|
|
|
homepage = "http://www.keepass.info/";
|
2021-02-05 17:12:51 +00:00
|
|
|
maintainers = with lib.maintainers; [ amorsillo obadz ];
|
2021-01-15 22:18:51 +00:00
|
|
|
platforms = with lib.platforms; all;
|
|
|
|
license = lib.licenses.gpl2;
|
2023-08-04 22:07:22 +00:00
|
|
|
mainProgram = "keepass";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
})
|