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

webcord{,-vencord}: move to pkgs/by-name, format with nixfmt, fixes for update scripts

authored by éclairevoyant and committed by GitHub f7063307 dd4070b4

+137 -111
-87
pkgs/applications/networking/instant-messengers/webcord/default.nix
··· 1 - { lib 2 - , buildNpmPackage 3 - , fetchFromGitHub 4 - , copyDesktopItems 5 - , python3 6 - , xdg-utils 7 - , electron_29 8 - , makeDesktopItem 9 - , nix-update-script 10 - }: 11 - 12 - buildNpmPackage rec { 13 - pname = "webcord"; 14 - version = "4.8.0"; 15 - 16 - src = fetchFromGitHub { 17 - owner = "SpacingBat3"; 18 - repo = "WebCord"; 19 - rev = "v${version}"; 20 - hash = "sha256-x9Ejb8yxgQhlEfUUfoqbgSffNNtOoFeAyb3OISR+Jz4="; 21 - }; 22 - 23 - npmDepsHash = "sha256-7H4I4vKygMgsPh+OvZZGhpkoQQu1a51yUTwEPJSBM18="; 24 - 25 - nativeBuildInputs = [ 26 - copyDesktopItems 27 - python3 28 - ]; 29 - 30 - # npm install will error when electron tries to download its binary 31 - # we don't need it anyways since we wrap the program with our nixpkgs electron 32 - env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; 33 - 34 - # remove husky commit hooks, errors and aren't needed for packaging 35 - postPatch = '' 36 - rm -rf .husky 37 - ''; 38 - 39 - # override installPhase so we can copy the only folders that matter 40 - installPhase = 41 - let 42 - binPath = lib.makeBinPath [ xdg-utils ]; 43 - in 44 - '' 45 - runHook preInstall 46 - 47 - # Remove dev deps that aren't necessary for running the app 48 - npm prune --omit=dev 49 - 50 - mkdir -p $out/lib/node_modules/webcord 51 - cp -r app node_modules sources package.json $out/lib/node_modules/webcord/ 52 - 53 - install -Dm644 sources/assets/icons/app.png $out/share/icons/hicolor/256x256/apps/webcord.png 54 - 55 - # Add xdg-utils to path via suffix, per PR #181171 56 - makeWrapper '${lib.getExe electron_29}' $out/bin/webcord \ 57 - --suffix PATH : "${binPath}" \ 58 - --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ 59 - --add-flags $out/lib/node_modules/webcord/ 60 - 61 - runHook postInstall 62 - ''; 63 - 64 - desktopItems = [ 65 - (makeDesktopItem { 66 - name = "webcord"; 67 - exec = "webcord"; 68 - icon = "webcord"; 69 - desktopName = "WebCord"; 70 - comment = meta.description; 71 - categories = [ "Network" "InstantMessaging" ]; 72 - }) 73 - ]; 74 - 75 - passthru.updateScript = nix-update-script { }; 76 - 77 - meta = { 78 - description = "A Discord and SpaceBar electron-based client implemented without Discord API"; 79 - homepage = "https://github.com/SpacingBat3/WebCord"; 80 - downloadPage = "https://github.com/SpacingBat3/WebCord/releases"; 81 - changelog = "https://github.com/SpacingBat3/WebCord/releases/tag/v${version}"; 82 - license = lib.licenses.mit; 83 - mainProgram = "webcord"; 84 - maintainers = with lib.maintainers; [ eclairevoyant huantian ]; 85 - platforms = lib.platforms.linux; 86 - }; 87 - }
pkgs/applications/networking/instant-messengers/webcord/webcord-vencord/add-extension.patch pkgs/by-name/we/webcord-vencord/add-extension.patch
-21
pkgs/applications/networking/instant-messengers/webcord/webcord-vencord/default.nix
··· 1 - { webcord 2 - , substituteAll 3 - , lib 4 - , vencord-web-extension 5 - }: 6 - 7 - webcord.overrideAttrs (old: { 8 - pname = "webcord-vencord"; 9 - 10 - patches = (old.patches or [ ]) ++ [ 11 - (substituteAll { 12 - src = ./add-extension.patch; 13 - vencord = vencord-web-extension; 14 - }) 15 - ]; 16 - 17 - meta = with lib; old.meta // { 18 - description = "Webcord with Vencord web extension"; 19 - maintainers = with maintainers; [ FlafyDev NotAShelf ]; 20 - }; 21 - })
+28
pkgs/by-name/we/webcord-vencord/package.nix
··· 1 + { 2 + webcord, 3 + substituteAll, 4 + lib, 5 + vencord-web-extension, 6 + }: 7 + 8 + # nixpkgs-update: no auto update 9 + webcord.overrideAttrs (old: { 10 + pname = "webcord-vencord"; 11 + 12 + patches = (old.patches or [ ]) ++ [ 13 + (substituteAll { 14 + src = ./add-extension.patch; 15 + vencord = vencord-web-extension; 16 + }) 17 + ]; 18 + 19 + meta = { 20 + inherit (old.meta) license mainProgram platforms; 21 + 22 + description = "Webcord with Vencord web extension"; 23 + maintainers = with lib.maintainers; [ 24 + FlafyDev 25 + NotAShelf 26 + ]; 27 + }; 28 + })
+93
pkgs/by-name/we/webcord/package.nix
··· 1 + { 2 + lib, 3 + buildNpmPackage, 4 + fetchFromGitHub, 5 + copyDesktopItems, 6 + python3, 7 + xdg-utils, 8 + electron, 9 + makeDesktopItem, 10 + }: 11 + 12 + buildNpmPackage rec { 13 + pname = "webcord"; 14 + version = "4.8.0"; 15 + 16 + src = fetchFromGitHub { 17 + owner = "SpacingBat3"; 18 + repo = "WebCord"; 19 + rev = "refs/tags/v${version}"; 20 + hash = "sha256-x9Ejb8yxgQhlEfUUfoqbgSffNNtOoFeAyb3OISR+Jz4="; 21 + }; 22 + 23 + npmDepsHash = "sha256-7H4I4vKygMgsPh+OvZZGhpkoQQu1a51yUTwEPJSBM18="; 24 + 25 + nativeBuildInputs = [ 26 + copyDesktopItems 27 + python3 28 + ]; 29 + 30 + # npm install will error when electron tries to download its binary 31 + # we don't need it anyways since we wrap the program with our nixpkgs electron 32 + env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; 33 + 34 + # remove husky commit hooks, errors and aren't needed for packaging 35 + postPatch = '' 36 + rm -rf .husky 37 + ''; 38 + 39 + # override installPhase so we can copy the only folders that matter 40 + installPhase = 41 + let 42 + binPath = lib.makeBinPath [ xdg-utils ]; 43 + in 44 + '' 45 + runHook preInstall 46 + 47 + # Remove dev deps that aren't necessary for running the app 48 + npm prune --omit=dev 49 + 50 + mkdir -p $out/lib/node_modules/webcord 51 + cp -r app node_modules sources package.json $out/lib/node_modules/webcord/ 52 + 53 + install -Dm644 sources/assets/icons/app.png $out/share/icons/hicolor/256x256/apps/webcord.png 54 + 55 + # Add xdg-utils to path via suffix, per PR #181171 56 + makeWrapper '${lib.getExe electron}' $out/bin/webcord \ 57 + --suffix PATH : "${binPath}" \ 58 + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ 59 + --add-flags $out/lib/node_modules/webcord/ 60 + 61 + runHook postInstall 62 + ''; 63 + 64 + desktopItems = [ 65 + (makeDesktopItem { 66 + name = "webcord"; 67 + exec = "webcord"; 68 + icon = "webcord"; 69 + desktopName = "WebCord"; 70 + comment = meta.description; 71 + categories = [ 72 + "Network" 73 + "InstantMessaging" 74 + ]; 75 + }) 76 + ]; 77 + 78 + passthru.updateScript = ./update.sh; 79 + 80 + meta = { 81 + description = "A Discord and SpaceBar electron-based client implemented without Discord API"; 82 + homepage = "https://github.com/SpacingBat3/WebCord"; 83 + downloadPage = "https://github.com/SpacingBat3/WebCord/releases"; 84 + changelog = "https://github.com/SpacingBat3/WebCord/releases/tag/v${version}"; 85 + license = lib.licenses.mit; 86 + mainProgram = "webcord"; 87 + maintainers = with lib.maintainers; [ 88 + eclairevoyant 89 + huantian 90 + ]; 91 + platforms = lib.platforms.linux; 92 + }; 93 + }
+15
pkgs/by-name/we/webcord/update.sh
··· 1 + #! /usr/bin/env nix-shell 2 + #! nix-shell -i bash -p curl jq nix-update 3 + 4 + set -ex 5 + 6 + curl_github() { 7 + curl -L ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} "$@" 8 + } 9 + 10 + latestTag=$(curl_github https://api.github.com/repos/SpacingBat3/Webcord/releases/latest | jq -r ".tag_name") 11 + latestVersion="$(expr "$latestTag" : 'v\(.*\)')" 12 + 13 + nix-update --version "$latestVersion" webcord 14 + electronVersion=$(curl_github "https://raw.githubusercontent.com/SpacingBat3/WebCord/v$latestVersion/package.json" | jq -r ".devDependencies.electron" | sed -r 's|^\^([0-9]+).*|\1|') 15 + sed -r "/webcord = / s|(electron_)[0-9]+|\1$electronVersion|" -i pkgs/top-level/all-packages.nix
+1 -3
pkgs/top-level/all-packages.nix
··· 35576 35576 35577 35577 webcamoid = libsForQt5.callPackage ../applications/video/webcamoid { }; 35578 35578 35579 - webcord = callPackage ../applications/networking/instant-messengers/webcord { }; 35580 - 35581 - webcord-vencord = callPackage ../applications/networking/instant-messengers/webcord/webcord-vencord { }; 35579 + webcord = callPackage ../by-name/we/webcord/package.nix { electron = electron_29; }; 35582 35580 35583 35581 webex = callPackage ../applications/networking/instant-messengers/webex { }; 35584 35582