Merge pull request #327189 from NixOS/1pwd_darwin-broken

This commit is contained in:
Franz Pletz 2024-07-26 10:31:42 +02:00 committed by GitHub
commit da8fd5be9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 153 additions and 101 deletions

View File

@ -1,16 +1,25 @@
{ stdenv {
, pname stdenv,
, version pname,
, src version,
, meta src,
, unzip meta,
, undmg unzip,
undmg,
}: }:
stdenv.mkDerivation { stdenv.mkDerivation {
inherit pname version src meta; inherit
pname
version
src
meta
;
nativeBuildInputs = [ unzip undmg ]; nativeBuildInputs = [
unzip
undmg
];
sourceRoot = "."; sourceRoot = ".";

View File

@ -1,13 +1,14 @@
{ stdenv {
, callPackage stdenv,
, channel ? "stable" callPackage,
, fetchurl channel ? "stable",
, lib fetchurl,
# This is only relevant for Linux, so we need to pass it through lib,
, polkitPolicyOwners ? [ ] }: # This is only relevant for Linux, so we need to pass it through
polkitPolicyOwners ? [ ],
}:
let let
pname = "1password"; pname = "1password";
version = if channel == "stable" then "8.10.36" else "8.10.38-13.BETA"; version = if channel == "stable" then "8.10.36" else "8.10.38-13.BETA";
@ -51,19 +52,46 @@ let
}; };
src = fetchurl { src = fetchurl {
inherit (sources.${channel}.${stdenv.system} or (throw "unsupported system ${stdenv.hostPlatform.system}")) url hash; inherit
(sources.${channel}.${stdenv.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"))
url
hash
;
}; };
meta = with lib; { meta = {
# Requires to be installed in "/Application" which is not possible for now (https://github.com/NixOS/nixpkgs/issues/254944)
broken = stdenv.isDarwin;
description = "Multi-platform password manager"; description = "Multi-platform password manager";
homepage = "https://1password.com/"; homepage = "https://1password.com/";
sourceProvenance = with sourceTypes; [ binaryNativeCode ]; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = licenses.unfree; license = lib.licenses.unfree;
maintainers = with maintainers; [ timstott savannidgerinel sebtm ]; maintainers = with lib.maintainers; [
timstott
savannidgerinel
sebtm
];
platforms = builtins.attrNames sources.${channel}; platforms = builtins.attrNames sources.${channel};
mainProgram = "1password"; mainProgram = "1password";
}; };
in if stdenv.isDarwin in
then callPackage ./darwin.nix { inherit pname version src meta; } if stdenv.isDarwin then
else callPackage ./linux.nix { inherit pname version src meta polkitPolicyOwners; } callPackage ./darwin.nix {
inherit
pname
version
src
meta
;
}
else
callPackage ./linux.nix {
inherit
pname
version
src
meta
polkitPolicyOwners
;
}

View File

@ -1,55 +1,65 @@
{ lib {
, stdenv lib,
, pname stdenv,
, version pname,
, src version,
, meta src,
, makeShellWrapper meta,
, wrapGAppsHook3 makeShellWrapper,
, alsa-lib wrapGAppsHook3,
, at-spi2-atk alsa-lib,
, at-spi2-core at-spi2-atk,
, atk at-spi2-core,
, cairo atk,
, cups cairo,
, dbus cups,
, expat dbus,
, gdk-pixbuf expat,
, glib gdk-pixbuf,
, gtk3 glib,
, libX11 gtk3,
, libXcomposite libX11,
, libXdamage libXcomposite,
, libXext libXdamage,
, libXfixes libXext,
, libXrandr libXfixes,
, libdrm libXrandr,
, libxcb libdrm,
, libxkbcommon libxcb,
, libxshmfence libxkbcommon,
, libGL libxshmfence,
, libappindicator-gtk3 libGL,
, mesa libappindicator-gtk3,
, nspr mesa,
, nss nspr,
, pango nss,
, systemd pango,
, udev systemd,
, xdg-utils udev,
xdg-utils,
# The 1Password polkit file requires a list of users for whom polkit # The 1Password polkit file requires a list of users for whom polkit
# integrations should be enabled. This should be a list of strings that # integrations should be enabled. This should be a list of strings that
# correspond to usernames. # correspond to usernames.
, polkitPolicyOwners ? [] polkitPolicyOwners ? [ ],
}: }:
let let
# Convert the polkitPolicyOwners variable to a polkit-compatible string for the polkit file. # Convert the polkitPolicyOwners variable to a polkit-compatible string for the polkit file.
policyOwners = lib.concatStringsSep " " (map (user: "unix-user:${user}") polkitPolicyOwners); policyOwners = lib.concatStringsSep " " (map (user: "unix-user:${user}") polkitPolicyOwners);
in stdenv.mkDerivation { in
inherit pname version src meta; stdenv.mkDerivation {
inherit
pname
version
src
meta
;
nativeBuildInputs = [ makeShellWrapper wrapGAppsHook3 ]; nativeBuildInputs = [
makeShellWrapper
wrapGAppsHook3
];
buildInputs = [ glib ]; buildInputs = [ glib ];
dontConfigure = true; dontConfigure = true;
@ -58,37 +68,41 @@ in stdenv.mkDerivation {
dontWrapGApps = true; dontWrapGApps = true;
installPhase = installPhase =
let rpath = lib.makeLibraryPath [ let
alsa-lib rpath =
at-spi2-atk lib.makeLibraryPath [
at-spi2-core alsa-lib
atk at-spi2-atk
cairo at-spi2-core
cups atk
dbus cairo
expat cups
gdk-pixbuf dbus
glib expat
gtk3 gdk-pixbuf
libX11 glib
libXcomposite gtk3
libXdamage libX11
libXext libXcomposite
libXfixes libXdamage
libXrandr libXext
libdrm libXfixes
libxcb libXrandr
libxkbcommon libdrm
libxshmfence libxcb
libGL libxkbcommon
libappindicator-gtk3 libxshmfence
mesa libGL
nspr libappindicator-gtk3
nss mesa
pango nspr
systemd nss
] + ":${stdenv.cc.cc.lib}/lib64"; pango
in '' systemd
]
+ ":${stdenv.cc.cc.lib}/lib64";
in
''
runHook preInstall runHook preInstall
mkdir -p $out/bin $out/share/1password mkdir -p $out/bin $out/share/1password
@ -99,12 +113,13 @@ in stdenv.mkDerivation {
substituteInPlace $out/share/applications/${pname}.desktop \ substituteInPlace $out/share/applications/${pname}.desktop \
--replace 'Exec=/opt/1Password/${pname}' 'Exec=${pname}' --replace 'Exec=/opt/1Password/${pname}' 'Exec=${pname}'
'' + (lib.optionalString (polkitPolicyOwners != [ ]) ''
'' + (lib.optionalString (polkitPolicyOwners != [ ]) ''
# Polkit file # Polkit file
mkdir -p $out/share/polkit-1/actions 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}" substitute com.1password.1Password.policy.tpl $out/share/polkit-1/actions/com.1password.1Password.policy --replace "\''${POLICY_OWNERS}" "${policyOwners}"
'') + '' '')
+ ''
# Icons # Icons
cp -a resources/icons $out/share cp -a resources/icons $out/share