Add support for building minecraft modpacks

This commit is contained in:
Tristan Daniël Maat 2021-04-25 04:50:30 +01:00
parent b474f7e97c
commit a9e3610744
Signed by: tlater
GPG key ID: 49670FD774E43268
6 changed files with 121 additions and 11 deletions
pkgs/build-support

View file

@ -0,0 +1,23 @@
{ lib, fetchurl }:
with builtins;
{ project, id, filename, ... }@args:
let
# I think this is supposed to be some weak automation
# protection. This split "id" is simply part of the download URL.
#
# Note that if it's zero-prefixed we need to remove the zeroes. It's
# really an odd one...
a = head (match "0*([[:digit:]]+)" (substring 0 4 id));
b = head (match "0*([[:digit:]]+)" (substring 4 7 id));
url = "https://media.forgecdn.net/files/${a}/${b}/${filename}";
otherArgs = removeAttrs args [ "project" "id" "filename" ];
in fetchurl (otherArgs // {
inherit url;
# Rename files to avoid names incompatible with the nix store
name = "${project}.jar";
})