feat(pkgs): add nix-modrinth-prefetch
This commit is contained in:
parent
1ac9b8179d
commit
e355a3341f
2 changed files with 15 additions and 0 deletions
13
pkgs/nix-modrinth-prefetch.nix
Normal file
13
pkgs/nix-modrinth-prefetch.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ runtimeShell, writeShellScriptBin, curl, jq, gnused }:
|
||||
writeShellScriptBin "nix-modrinth-prefetch" ''
|
||||
input=$(${curl}/bin/curl --no-progress-meter https://api.modrinth.com/v2/version/$1)
|
||||
|
||||
if [[ $input == "" ]]; then
|
||||
echo "Invalid version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo $input \
|
||||
| ${jq}/bin/jq -c '.files | (.[] | select(.primary == true)) // .[0] | {url: .url, sha512: .hashes.sha512}' \
|
||||
| ${gnused}/bin/sed 's/{"url":"\(.\+\)","sha512":"\(.\+\)"}/fetchurl { url = "\1"; sha512 = "\2"; }/'
|
||||
''
|
Loading…
Add table
Add a link
Reference in a new issue