about summary refs log tree commit diff
path: root/pkgs/applications/networking/instant-messengers/teams
diff options
context:
space:
mode:
authorOlli Helenius <liff@iki.fi>2021-06-26 17:31:30 +0300
committerOlli Helenius <liff@iki.fi>2021-06-26 17:31:30 +0300
commitcce2b65151ee844c3a0af0393742ba9c5bb73066 (patch)
treefb5cc5827af31dc74e46a1833eeeb532f033659c /pkgs/applications/networking/instant-messengers/teams
parentff5542ccef7f995fc99279478ce0b91d05987f1b (diff)
teams: fix absolute path usages
There are some references to absolute paths in the Teams application
code:

  * /usr/share/pixmaps - The application icon.
  * /usr/bin/xdg-mime - Uses absolute path to invoke.
  * /usr/bin/teams - Uses absolute path in the autostart file if
                     configured to start automatically at login.

Though the paths are hardcoded they can be easily changed within
the application’s main JavaScript code bundle and so we’ll do just
that.

This should at least fix auto-start not working, even when enabled.
Diffstat (limited to 'pkgs/applications/networking/instant-messengers/teams')
-rw-r--r--pkgs/applications/networking/instant-messengers/teams/default.nix21
1 files changed, 19 insertions, 2 deletions
diff --git a/pkgs/applications/networking/instant-messengers/teams/default.nix b/pkgs/applications/networking/instant-messengers/teams/default.nix
index ab6274cdf3465..1267340c0985f 100644
--- a/pkgs/applications/networking/instant-messengers/teams/default.nix
+++ b/pkgs/applications/networking/instant-messengers/teams/default.nix
@@ -13,6 +13,7 @@
 , gawk
 , xdg-utils
 , systemd
+, nodePackages
 , enableRectOverlay ? false }:
 
 stdenv.mkDerivation rec {
@@ -24,7 +25,7 @@ stdenv.mkDerivation rec {
     sha256 = "1kx4j837fd344zy90nl0j3r8cdvihy6i6gf56wd5n56zngx1fhjv";
   };
 
-  nativeBuildInputs = [ dpkg autoPatchelfHook wrapGAppsHook ];
+  nativeBuildInputs = [ dpkg autoPatchelfHook wrapGAppsHook nodePackages.asar ];
 
   unpackCmd = "dpkg -x $curSrc .";
 
@@ -40,11 +41,27 @@ stdenv.mkDerivation rec {
   ];
 
   preFixup = ''
-    gappsWrapperArgs+=(--prefix PATH : "${coreutils}/bin:${gawk}/bin:${xdg-utils}/bin")
+    gappsWrapperArgs+=(--prefix PATH : "${coreutils}/bin:${gawk}/bin")
     gappsWrapperArgs+=(--add-flags --disable-namespace-sandbox)
     gappsWrapperArgs+=(--add-flags --disable-setuid-sandbox)
   '';
 
+
+  buildPhase = ''
+    runHook preBuild
+
+    asar extract share/teams/resources/app.asar "$TMP/work"
+    substituteInPlace $TMP/work/main.bundle.js \
+        --replace "/usr/share/pixmaps/" "$out/share/pixmaps" \
+        --replace "/usr/bin/xdg-mime" "${xdg-utils}/bin/xdg-mime" \
+        --replace "Exec=/usr/bin/" "Exec=" # Remove usage of absolute path in autostart.
+    asar pack --unpack='{*.node,*.ftz,rect-overlay}' "$TMP/work" share/teams/resources/app.asar
+
+    runHook postBuild
+  '';
+
+  preferLocalBuild = true;
+
   installPhase = ''
     runHook preInstall