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

8
lib/default.nix Normal file
View file

@ -0,0 +1,8 @@
{ inputs, lib, pkgs, ... }:
let
inherit (lib) makeExtensible foldr attrValues;
tlater-lib = makeExtensible (self:
let callLibs = file: import file { inherit self lib pkgs inputs; };
in { minecraft = callLibs ./minecraft.nix; });
in tlater-lib.extend (self: super: foldr (a: b: a // b) { } (attrValues super))

30
lib/minecraft.nix Normal file
View file

@ -0,0 +1,30 @@
{ lib, pkgs, ... }:
{
# Make a modpack given its mod inputs.
#
# Mods should be attrsets in this format:
# {
# project = "";
# id = "";
# filename = "";
# sha256 = "";
# }
#
# This may be nice to read from a json ;)
#
mkModpack = { name, version, mods }:
pkgs.stdenv.mkDerivation {
inherit name version;
srcs = map pkgs.local.fetchFromCurseForge mods;
sourceRoot = "src/";
preUnpack = "mkdir -p src/";
unpackCmd = "cp $curSrc src/";
installPhase = ''
mkdir -p $out/mods/
cp * $out/mods
'';
};
}