discord: Add update script for darwin

Runnable on linux with

```
nix-shell maintainers/scripts/update.nix --argstr commit true --argstr package pkgsCross.aarch64-darwin.discord
```

The generated commit will have the pkgsCross prefix so that has to be
removed manually

`pkgsCross.aarch64-darwin.discord-canary: 0.0.312 -> 0.0.314`
This commit is contained in:
Artturin 2023-10-02 08:44:26 +03:00
parent 5db123ddef
commit 2958e1b60a

View File

@ -1,4 +1,4 @@
{ pname, version, src, meta, stdenv, binaryName, desktopName, lib, undmg, makeWrapper
{ pname, version, src, meta, stdenv, binaryName, desktopName, lib, undmg, makeWrapper, writeScript
, branch
, withOpenASAR ? false, openasar
, withVencord ? false, vencord }:
@ -31,4 +31,19 @@ stdenv.mkDerivation {
echo '{"name":"discord","main":"index.js"}' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/package.json
echo 'require("${vencord}/patcher.js")' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/index.js
'';
passthru = {
updateScript = writeScript "discord-update-script" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep common-updater-scripts
set -x
set -eou pipefail;
url=$(curl -sI "https://discordapp.com/api/download/${
builtins.replaceStrings [ "discord-" "discord" ] [ "" "stable" ] pname
}?platform=osx&format=dmg" | grep -oP 'location: \K\S+')
version=''${url##https://dl*.discordapp.net/apps/osx/}
version=''${version%%/*.dmg}
update-source-version ${lib.optionalString (!stdenv.buildPlatform.isDarwin) "pkgsCross.aarch64-darwin."}${pname} "$version" --file=./pkgs/applications/networking/instant-messengers/discord/default.nix --version-key=${branch}
'';
};
}