1{ lib, stdenv, fetchurl, dpkg, buildFHSEnv
2, glibc, glib, openssl, tpm2-tss
3, gtk3, gnome, polkit, polkit_gnome
4}:
5
6let
7 pname = "beyond-identity";
8 version = "2.60.0-0";
9 libPath = lib.makeLibraryPath ([ glib glibc openssl tpm2-tss gtk3 gnome.gnome-keyring polkit polkit_gnome ]);
10 meta = with lib; {
11 description = "Passwordless MFA identities for workforces, customers, and developers";
12 homepage = "https://www.beyondidentity.com";
13 downloadPage = "https://app.byndid.com/downloads";
14 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
15 license = licenses.unfree;
16 maintainers = with maintainers; [ klden ];
17 platforms = [ "x86_64-linux" ];
18 };
19
20 beyond-identity = stdenv.mkDerivation {
21 inherit pname version meta;
22
23 src = fetchurl {
24 url = "https://packages.beyondidentity.com/public/linux-authenticator/deb/ubuntu/pool/focal/main/b/be/${pname}_${version}/${pname}_${version}_amd64.deb";
25 sha512 = "sha512-JrHLf7KkJVbJLxx54OTvOSaIzY3+hjX+bpkeBHKX23YriCJssUUvEP6vlbI4r6gjMMFMhW92k0iikAgD1Tr4ug==";
26 };
27
28 nativeBuildInputs = [
29 dpkg
30 ];
31
32 unpackPhase = ''
33 dpkg -x $src .
34 '';
35
36 installPhase = ''
37 mkdir -p $out/opt/beyond-identity
38
39 rm -rf usr/share/doc
40
41 # https://github.com/NixOS/nixpkgs/issues/42117
42 sed -i -e 's/auth_self/yes/g' usr/share/polkit-1/actions/com.beyondidentity.endpoint.stepup.policy
43
44 cp -ar usr/{bin,share} $out
45 cp -ar opt/beyond-identity/bin $out/opt/beyond-identity
46
47 ln -s $out/opt/beyond-identity/bin/* $out/bin/
48 '';
49
50 postFixup = ''
51 substituteInPlace \
52 $out/share/applications/com.beyondidentity.endpoint.BeyondIdentity.desktop \
53 --replace /usr/bin/ $out/bin/
54 substituteInPlace \
55 $out/share/applications/com.beyondidentity.endpoint.webserver.BeyondIdentity.desktop \
56 --replace /opt/ $out/opt/
57 substituteInPlace \
58 $out/opt/beyond-identity/bin/byndid-web \
59 --replace /opt/ $out/opt/
60 substituteInPlace \
61 $out/bin/beyond-identity \
62 --replace /opt/ $out/opt/ \
63 --replace /usr/bin/gtk-launch ${gtk3}/bin/gtk-launch
64
65 patchelf \
66 --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
67 --set-rpath "${libPath}" \
68 --force-rpath \
69 $out/bin/byndid
70 '';
71 };
72# /usr/bin/pkcheck is hardcoded in binary - we need FHS
73in buildFHSEnv {
74 inherit meta;
75 name = pname;
76
77 targetPkgs = pkgs: [
78 beyond-identity
79 glib glibc openssl tpm2-tss
80 gtk3 gnome.gnome-keyring
81 polkit polkit_gnome
82 ];
83
84 extraInstallCommands = ''
85 ln -s ${beyond-identity}/share $out
86 '';
87
88 runScript = "beyond-identity";
89}
90