dot.nix/pkgs/proton-cachyos/update.nix
Chris Toph 93dc3db7a5
Some checks are pending
Build NixOS ISOs (x86 only) / build-iso (x86, desktop) (push) Waiting to run
Build NixOS ISOs (x86 only) / build-iso (x86, server) (push) Waiting to run
Build NixOS ISOs (x86 only) / create-release (push) Blocked by required conditions
Add proton-cachyos package and update gamescope-run steam wrapper to use the properly configured steam executable
2025-06-29 03:03:41 -04:00

55 lines
1.4 KiB
Nix

{
writeShellScript,
lib,
coreutils,
findutils,
gnugrep,
curl,
jq,
git,
nix,
nix-prefetch-git,
moreutils,
yq,
}:
let
path = lib.makeBinPath [
coreutils
curl
findutils
gnugrep
jq
moreutils
git
nix-prefetch-git
nix
yq
];
in
writeShellScript "update-proton-cachyos" ''
set -euo pipefail
PATH=${path}
srcJson=pkgs/proton-cachyos/versions.json
localBase=$(jq -r .base < $srcJson)
localRelease=$(jq -r .release < $srcJson)
latestVer=$(curl 'https://github.com/GloriousEggroll/proton-cachyos/tags.atom' | xq -r '.feed.entry[0].link."@href"' | grep -Po '(?<=/)[^/]+$')
if [ "GE-Proton''${localBase}-''${localRelease}" == "$latestVer" ]; then
exit 0
fi
latestBase=$(echo $latestVer | grep -Po '(?<=GE-Proton)[^-]+')
latestRelease=$(echo $latestVer | grep -Po '(?<=-)[^-]+$')
latestSha256=$(nix-prefetch-url --type sha256 "https://github.com/CachyOS/proton-cachyos/releases/download/''${latestVer}/''${latestVer}.tar.gz")
latestHash=$(nix-hash --to-sri --type sha256 $latestSha256)
jq \
--arg latestBase "$latestBase" --arg latestRelease "$latestRelease" --arg latestHash "$latestHash" \
'.base = $latestBase | .release = $latestRelease | .hash = $latestHash' \
"$srcJson" | sponge "$srcJson"
git add $srcJson
git commit -m "proton-cachyos: ''${localBase}.''${localRelease} -> ''${latestBase}.''${latestRelease}"
''