|
| 1 | +{ |
| 2 | + pname, |
| 3 | + version, |
| 4 | + src, |
| 5 | + passthru, |
| 6 | + meta, |
| 7 | + |
| 8 | + lib, |
| 9 | + stdenv, |
| 10 | + dpkg, |
| 11 | + makeWrapper, |
| 12 | + asar, |
| 13 | + alsa-lib, |
| 14 | + at-spi2-atk, |
| 15 | + at-spi2-core, |
| 16 | + atk, |
| 17 | + cairo, |
| 18 | + cups, |
| 19 | + curl, |
| 20 | + dbus, |
| 21 | + expat, |
| 22 | + fontconfig, |
| 23 | + freetype, |
| 24 | + gdk-pixbuf, |
| 25 | + glib, |
| 26 | + gtk3, |
| 27 | + libGL, |
| 28 | + libappindicator-gtk3, |
| 29 | + libdrm, |
| 30 | + libnotify, |
| 31 | + libpulseaudio, |
| 32 | + libuuid, |
| 33 | + libxcb, |
| 34 | + libxkbcommon, |
| 35 | + libgbm, |
| 36 | + nspr, |
| 37 | + nss, |
| 38 | + pango, |
| 39 | + pipewire, |
| 40 | + systemd, |
| 41 | + wayland, |
| 42 | + xdg-utils, |
| 43 | + xorg, |
| 44 | +}: |
| 45 | +stdenv.mkDerivation rec { |
| 46 | + inherit |
| 47 | + pname |
| 48 | + version |
| 49 | + src |
| 50 | + passthru |
| 51 | + meta |
| 52 | + ; |
| 53 | + |
| 54 | + rpath = |
| 55 | + lib.makeLibraryPath [ |
| 56 | + alsa-lib |
| 57 | + at-spi2-atk |
| 58 | + at-spi2-core |
| 59 | + atk |
| 60 | + cairo |
| 61 | + cups |
| 62 | + curl |
| 63 | + dbus |
| 64 | + expat |
| 65 | + fontconfig |
| 66 | + freetype |
| 67 | + gdk-pixbuf |
| 68 | + glib |
| 69 | + gtk3 |
| 70 | + libGL |
| 71 | + libappindicator-gtk3 |
| 72 | + libdrm |
| 73 | + libnotify |
| 74 | + libpulseaudio |
| 75 | + libuuid |
| 76 | + libxcb |
| 77 | + libxkbcommon |
| 78 | + libgbm |
| 79 | + nspr |
| 80 | + nss |
| 81 | + pango |
| 82 | + pipewire |
| 83 | + stdenv.cc.cc |
| 84 | + systemd |
| 85 | + wayland |
| 86 | + xorg.libX11 |
| 87 | + xorg.libXScrnSaver |
| 88 | + xorg.libXcomposite |
| 89 | + xorg.libXcursor |
| 90 | + xorg.libXdamage |
| 91 | + xorg.libXext |
| 92 | + xorg.libXfixes |
| 93 | + xorg.libXi |
| 94 | + xorg.libXrandr |
| 95 | + xorg.libXrender |
| 96 | + xorg.libXtst |
| 97 | + xorg.libxkbfile |
| 98 | + xorg.libxshmfence |
| 99 | + ] |
| 100 | + + ":${lib.getLib stdenv.cc.cc}/lib64"; |
| 101 | + |
| 102 | + buildInputs = [ |
| 103 | + gtk3 # needed for GSETTINGS_SCHEMAS_PATH |
| 104 | + ]; |
| 105 | + |
| 106 | + nativeBuildInputs = [ |
| 107 | + dpkg |
| 108 | + makeWrapper |
| 109 | + asar |
| 110 | + ]; |
| 111 | + |
| 112 | + dontUnpack = true; |
| 113 | + dontBuild = true; |
| 114 | + dontPatchELF = true; |
| 115 | + |
| 116 | + installPhase = '' |
| 117 | + runHook preInstall |
| 118 | +
|
| 119 | + # The deb file contains a setuid binary, so 'dpkg -x' doesn't work here |
| 120 | + dpkg --fsys-tarfile $src | tar --extract |
| 121 | + rm -rf usr/share/lintian |
| 122 | +
|
| 123 | + mkdir -p $out |
| 124 | + mv usr/* $out |
| 125 | +
|
| 126 | + # Otherwise it looks "suspicious" |
| 127 | + chmod -R g-w $out |
| 128 | +
|
| 129 | + for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do |
| 130 | + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true |
| 131 | + patchelf --set-rpath ${rpath}:$out/lib/slack $file || true |
| 132 | + done |
| 133 | +
|
| 134 | + # Replace the broken bin/slack symlink with a startup wrapper. |
| 135 | + # Make xdg-open overrideable at runtime. |
| 136 | + rm $out/bin/slack |
| 137 | + makeWrapper $out/lib/slack/slack $out/bin/slack \ |
| 138 | + --prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \ |
| 139 | + --suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \ |
| 140 | + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations,WebRTCPipeWireCapturer --enable-wayland-ime=true}}" |
| 141 | +
|
| 142 | + # Fix the desktop link |
| 143 | + substituteInPlace $out/share/applications/slack.desktop \ |
| 144 | + --replace /usr/bin/ $out/bin/ \ |
| 145 | + --replace /usr/share/pixmaps/slack.png slack \ |
| 146 | + --replace bin/slack "bin/slack -s" |
| 147 | +
|
| 148 | + # Prevent Un-blacklist pipewire integration to enable screen sharing on wayland. |
| 149 | + # https://github.com/flathub/com.slack.Slack/issues/101#issuecomment-1807073763 |
| 150 | + sed -i -e 's/,"WebRTCPipeWireCapturer"/,"LebRTCPipeWireCapturer"/' $out/lib/slack/resources/app.asar |
| 151 | +
|
| 152 | + runHook postInstall |
| 153 | + ''; |
| 154 | +} |
0 commit comments