nixpkgs/pkgs/applications/misc/1password-gui/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

152 lines
3.9 KiB
Nix
Raw Normal View History

{ lib
, stdenv
2020-08-08 07:06:45 +00:00
, fetchurl
, makeWrapper
, wrapGAppsHook
, alsa-lib
, at-spi2-atk
, at-spi2-core
, atk
, cairo
, cups
, dbus
, expat
, gdk-pixbuf
, glib
, gtk3
, libX11
, libXcomposite
, libXdamage
, libXext
, libXfixes
, libXrandr
, libdrm
, libxcb
, libxkbcommon
, libxshmfence
, libGL
2022-08-12 21:46:13 +00:00
, libappindicator-gtk3
, mesa
, nspr
, nss
, pango
, systemd
, udev
, xdg-utils
2022-03-16 18:09:37 +00:00
# The 1Password polkit file requires a list of users for whom polkit
# integrations should be enabled. This should be a list of strings that
# correspond to usernames.
, polkitPolicyOwners ? []
2020-08-08 07:06:45 +00:00
}:
2022-03-16 18:09:37 +00:00
let
# Convert the polkitPolicyOwners variable to a polkit-compatible string for the polkit file.
policyOwners = lib.concatStringsSep " " (map (user: "unix-user:${user}") polkitPolicyOwners);
in stdenv.mkDerivation rec {
2020-08-08 07:06:45 +00:00
pname = "1password";
2022-09-24 10:40:30 +00:00
version = "8.9.4";
2020-08-08 07:06:45 +00:00
2022-08-12 21:46:13 +00:00
src =
if stdenv.hostPlatform.isAarch64 then
fetchurl {
url = "https://downloads.1password.com/linux/tar/stable/aarch64/1password-${version}.arm64.tar.gz";
sha256 = "sha256-SJDUfAFEwYnOR+y/6Dg2S/CkA84QogoRpMXOPP5PyrM=";
2022-08-12 21:46:13 +00:00
}
else
fetchurl {
url = "https://downloads.1password.com/linux/tar/stable/x86_64/1password-${version}.x64.tar.gz";
2022-09-24 10:40:30 +00:00
sha256 = "sha256-Smq0gOGfBTjIOMwF1AI+TJwXaIiTi/YP9mGIqcjsCNQ=";
2022-08-12 21:46:13 +00:00
};
2020-08-08 07:06:45 +00:00
nativeBuildInputs = [ makeWrapper wrapGAppsHook ];
buildInputs = [ glib ];
2020-08-08 07:06:45 +00:00
dontConfigure = true;
dontBuild = true;
dontPatchELF = true;
dontWrapGApps = true;
2020-08-08 07:06:45 +00:00
installPhase =
let rpath = lib.makeLibraryPath [
alsa-lib
at-spi2-atk
at-spi2-core
atk
cairo
cups
dbus
expat
gdk-pixbuf
glib
gtk3
libX11
libXcomposite
libXdamage
libXext
libXfixes
libXrandr
libdrm
libxcb
libxkbcommon
libxshmfence
libGL
libappindicator-gtk3
mesa
nspr
nss
pango
systemd
] + ":${stdenv.cc.cc.lib}/lib64";
in ''
runHook preInstall
2020-08-08 07:06:45 +00:00
mkdir -p $out/bin $out/share/1password
cp -a * $out/share/1password
2020-08-08 07:06:45 +00:00
# Desktop file
install -Dt $out/share/applications resources/${pname}.desktop
substituteInPlace $out/share/applications/${pname}.desktop \
--replace 'Exec=/opt/1Password/${pname}' 'Exec=${pname}'
2020-08-08 07:06:45 +00:00
2022-03-16 18:09:37 +00:00
'' + (lib.optionalString (polkitPolicyOwners != [ ])
''
# Polkit file
2022-03-16 18:09:37 +00:00
mkdir -p $out/share/polkit-1/actions
substitute com.1password.1Password.policy.tpl $out/share/polkit-1/actions/com.1password.1Password.policy --replace "\''${POLICY_OWNERS}" "${policyOwners}"
'') + ''
# Icons
cp -a resources/icons $out/share
interp="$(cat $NIX_CC/nix-support/dynamic-linker)"
2022-09-29 03:49:59 +00:00
patchelf --set-interpreter $interp $out/share/1password/{1password,1Password-BrowserSupport,1Password-KeyringHelper,op-ssh-sign}
patchelf --set-rpath ${rpath}:$out/share/1password $out/share/1password/{1password,1Password-BrowserSupport,1Password-KeyringHelper,op-ssh-sign}
for file in $(find $out -type f -name \*.so\* ); do
patchelf --set-rpath ${rpath}:$out/share/1password $file
done
runHook postInstall
'';
2020-08-08 07:06:45 +00:00
preFixup = ''
# Electron is trying to open udev via dlopen()
# and for some reason that doesn't seem to be impacted from the rpath.
# Adding udev to LD_LIBRARY_PATH fixes that.
# Make xdg-open overrideable at runtime.
makeWrapper $out/share/1password/1password $out/bin/1password \
''${gappsWrapperArgs[@]} \
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ udev ]}
'';
meta = with lib; {
2020-08-08 07:06:45 +00:00
description = "Multi-platform password manager";
homepage = "https://1password.com/";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
2020-08-08 07:06:45 +00:00
license = licenses.unfree;
2022-04-18 01:09:43 +00:00
maintainers = with maintainers; [ timstott savannidgerinel maxeaubrey sebtm ];
2022-08-12 21:46:13 +00:00
platforms = [ "x86_64-linux" "aarch64-linux" ];
2020-08-08 07:06:45 +00:00
};
}