llvmPackages_rocm: add update script

This commit is contained in:
Sebastian Neubauer 2021-09-08 16:15:45 +02:00
parent d99dfe5821
commit 61a2864b18

@ -1,6 +1,7 @@
{ stdenv { stdenv
, lib , lib
, fetchFromGitHub , fetchFromGitHub
, writeScript
, cmake , cmake
, python3 , python3
, libxml2 , libxml2
@ -88,6 +89,23 @@ in stdenv.mkDerivation rec {
passthru.src = src; passthru.src = src;
updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq common-updater-scripts nix-prefetch-github
version="$(curl -sL "https://api.github.com/repos/RadeonOpenCompute/llvm-project/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)"
current_version="$(grep "version =" pkgs/development/compilers/llvm/rocm/default.nix | cut -d'"' -f2)"
if [[ "$version" != "$current_version" ]]; then
tarball_meta="$(nix-prefetch-github RadeonOpenCompute llvm-project --rev "rocm-$version")"
tarball_hash="$(nix to-base64 sha256-$(jq -r '.sha256' <<< "$tarball_meta"))"
sed -i "pkgs/development/compilers/llvm/rocm/default.nix" \
-e 's,version = "\(.*\)",version = "'"$version"'",' \
-e 's,hash = "\(.*\)",hash = "sha256-'"$tarball_hash"'",'
else
echo rocm-llvm already up-to-date
fi
'';
meta = with lib; { meta = with lib; {
description = "ROCm fork of the LLVM compiler infrastructure"; description = "ROCm fork of the LLVM compiler infrastructure";
homepage = "https://github.com/RadeonOpenCompute/llvm-project"; homepage = "https://github.com/RadeonOpenCompute/llvm-project";