Merge pull request #210556 from LostAttractor/keeweb

keeweb: use debian package instead appimage
This commit is contained in:
Jörg Thalheim 2023-01-16 01:31:02 +01:00 committed by GitHub
commit 0e111b34f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,13 +1,34 @@
{ lib, stdenv, fetchurl, appimageTools, undmg, libsecret, libxshmfence }:
{ lib
, stdenv
, fetchurl
, undmg
, dpkg
, autoPatchelfHook
, wrapGAppsHook
, makeWrapper
, alsa-lib
, at-spi2-atk
, gdk-pixbuf
, glibc
, nss
, udev
, xorg
, gnome
, mesa
, gtk3
, libusb1
, libsecret
, libappindicator
, xdotool
}:
let
pname = "keeweb";
version = "1.18.7";
name = "${pname}-${version}";
srcs = {
x86_64-linux = fetchurl {
url = "https://github.com/keeweb/keeweb/releases/download/v${version}/KeeWeb-${version}.linux.AppImage";
hash = "sha256-W3Dfo7YZfLObodAS7ZN3jqnYzLNAnjJIfJC6il5THwY=";
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";
@ -18,11 +39,29 @@ let
hash = "sha256-bkhwsWYLkec16vMOfXUce7jfrmI9W2xHiZvU1asebK4=";
};
};
src = srcs.${stdenv.hostPlatform.system};
src = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
appimageContents = appimageTools.extract {
inherit name src;
};
libraries = [
alsa-lib
at-spi2-atk
gdk-pixbuf
nss
udev
xorg.libX11
xorg.libXcomposite
xorg.libXext
xorg.libXrandr
xorg.libXScrnSaver
xorg.libXtst
xorg.libxshmfence
gnome.gnome-keyring
mesa
gtk3
libusb1
libsecret
libappindicator
xdotool
];
meta = with lib; {
description = "Free cross-platform password manager compatible with KeePass";
@ -33,35 +72,46 @@ let
maintainers = with maintainers; [ sikmir ];
platforms = builtins.attrNames srcs;
};
linux = appimageTools.wrapType2 rec {
inherit name src meta;
extraPkgs = pkgs: with pkgs; [ libsecret libxshmfence ];
extraInstallCommands = ''
mv $out/bin/{${name},${pname}}
install -Dm644 ${appimageContents}/keeweb.desktop -t $out/share/applications
install -Dm644 ${appimageContents}/keeweb.png -t $out/share/icons/hicolor/256x256/apps
install -Dm644 ${appimageContents}/usr/share/mime/keeweb.xml -t $out/share/mime
substituteInPlace $out/share/applications/keeweb.desktop \
--replace "Exec=AppRun" "Exec=$out/bin/${pname}"
'';
};
darwin = stdenv.mkDerivation {
inherit pname version src meta;
nativeBuildInputs = [ undmg ];
sourceRoot = ".";
installPhase = ''
mkdir -p $out/Applications
cp -r *.app $out/Applications
'';
};
in
if stdenv.isDarwin
then darwin
else linux
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
wrapGAppsHook
makeWrapper
];
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
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}"
runHook postInstall
'';
}