Merge pull request #308993 from eclairevoyant/webcord-update-script

webcord{,-vencord}: move to pkgs/by-name, format with nixfmt, fixes for update scripts
This commit is contained in:
éclairevoyant 2024-05-06 06:14:50 +00:00 committed by GitHub
commit f706330741
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 62 additions and 36 deletions

View File

@ -1,9 +1,11 @@
{ webcord
, substituteAll
, lib
, vencord-web-extension
{
webcord,
substituteAll,
lib,
vencord-web-extension,
}:
# nixpkgs-update: no auto update
webcord.overrideAttrs (old: {
pname = "webcord-vencord";
@ -14,8 +16,13 @@ webcord.overrideAttrs (old: {
})
];
meta = with lib; old.meta // {
meta = {
inherit (old.meta) license mainProgram platforms;
description = "Webcord with Vencord web extension";
maintainers = with maintainers; [ FlafyDev NotAShelf ];
maintainers = with lib.maintainers; [
FlafyDev
NotAShelf
];
};
})

View File

@ -1,12 +1,12 @@
{ lib
, buildNpmPackage
, fetchFromGitHub
, copyDesktopItems
, python3
, xdg-utils
, electron_29
, makeDesktopItem
, nix-update-script
{
lib,
buildNpmPackage,
fetchFromGitHub,
copyDesktopItems,
python3,
xdg-utils,
electron,
makeDesktopItem,
}:
buildNpmPackage rec {
@ -16,7 +16,7 @@ buildNpmPackage rec {
src = fetchFromGitHub {
owner = "SpacingBat3";
repo = "WebCord";
rev = "v${version}";
rev = "refs/tags/v${version}";
hash = "sha256-x9Ejb8yxgQhlEfUUfoqbgSffNNtOoFeAyb3OISR+Jz4=";
};
@ -41,25 +41,25 @@ buildNpmPackage rec {
let
binPath = lib.makeBinPath [ xdg-utils ];
in
''
runHook preInstall
''
runHook preInstall
# Remove dev deps that aren't necessary for running the app
npm prune --omit=dev
# Remove dev deps that aren't necessary for running the app
npm prune --omit=dev
mkdir -p $out/lib/node_modules/webcord
cp -r app node_modules sources package.json $out/lib/node_modules/webcord/
mkdir -p $out/lib/node_modules/webcord
cp -r app node_modules sources package.json $out/lib/node_modules/webcord/
install -Dm644 sources/assets/icons/app.png $out/share/icons/hicolor/256x256/apps/webcord.png
install -Dm644 sources/assets/icons/app.png $out/share/icons/hicolor/256x256/apps/webcord.png
# Add xdg-utils to path via suffix, per PR #181171
makeWrapper '${lib.getExe electron_29}' $out/bin/webcord \
--suffix PATH : "${binPath}" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
--add-flags $out/lib/node_modules/webcord/
# Add xdg-utils to path via suffix, per PR #181171
makeWrapper '${lib.getExe electron}' $out/bin/webcord \
--suffix PATH : "${binPath}" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
--add-flags $out/lib/node_modules/webcord/
runHook postInstall
'';
runHook postInstall
'';
desktopItems = [
(makeDesktopItem {
@ -68,11 +68,14 @@ buildNpmPackage rec {
icon = "webcord";
desktopName = "WebCord";
comment = meta.description;
categories = [ "Network" "InstantMessaging" ];
categories = [
"Network"
"InstantMessaging"
];
})
];
passthru.updateScript = nix-update-script { };
passthru.updateScript = ./update.sh;
meta = {
description = "A Discord and SpaceBar electron-based client implemented without Discord API";
@ -81,7 +84,10 @@ buildNpmPackage rec {
changelog = "https://github.com/SpacingBat3/WebCord/releases/tag/v${version}";
license = lib.licenses.mit;
mainProgram = "webcord";
maintainers = with lib.maintainers; [ eclairevoyant huantian ];
maintainers = with lib.maintainers; [
eclairevoyant
huantian
];
platforms = lib.platforms.linux;
};
}

View File

@ -0,0 +1,15 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p curl jq nix-update
set -ex
curl_github() {
curl -L ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} "$@"
}
latestTag=$(curl_github https://api.github.com/repos/SpacingBat3/Webcord/releases/latest | jq -r ".tag_name")
latestVersion="$(expr "$latestTag" : 'v\(.*\)')"
nix-update --version "$latestVersion" webcord
electronVersion=$(curl_github "https://raw.githubusercontent.com/SpacingBat3/WebCord/v$latestVersion/package.json" | jq -r ".devDependencies.electron" | sed -r 's|^\^([0-9]+).*|\1|')
sed -r "/webcord = / s|(electron_)[0-9]+|\1$electronVersion|" -i pkgs/top-level/all-packages.nix

View File

@ -35576,9 +35576,7 @@ with pkgs;
webcamoid = libsForQt5.callPackage ../applications/video/webcamoid { };
webcord = callPackage ../applications/networking/instant-messengers/webcord { };
webcord-vencord = callPackage ../applications/networking/instant-messengers/webcord/webcord-vencord { };
webcord = callPackage ../by-name/we/webcord/package.nix { electron = electron_29; };
webex = callPackage ../applications/networking/instant-messengers/webex { };