@@ -0,0 +1,65 @@
1+{ stdenv, fetchurl, appimageTools, undmg, libsecret }:
2+let
3+ inherit (stdenv.hostPlatform) system;
4+ throwSystem = throw "Unsupported system: ${system}";
5+
6+ pname = "keeweb";
7+ version = "1.15.7";
8+ name = "${pname}-${version}";
9+
10+ suffix = {
11+ x86_64-linux = "linux.AppImage";
12+ x86_64-darwin = "mac.dmg";
13+ }.${system} or throwSystem;
14+
15+ src = fetchurl {
16+ url = "https://github.com/keeweb/keeweb/releases/download/v${version}/KeeWeb-${version}.${suffix}";
17+ sha256 = {
18+ x86_64-linux = "0cy0avl0m07xs523xm0rzsmifl28sv4rjb2jj3x492qmr2v64ckk";
19+ x86_64-darwin = "0r8c3zi0ibj0bb0gfc1axfn0y4qpjqfr0xpcxf810d65kaz6wic4";
20+ }.${system} or throwSystem;
21+ };
22+
23+ appimageContents = appimageTools.extract {
24+ inherit name src;
25+ };
26+
27+ meta = with stdenv.lib; {
28+ description = "Free cross-platform password manager compatible with KeePass";
29+ homepage = "https://keeweb.info/";
30+ license = licenses.mit;
31+ maintainers = with maintainers; [ sikmir ];
32+ platforms = [ "x86_64-linux" "x86_64-darwin" ];
33+ };
34+
35+ linux = appimageTools.wrapType2 rec {
36+ inherit name src meta;
37+
38+ extraPkgs = pkgs: with pkgs; [ libsecret ];
39+
40+ extraInstallCommands = ''
41+ mv $out/bin/{${name},${pname}}
42+ install -Dm644 ${appimageContents}/keeweb.desktop -t $out/share/applications
43+ install -Dm644 ${appimageContents}/keeweb.png -t $out/share/icons/hicolor/256x256/apps
44+ install -Dm644 ${appimageContents}/usr/share/mime/keeweb.xml -t $out/share/mime
45+ substituteInPlace $out/share/applications/keeweb.desktop \
46+ --replace 'Exec=AppRun' 'Exec=${pname}'
47+ '';
48+ };
49+
50+ darwin = stdenv.mkDerivation {
51+ inherit pname version src meta;
52+
53+ nativeBuildInputs = [ undmg ];
54+
55+ sourceRoot = "KeeWeb.app";
56+
57+ installPhase = ''
58+ mkdir -p $out/Applications/KeeWeb.app
59+ cp -R . $out/Applications/KeeWeb.app
60+ '';
61+ };
62+in
63+if stdenv.isDarwin
64+then darwin
65+else linux