41 # The 1Password polkit file requires a list of users for whom polkit
42 # integrations should be enabled. This should be a list of strings that
43 # correspond to usernames.
44 polkitPolicyOwners ? [ ],
47 # Convert the polkitPolicyOwners variable to a polkit-compatible string for the polkit file.
48 policyOwners = lib.concatStringsSep " " (map (user: "unix-user:${user}") polkitPolicyOwners);
63 buildInputs = [ glib ];
103 + ":${stdenv.cc.cc.lib}/lib64";
108 mkdir -p $out/bin $out/share/1password
109 cp -a * $out/share/1password
112 install -Dt $out/share/applications resources/${pname}.desktop
113 substituteInPlace $out/share/applications/${pname}.desktop \
114 --replace 'Exec=/opt/1Password/${pname}' 'Exec=${pname}'
117 + (lib.optionalString (polkitPolicyOwners != [ ]) ''
119 mkdir -p $out/share/polkit-1/actions
120 substitute com.1password.1Password.policy.tpl $out/share/polkit-1/actions/com.1password.1Password.policy --replace "\''${POLICY_OWNERS}" "${policyOwners}"
125 cp -a resources/icons $out/share
127 interp="$(cat $NIX_CC/nix-support/dynamic-linker)"
128 patchelf --set-interpreter $interp $out/share/1password/{1password,1Password-BrowserSupport,1Password-LastPass-Exporter,op-ssh-sign}
129 patchelf --set-rpath ${rpath}:$out/share/1password $out/share/1password/{1password,1Password-BrowserSupport,1Password-LastPass-Exporter,op-ssh-sign}
130 for file in $(find $out -type f -name \*.so\* ); do
131 patchelf --set-rpath ${rpath}:$out/share/1password $file
134 ln -s $out/share/1password/op-ssh-sign $out/bin/op-ssh-sign
140 # makeWrapper defaults to makeBinaryWrapper due to wrapGAppsHook
141 # but we need a shell wrapper specifically for `NIXOS_OZONE_WL`.
142 # Electron is trying to open udev via dlopen()
143 # and for some reason that doesn't seem to be impacted from the rpath.
144 # Adding udev to LD_LIBRARY_PATH fixes that.
145 # Make xdg-open overrideable at runtime.
146 makeShellWrapper $out/share/1password/1password $out/bin/1password \
147 "''${gappsWrapperArgs[@]}" \
148 --suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \
149 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ udev ]}
150 # Currently half broken on wayland (e.g. no copy functionality)
151 # See: https://github.com/NixOS/nixpkgs/pull/232718#issuecomment-1582123406
152 # Remove this comment when upstream fixes:
153 # https://1password.community/discussion/comment/624011/#Comment_624011
154 #--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"