fork/nix-minecraft

git clone https://git.julia.blue/fork/nix-minecraft

Infinidogefix(helpers): use compact json in fetchModrinthModdc3914e

module/fix-14
503 B21 linesraw
1{ stdenv
2, fetchurl
3, jq
4, id
5, hash
6}:
7let
8  version = builtins.fromJSON
9    (builtins.readFile
10      (fetchurl {
11        url = "https://api.modrinth.com/v2/version/${id}";
12        sha256 = hash;
13        downloadToTemp = true;
14        postFetch = ''
15          cat $downloadedFile \
16          | jq -c '.files | (.[] | select(.primary == true)) // .[0] | {url: .url, sha512: .hashes.sha512}' > $out
17        '';
18        nativeBuildInputs = [ jq ];
19      }));
20in
21fetchurl { inherit (version) url sha512; }