vuls: init at 0.27.0 (#348530)
[NixPkgs.git] / pkgs / by-name / mi / microsoft-identity-broker / package.nix
blob2866d38da4cdd28d689a18751fb9cd0e6b390a20
1 { stdenv
2 , lib
3 , fetchurl
4 , dpkg
5 , openjdk11
6 , jnr-posix
7 , makeWrapper
8 , openjfx17
9 , zip
10 , nixosTests
11 , bash
13 stdenv.mkDerivation rec {
14   pname = "microsoft-identity-broker";
15   version = "2.0.1";
17   src = fetchurl {
18     url = "https://packages.microsoft.com/ubuntu/22.04/prod/pool/main/m/microsoft-identity-broker/microsoft-identity-broker_${version}_amd64.deb";
19     hash = "sha256-O9zbImSWMrRsaOozj5PsCRvQ3UsaJzLfoTohmLZvLkM=";
20   };
22   nativeBuildInputs = [ dpkg makeWrapper openjdk11 zip ];
24   buildPhase = ''
25     runHook preBuild
27     rm opt/microsoft/identity-broker/lib/jnr-posix-3.1.4.jar
28     jar -uf opt/microsoft/identity-broker/lib/javafx-graphics-15-linux.jar -C ${openjfx17}/modules_libs/javafx.graphics/ libglass.so
29     jar -uf opt/microsoft/identity-broker/lib/javafx-graphics-15-linux.jar -C ${openjfx17}/modules_libs/javafx.graphics/ libglassgtk3.so
30     jar -uf opt/microsoft/identity-broker/lib/javafx-graphics-15-linux.jar -C ${openjfx17}/modules_libs/javafx.graphics/ libprism_es2.so
31     zip -d opt/microsoft/identity-broker/lib/javafx-media-15-linux.jar libavplugin-54.so
32     zip -d opt/microsoft/identity-broker/lib/javafx-media-15-linux.jar libavplugin-56.so
33     zip -d opt/microsoft/identity-broker/lib/javafx-media-15-linux.jar libavplugin-57.so
34     zip -d opt/microsoft/identity-broker/lib/javafx-media-15-linux.jar libavplugin-ffmpeg-56.so
35     zip -d opt/microsoft/identity-broker/lib/javafx-media-15-linux.jar libavplugin-ffmpeg-57.so
36     zip -d opt/microsoft/identity-broker/lib/javafx-media-15-linux.jar libavplugin-ffmpeg-58.so
37     jar -uf opt/microsoft/identity-broker/lib/javafx-media-15-linux.jar -C ${openjfx17}/modules_libs/javafx.media/ libavplugin.so
38     jar -uf opt/microsoft/identity-broker/lib/javafx-media-15-linux.jar -C ${openjfx17}/modules_libs/javafx.media/ libfxplugins.so
39     jar -uf opt/microsoft/identity-broker/lib/javafx-media-15-linux.jar -C ${openjfx17}/modules_libs/javafx.media/ libgstreamer-lite.so
40     jar -uf opt/microsoft/identity-broker/lib/javafx-media-15-linux.jar -C ${openjfx17}/modules_libs/javafx.media/ libjfxmedia.so
42     runHook postBuild
43   '';
45   installPhase = ''
46     runHook preInstall
48     mkdir -p $out/lib/microsoft-identity-broker
49     cp -a opt/microsoft/identity-broker/lib/* $out/lib/microsoft-identity-broker
50     cp -a usr/* $out
51     for jar in $out/lib/microsoft-identity-broker/*.jar; do
52       classpath="$classpath:$jar"
53     done
54     classpath="$classpath:${jnr-posix}/share/java/jnr-posix-${jnr-posix.version}.jar"
55     mkdir -p $out/bin
56     makeWrapper ${openjdk11}/bin/java $out/bin/microsoft-identity-broker \
57       --add-flags "-classpath $classpath com.microsoft.identity.broker.service.IdentityBrokerService" \
58       --add-flags "-verbose"
59     makeWrapper ${openjdk11}/bin/java $out/bin/microsoft-identity-device-broker \
60       --add-flags "-verbose" \
61       --add-flags "-classpath $classpath" \
62       --add-flags "com.microsoft.identity.broker.service.DeviceBrokerService" \
63       --add-flags "save"
65     runHook postInstall
66   '';
68   postInstall = ''
69     substituteInPlace \
70       $out/lib/systemd/user/microsoft-identity-broker.service \
71       $out/lib/systemd/system/microsoft-identity-device-broker.service \
72       $out/share/dbus-1/system-services/com.microsoft.identity.devicebroker1.service \
73       $out/share/dbus-1/services/com.microsoft.identity.broker1.service \
74       --replace \
75         ExecStartPre=sh \
76         ExecStartPre=${bash}/bin/sh \
77       --replace \
78         ExecStartPre=!sh \
79         ExecStartPre=!${bash}/bin/sh \
80       --replace \
81         /opt/microsoft/identity-broker/bin/microsoft-identity-broker \
82         $out/bin/microsoft-identity-broker \
83       --replace \
84         /opt/microsoft/identity-broker/bin/microsoft-identity-device-broker \
85         $out/bin/microsoft-identity-device-broker \
86       --replace \
87         /usr/lib/jvm/java-11-openjdk-amd64 \
88         ${openjdk11}/bin/java
89   '';
91   passthru = {
92     updateScript = ./update.sh;
93     tests = { inherit (nixosTests) intune; };
94   };
96   meta = with lib; {
97     description = "Microsoft Authentication Broker for Linux";
98     homepage = "https://www.microsoft.com/";
99     license = licenses.unfree;
100     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
101     platforms = [ "x86_64-linux" ];
102     maintainers = with lib.maintainers; [ rhysmdnz ];
103   };