about summary refs log tree commit diff
path: root/pkgs/by-name/ke/keeweb/package.nix
blob: 48b9a603d84170f7fe1286fdaab3de9c8e0910bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
  lib,
  libGL,
  stdenv,
  fetchurl,
  undmg,
  dpkg,
  autoPatchelfHook,
  wrapGAppsHook3,
  alsa-lib,
  at-spi2-atk,
  gdk-pixbuf,
  nss,
  udev,
  gnome-keyring,
  mesa,
  gtk3,
  libusb1,
  libsecret,
  libappindicator,
  xdotool,
  libX11,
  libXcomposite,
  libXext,
  libXrandr,
  libXScrnSaver,
  libXtst,
  libxshmfence,
}:
let
  pname = "keeweb";
  version = "1.18.7";

  srcs = {
    x86_64-linux = fetchurl {
      url = "https://github.com/keeweb/keeweb/releases/download/v${version}/KeeWeb-${version}.linux.x64.deb";
      hash = "sha256-/U+vn5TLIU9/J6cRFjuAdyGzlwC04mp4L2X2ETp+ZSE=";
    };
    x86_64-darwin = fetchurl {
      url = "https://github.com/keeweb/keeweb/releases/download/v${version}/KeeWeb-${version}.mac.x64.dmg";
      hash = "sha256-+ZFGrrw0tZ7F6lb/3iBIyGD+tp1puVhkPv10hfp6ATU=";
    };
    aarch64-darwin = fetchurl {
      url = "https://github.com/keeweb/keeweb/releases/download/v${version}/KeeWeb-${version}.mac.arm64.dmg";
      hash = "sha256-bkhwsWYLkec16vMOfXUce7jfrmI9W2xHiZvU1asebK4=";
    };
  };
  src =
    srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

  libraries = [
    alsa-lib
    at-spi2-atk
    gdk-pixbuf
    libGL
    nss
    udev
    libX11
    libXcomposite
    libXext
    libXrandr
    libXScrnSaver
    libXtst
    libxshmfence
    gnome-keyring
    mesa
    gtk3
    libusb1
    libsecret
    libappindicator
    xdotool
  ];

  meta = {
    description = "Free cross-platform password manager compatible with KeePass";
    mainProgram = "keeweb";
    homepage = "https://keeweb.info/";
    changelog = "https://github.com/keeweb/keeweb/blob/v${version}/release-notes.md";
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ sikmir ];
    platforms = builtins.attrNames srcs;
  };
in
if stdenv.hostPlatform.isDarwin then
  stdenv.mkDerivation {
    inherit
      pname
      version
      src
      meta
      ;

    nativeBuildInputs = [ undmg ];

    sourceRoot = ".";

    installPhase = ''
      mkdir -p $out/Applications
      cp -r *.app $out/Applications
    '';
  }
else
  stdenv.mkDerivation {
    inherit
      pname
      version
      src
      meta
      ;

    nativeBuildInputs = [
      autoPatchelfHook
      wrapGAppsHook3
    ];

    buildInputs = libraries;

    unpackPhase = ''
      ${dpkg}/bin/dpkg-deb --fsys-tarfile $src | tar --extract
    '';

    installPhase = ''
      runHook preInstall

      mkdir -p $out/bin
      cp -r usr/share $out/share

      runHook postInstall
    '';

    postFixup = ''
      makeWrapper $out/share/keeweb-desktop/keeweb $out/bin/keeweb \
        --argv0 "keeweb" \
        --add-flags "$out/share/keeweb-desktop/resources/app.asar" \
        --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath libraries}" \
        ''${gappsWrapperArgs[@]}
    '';
  }