_1password-gui: use the upstream tarball rather than AppImage

AgileBits now provides tarballs of 1Password for Linux, which is more
convenient for us than AppImages.

Also include the browser support and keyring helper programs.

Thanks to Savanni D'Gerinel for providing many of the changes made in
this PR.
This commit is contained in:
Daniël de Kok 2021-03-28 10:40:34 +02:00
parent 85aef7706e
commit ad09957566

View File

@ -1,6 +1,6 @@
{ lib, stdenv
{ lib
, stdenv
, fetchurl
, appimageTools
, makeWrapper
, electron_11
, openssl
@ -11,18 +11,12 @@ stdenv.mkDerivation rec {
version = "8.0.30";
src = fetchurl {
url = "https://onepassword.s3.amazonaws.com/linux/appimage/${pname}-${version}.AppImage";
hash = "sha256-j+fp/f8nta+OOuOFU4mmUrGYlVmAqdaXO4rLJ0in+m8=";
url = "https://downloads.1password.com/linux/tar/1password-${version}.tar.gz";
hash = "sha256-R4Tbu2TAig0iF/IN8hnO3Bzqqj6Ru1YyyGhzraM7/9Y=";
};
nativeBuildInputs = [ makeWrapper ];
appimageContents = appimageTools.extractType2 {
name = "${pname}-${version}";
inherit src;
};
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
@ -35,20 +29,33 @@ stdenv.mkDerivation rec {
mkdir -p $out/bin $out/share/1password
# Applications files.
cp -a ${appimageContents}/{locales,resources} $out/share/${pname}
cp -a {locales,resources} $out/share/${pname}
install -Dm0755 -t $out/share/${pname} {1Password-BrowserSupport,1Password-KeyringHelper}
# Desktop file.
install -Dt $out/share/applications ${appimageContents}/${pname}.desktop
install -Dt $out/share/applications usr/share/applications/${pname}.desktop
substituteInPlace $out/share/applications/${pname}.desktop \
--replace 'Exec=AppRun' 'Exec=${pname}'
--replace 'Exec=/opt/1Password/${pname}' 'Exec=${pname}'
# Icons.
cp -a ${appimageContents}/usr/share/icons $out/share
cp -a usr/share/icons $out/share
# Wrap the application with Electron.
makeWrapper "${electron_11}/bin/electron" "$out/bin/${pname}" \
--add-flags "$out/share/${pname}/resources/app.asar" \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeLibs}"
# Set the interpreter for the helper binaries and wrap them with
# the runtime libraries.
interp="$(cat $NIX_CC/nix-support/dynamic-linker)"
patchelf --set-interpreter $interp \
$out/share/$pname/{1Password-BrowserSupport,1Password-KeyringHelper}
wrapProgram $out/share/${pname}/1Password-BrowserSupport \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeLibs}"
wrapProgram $out/share/${pname}/1Password-KeyringHelper \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeLibs}"
'';
passthru.updateScript = ./update.sh;