teams-for-linux: 1.4.27 -> 1.9.5

This commit is contained in:
Austin Horstman 2024-08-27 21:54:55 -05:00
parent 8802c04d25
commit 3ff5f76c24
No known key found for this signature in database
2 changed files with 63 additions and 122 deletions

View File

@ -1,108 +1,104 @@
{
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,
versionCheckHook,
which,
testers,
teams-for-linux,
}:
stdenv.mkDerivation (finalAttrs: {
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
];
versionCheckHook
] ++ lib.optionals (stdenv.isLinux) [ copyDesktopItems ];
configurePhase = ''
runHook preConfigure
doInstallCheck = stdenv.isLinux;
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 ${electron_30.dist} 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}}"
--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
'';
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 +107,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;
};
})
}

View File

@ -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