From 40d73c784cb38c94da6f5324fe83a69168aeaa66 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 27 Aug 2024 21:46:27 -0500 Subject: [PATCH 1/4] teams-for-linux: fmt --- .../teams-for-linux/default.nix | 84 ++++++++++++------- 1 file changed, 55 insertions(+), 29 deletions(-) diff --git a/pkgs/applications/networking/instant-messengers/teams-for-linux/default.nix b/pkgs/applications/networking/instant-messengers/teams-for-linux/default.nix index f59b9c3774bc6..4da418eb9d1fe 100644 --- a/pkgs/applications/networking/instant-messengers/teams-for-linux/default.nix +++ b/pkgs/applications/networking/instant-messengers/teams-for-linux/default.nix @@ -1,18 +1,19 @@ -{ lib -, stdenv -, fetchFromGitHub -, makeWrapper -, makeDesktopItem -, copyDesktopItems -, yarn -, nodejs -, fetchYarnDeps -, fixup-yarn-lock -, electron -, alsa-utils -, which -, testers -, teams-for-linux +{ + lib, + stdenv, + fetchFromGitHub, + makeWrapper, + makeDesktopItem, + copyDesktopItems, + yarn, + nodejs, + fetchYarnDeps, + fixup-yarn-lock, + electron, + alsa-utils, + which, + testers, + teams-for-linux, }: stdenv.mkDerivation (finalAttrs: { @@ -31,7 +32,13 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-jBwyIyiWeqNmOnxmVOr7c4oMWwHElEjM25sShhTMi78="; }; - nativeBuildInputs = [ yarn fixup-yarn-lock nodejs copyDesktopItems makeWrapper ]; + nativeBuildInputs = [ + yarn + fixup-yarn-lock + nodejs + copyDesktopItems + makeWrapper + ]; configurePhase = '' runHook preConfigure @@ -49,8 +56,10 @@ stdenv.mkDerivation (finalAttrs: { runHook preBuild yarn --offline electron-builder \ - --dir ${if stdenv.isDarwin then "--macos" else "--linux"} ${if stdenv.hostPlatform.isAarch64 then "--arm64" else "--x64"} \ - -c.electronDist=${electron}/libexec/electron \ + --dir ${if stdenv.isDarwin then "--macos" else "--linux"} ${ + if stdenv.hostPlatform.isAarch64 then "--arm64" else "--x64" + } \ + -c.electronDist=${electron.dist} \ -c.electronVersion=${electron.version} runHook postBuild @@ -60,7 +69,9 @@ stdenv.mkDerivation (finalAttrs: { runHook preInstall mkdir -p $out/share/{applications,teams-for-linux} - cp dist/${if stdenv.isDarwin then "darwin-" else "linux-"}${lib.optionalString stdenv.hostPlatform.isAarch64 "arm64-"}unpacked/resources/app.asar $out/share/teams-for-linux/ + cp dist/${ + if stdenv.isDarwin then "darwin-" else "linux-" + }${lib.optionalString stdenv.hostPlatform.isAarch64 "arm64-"}unpacked/resources/app.asar $out/share/teams-for-linux/ pushd build/icons for image in *png; do @@ -72,7 +83,12 @@ stdenv.mkDerivation (finalAttrs: { # Linux needs 'aplay' for notification sounds makeWrapper '${electron}/bin/electron' "$out/bin/teams-for-linux" \ ${lib.optionalString stdenv.isLinux '' - --prefix PATH : ${lib.makeBinPath [ alsa-utils which ]} \ + --prefix PATH : ${ + lib.makeBinPath [ + alsa-utils + which + ] + } \ ''} \ --add-flags "$out/share/teams-for-linux/app.asar" \ --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" @@ -80,14 +96,20 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstall ''; - desktopItems = [(makeDesktopItem { - name = finalAttrs.pname; - exec = finalAttrs.pname; - icon = finalAttrs.pname; - desktopName = "Microsoft Teams for Linux"; - comment = finalAttrs.meta.description; - categories = [ "Network" "InstantMessaging" "Chat" ]; - })]; + desktopItems = [ + (makeDesktopItem { + name = finalAttrs.pname; + exec = finalAttrs.pname; + icon = finalAttrs.pname; + desktopName = "Microsoft Teams for Linux"; + comment = finalAttrs.meta.description; + categories = [ + "Network" + "InstantMessaging" + "Chat" + ]; + }) + ]; passthru.updateScript = ./update.sh; passthru.tests.version = testers.testVersion rec { @@ -100,7 +122,11 @@ stdenv.mkDerivation (finalAttrs: { mainProgram = "teams-for-linux"; homepage = "https://github.com/IsmaelMartinez/teams-for-linux"; license = lib.licenses.gpl3Only; - maintainers = with lib.maintainers; [ muscaln lilyinstarlight qjoly chvp ]; + maintainers = with lib.maintainers; [ + muscaln + qjoly + chvp + ]; platforms = lib.platforms.unix; broken = stdenv.isDarwin; }; From 1075a62a0356802d3bfd39d5165fb578de1846d4 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 27 Aug 2024 21:48:44 -0500 Subject: [PATCH 2/4] teams-for-linux: move to by-name --- .../te/teams-for-linux/package.nix} | 8 ++++---- .../te}/teams-for-linux/update.sh | 0 pkgs/top-level/all-packages.nix | 4 ---- 3 files changed, 4 insertions(+), 8 deletions(-) rename pkgs/{applications/networking/instant-messengers/teams-for-linux/default.nix => by-name/te/teams-for-linux/package.nix} (94%) rename pkgs/{applications/networking/instant-messengers => by-name/te}/teams-for-linux/update.sh (100%) diff --git a/pkgs/applications/networking/instant-messengers/teams-for-linux/default.nix b/pkgs/by-name/te/teams-for-linux/package.nix similarity index 94% rename from pkgs/applications/networking/instant-messengers/teams-for-linux/default.nix rename to pkgs/by-name/te/teams-for-linux/package.nix index 4da418eb9d1fe..792b25b115626 100644 --- a/pkgs/applications/networking/instant-messengers/teams-for-linux/default.nix +++ b/pkgs/by-name/te/teams-for-linux/package.nix @@ -9,7 +9,7 @@ nodejs, fetchYarnDeps, fixup-yarn-lock, - electron, + electron_29, alsa-utils, which, testers, @@ -59,8 +59,8 @@ stdenv.mkDerivation (finalAttrs: { --dir ${if stdenv.isDarwin then "--macos" else "--linux"} ${ if stdenv.hostPlatform.isAarch64 then "--arm64" else "--x64" } \ - -c.electronDist=${electron.dist} \ - -c.electronVersion=${electron.version} + -c.electronDist=${electron_29.dist} \ + -c.electronVersion=${electron_29.version} runHook postBuild ''; @@ -81,7 +81,7 @@ stdenv.mkDerivation (finalAttrs: { popd # Linux needs 'aplay' for notification sounds - makeWrapper '${electron}/bin/electron' "$out/bin/teams-for-linux" \ + makeWrapper '${electron_29}/bin/electron' "$out/bin/teams-for-linux" \ ${lib.optionalString stdenv.isLinux '' --prefix PATH : ${ lib.makeBinPath [ diff --git a/pkgs/applications/networking/instant-messengers/teams-for-linux/update.sh b/pkgs/by-name/te/teams-for-linux/update.sh similarity index 100% rename from pkgs/applications/networking/instant-messengers/teams-for-linux/update.sh rename to pkgs/by-name/te/teams-for-linux/update.sh diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8069364dc4563..dccff2b34ddd9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -34633,10 +34633,6 @@ with pkgs; teams = callPackage ../applications/networking/instant-messengers/teams { }; - teams-for-linux = callPackage ../applications/networking/instant-messengers/teams-for-linux { - electron = electron_29; - }; - teamspeak_client = libsForQt5.callPackage ../applications/networking/instant-messengers/teamspeak/client.nix { }; teamspeak5_client = callPackage ../applications/networking/instant-messengers/teamspeak/client5.nix { }; teamspeak_server = callPackage ../applications/networking/instant-messengers/teamspeak/server.nix { }; From 889ce5b2c82e72ab1d720076295a343fa345d3dc Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 27 Aug 2024 23:34:37 -0500 Subject: [PATCH 3/4] teams-for-linux: add khaneliman maintainer --- pkgs/by-name/te/teams-for-linux/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/te/teams-for-linux/package.nix b/pkgs/by-name/te/teams-for-linux/package.nix index 792b25b115626..4bff55c0e3bd4 100644 --- a/pkgs/by-name/te/teams-for-linux/package.nix +++ b/pkgs/by-name/te/teams-for-linux/package.nix @@ -126,6 +126,7 @@ stdenv.mkDerivation (finalAttrs: { muscaln qjoly chvp + khaneliman ]; platforms = lib.platforms.unix; broken = stdenv.isDarwin; From 261db25a2d554b915ec107b0161b9467de1d675c Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 27 Aug 2024 21:54:55 -0500 Subject: [PATCH 4/4] teams-for-linux: 1.4.27 -> 1.9.5 --- pkgs/by-name/te/teams-for-linux/package.nix | 138 +++++++++----------- pkgs/by-name/te/teams-for-linux/update.sh | 50 ------- 2 files changed, 64 insertions(+), 124 deletions(-) delete mode 100755 pkgs/by-name/te/teams-for-linux/update.sh diff --git a/pkgs/by-name/te/teams-for-linux/package.nix b/pkgs/by-name/te/teams-for-linux/package.nix index 4bff55c0e3bd4..1abff281edb95 100644 --- a/pkgs/by-name/te/teams-for-linux/package.nix +++ b/pkgs/by-name/te/teams-for-linux/package.nix @@ -1,108 +1,103 @@ { lib, stdenv, + buildNpmPackage, fetchFromGitHub, - makeWrapper, - makeDesktopItem, - copyDesktopItems, - yarn, - nodejs, - fetchYarnDeps, - fixup-yarn-lock, - electron_29, alsa-utils, + copyDesktopItems, + electron_30, + makeDesktopItem, + makeWrapper, + nix-update-script, which, - testers, - teams-for-linux, }: -stdenv.mkDerivation (finalAttrs: { +let + electronDist = "${electron_30}/${if stdenv.isDarwin then "Applications" else "libexec/electron"}"; +in +buildNpmPackage rec { pname = "teams-for-linux"; - version = "1.4.27"; + version = "1.9.5"; src = fetchFromGitHub { owner = "IsmaelMartinez"; repo = "teams-for-linux"; - rev = "v${finalAttrs.version}"; - hash = "sha256-nUHiveS1XI+vC2Tj1DK/DS4CrKTLMg1IYgTPWXuLrAc="; + rev = "refs/tags/v${version}"; + hash = "sha256-+rEGDg+/qvjCMhGHccb4p+CKOo/65RpkFT/WnCDlCgU="; }; - offlineCache = fetchYarnDeps { - yarnLock = "${finalAttrs.src}/yarn.lock"; - hash = "sha256-jBwyIyiWeqNmOnxmVOr7c4oMWwHElEjM25sShhTMi78="; - }; + npmDepsHash = "sha256-vDRFFxkIQo5qU9gmkSwUhPz4FG2XbUNkTw6SCuvMqCc="; nativeBuildInputs = [ - yarn - fixup-yarn-lock - nodejs - copyDesktopItems makeWrapper - ]; + ] ++ lib.optionals (stdenv.isLinux) [ copyDesktopItems ]; - configurePhase = '' - runHook preConfigure - - export HOME=$(mktemp -d) - yarn config --offline set yarn-offline-mirror $offlineCache - fixup-yarn-lock yarn.lock - yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive - patchShebangs node_modules/ - - runHook postConfigure - ''; + env = { + # disable code signing on Darwin + CSC_IDENTITY_AUTO_DISCOVERY = "false"; + ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; + }; buildPhase = '' runHook preBuild - yarn --offline electron-builder \ - --dir ${if stdenv.isDarwin then "--macos" else "--linux"} ${ - if stdenv.hostPlatform.isAarch64 then "--arm64" else "--x64" - } \ - -c.electronDist=${electron_29.dist} \ - -c.electronVersion=${electron_29.version} + cp -r ${electronDist} electron-dist + chmod -R u+w electron-dist + + npm exec electron-builder -- \ + --dir \ + -c.npmRebuild=true \ + -c.asarUnpack="**/*.node" \ + -c.electronDist=electron-dist \ + -c.electronVersion=${electron_30.version} runHook postBuild ''; - installPhase = '' - runHook preInstall + installPhase = + '' + runHook preInstall - mkdir -p $out/share/{applications,teams-for-linux} - cp dist/${ - if stdenv.isDarwin then "darwin-" else "linux-" - }${lib.optionalString stdenv.hostPlatform.isAarch64 "arm64-"}unpacked/resources/app.asar $out/share/teams-for-linux/ + '' + + lib.optionalString stdenv.isLinux '' + mkdir -p $out/share/{applications,teams-for-linux} + cp dist/*-unpacked/resources/app.asar $out/share/teams-for-linux/ - pushd build/icons - for image in *png; do - mkdir -p $out/share/icons/hicolor/''${image%.png}/apps - cp -r $image $out/share/icons/hicolor/''${image%.png}/apps/teams-for-linux.png - done - popd + pushd build/icons + for image in *png; do + mkdir -p $out/share/icons/hicolor/''${image%.png}/apps + cp -r $image $out/share/icons/hicolor/''${image%.png}/apps/teams-for-linux.png + done + popd - # Linux needs 'aplay' for notification sounds - makeWrapper '${electron_29}/bin/electron' "$out/bin/teams-for-linux" \ - ${lib.optionalString stdenv.isLinux '' + # Linux needs 'aplay' for notification sounds + makeWrapper '${lib.getExe electron_30}' "$out/bin/teams-for-linux" \ --prefix PATH : ${ lib.makeBinPath [ alsa-utils which ] } \ - ''} \ - --add-flags "$out/share/teams-for-linux/app.asar" \ - --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" - - runHook postInstall - ''; + --add-flags "$out/share/teams-for-linux/app.asar" \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" + '' + + lib.optionalString stdenv.isDarwin '' + mkdir -p $out/Applications + cp -r dist/mac*/teams-for-linux.app $out/Applications + makeWrapper $out/Applications/teams-for-linux.app/Contents/MacOS/teams-for-linux $out/bin/teams-for-linux + '' + + '' + + runHook postInstall + ''; desktopItems = [ (makeDesktopItem { - name = finalAttrs.pname; - exec = finalAttrs.pname; - icon = finalAttrs.pname; + name = "teams-for-linux"; + exec = "teams-for-linux"; + icon = "teams-for-linux"; desktopName = "Microsoft Teams for Linux"; - comment = finalAttrs.meta.description; + comment = meta.description; categories = [ "Network" "InstantMessaging" @@ -111,24 +106,19 @@ stdenv.mkDerivation (finalAttrs: { }) ]; - passthru.updateScript = ./update.sh; - passthru.tests.version = testers.testVersion rec { - package = teams-for-linux; - command = "HOME=$TMPDIR ${package.meta.mainProgram or package.pname} --version"; - }; + passthru.updateScript = nix-update-script { }; meta = { description = "Unofficial Microsoft Teams client for Linux"; mainProgram = "teams-for-linux"; homepage = "https://github.com/IsmaelMartinez/teams-for-linux"; - license = lib.licenses.gpl3Only; + license = lib.licenses.gpl3Plus; maintainers = with lib.maintainers; [ muscaln qjoly chvp khaneliman ]; - platforms = lib.platforms.unix; - broken = stdenv.isDarwin; + platforms = with lib.platforms; darwin ++ linux; }; -}) +} diff --git a/pkgs/by-name/te/teams-for-linux/update.sh b/pkgs/by-name/te/teams-for-linux/update.sh deleted file mode 100755 index 650edf188611f..0000000000000 --- a/pkgs/by-name/te/teams-for-linux/update.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p nix jq common-updater-scripts - -set -euo pipefail - -nixpkgs="$(git rev-parse --show-toplevel || (printf 'Could not find root of nixpkgs repo\nAre we running from within the nixpkgs git repo?\n' >&2; exit 1))" - -stripwhitespace() { - sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -} - -nixeval() { - nix --extra-experimental-features nix-command eval --json --impure -f "$nixpkgs" "$1" | jq -r . -} - -vendorhash() { - (nix --extra-experimental-features nix-command build --impure --argstr nixpkgs "$nixpkgs" --argstr attr "$1" --expr '{ nixpkgs, attr }: let pkgs = import nixpkgs {}; in with pkgs.lib; (getAttrFromPath (splitString "." attr) pkgs).overrideAttrs (attrs: { outputHash = fakeHash; })' --no-link 2>&1 >/dev/null | tail -n3 | grep -F got: | cut -d: -f2- | stripwhitespace) 2>/dev/null || true -} - -findpath() { - path="$(nix --extra-experimental-features nix-command eval --json --impure -f "$nixpkgs" "$1.meta.position" | jq -r . | cut -d: -f1)" - outpath="$(nix --extra-experimental-features nix-command eval --json --impure --expr "builtins.fetchGit \"$nixpkgs\"")" - - if [ -n "$outpath" ]; then - path="${path/$(echo "$outpath" | jq -r .)/$nixpkgs}" - fi - - echo "$path" -} - -attr="${UPDATE_NIX_ATTR_PATH:-teams-for-linux}" -version="$(cd "$nixpkgs" && list-git-tags --pname="$(nixeval "$attr".pname)" --attr-path="$attr" | grep '^v' | sed -e 's|^v||' | sort -V | tail -n1)" - -pkgpath="$(findpath "$attr")" - -updated="$(cd "$nixpkgs" && update-source-version "$attr" "$version" --file="$pkgpath" --print-changes | jq -r length)" - -if [ "$updated" -eq 0 ]; then - echo 'update.sh: Package version not updated, nothing to do.' - exit 0 -fi - -curhash="$(nixeval "$attr.offlineCache.outputHash")" -newhash="$(vendorhash "$attr.offlineCache")" - -if [ -n "$newhash" ] && [ "$curhash" != "$newhash" ]; then - sed -i -e "s|\"$curhash\"|\"$newhash\"|" "$pkgpath" -else - echo 'update.sh: New vendorHash same as old vendorHash, nothing to do.' -fi