treewide: Reformat project with alejandra

This commit is contained in:
Tristan Daniël Maat 2022-10-10 13:03:08 +01:00
parent 58e52dd119
commit 046a88905d
Signed by: tlater
GPG key ID: 49670FD774E43268
17 changed files with 405 additions and 353 deletions

View file

@ -1,26 +1,31 @@
{ lib, fetchurl }:
{
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 (toString id)));
b = head (match "0*([[:digit:]]+)" (substring 4 7 (toString id)));
encoded-filename = replaceStrings [" "] ["%20"] filename;
{ 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 (toString id)));
b = head (match "0*([[:digit:]]+)" (substring 4 7 (toString id)));
encoded-filename = replaceStrings [ " " ] [ "%20" ] filename;
url = "https://media.forgecdn.net/files/${a}/${b}/${encoded-filename}";
otherArgs = removeAttrs args [ "project" "project_id" "id" "filename" ];
in fetchurl (otherArgs // {
inherit url;
# Rename files to avoid names incompatible with the nix store
name = "${project}.jar";
# Avoid accidental URL globbing
curlOpts = "--globoff";
})
url = "https://media.forgecdn.net/files/${a}/${b}/${encoded-filename}";
otherArgs = removeAttrs args ["project" "project_id" "id" "filename"];
in
fetchurl (otherArgs
// {
inherit url;
# Rename files to avoid names incompatible with the nix store
name = "${project}.jar";
# Avoid accidental URL globbing
curlOpts = "--globoff";
})

View file

@ -1,19 +1,21 @@
{ pkgs, local-lib, ... }:
let
{
pkgs,
local-lib,
...
}: let
inherit (pkgs.lib) callPackageWith;
callPackage = callPackageWith (pkgs // { inherit local-lib; });
callPackage = callPackageWith (pkgs // {inherit local-lib;});
in {
# Forge
forge-server = callPackage ./minecraft/forge-server.nix { };
forge-server = callPackage ./minecraft/forge-server.nix {};
# Build support
fetchFromCurseForge = callPackage ./build-support/fetchFromCurseForge.nix { };
fetchFromCurseForge = callPackage ./build-support/fetchFromCurseForge.nix {};
# Minecraft modpacks
voor-kia = callPackage ./minecraft/voor-kia.nix { };
voor-kia-client = callPackage ./minecraft/voor-kia-client.nix { };
voor-kia = callPackage ./minecraft/voor-kia.nix {};
voor-kia-client = callPackage ./minecraft/voor-kia-client.nix {};
# Starbound
starbound = callPackage ./starbound { };
starbound = callPackage ./starbound {};
}

View file

@ -1,7 +1,15 @@
{ lib, stdenv, fetchurl, busybox, coreutils, jre_headless, runtimeShell
, mods ? null, modConfig ? null, defaultconfigs ? null }:
let
{
lib,
stdenv,
fetchurl,
busybox,
coreutils,
jre_headless,
runtimeShell,
mods ? null,
modConfig ? null,
defaultconfigs ? null,
}: let
name = "forge-server";
version = "1.16.5-36.2.2";
mirror = "https://files.minecraftforge.net/maven/net/minecraftforge/forge";
@ -14,7 +22,7 @@ let
unpackCmd = "mkdir -p src; cp $curSrc src/forge-${version}-installer.jar";
nativeBuildInputs = [ jre_headless ];
nativeBuildInputs = [jre_headless];
# Somewhat evil pre-install step to run through the network
# dependency resolution forge needs. This is also common for gradle
@ -43,70 +51,70 @@ let
outputHashMode = "recursive";
outputHash = "VuUGc5JnzcRhDt9aaGrU+yUrJILVdU2vzv1PxLwdAig=";
};
in
stdenv.mkDerivation rec {
inherit name version src unpackCmd nativeBuildInputs;
in stdenv.mkDerivation rec {
inherit name version src unpackCmd nativeBuildInputs;
buildPhase = ''
mkdir -p installation
buildPhase = ''
mkdir -p installation
# Take the input deps and patch the Minecraft server jar into our
# libraries to create the package.
cp -rv ${deps}/* installation/
chmod -R +w installation/
java -jar forge-${version}-installer.jar --offline --installServer installation/
'';
# Take the input deps and patch the Minecraft server jar into our
# libraries to create the package.
cp -rv ${deps}/* installation/
chmod -R +w installation/
java -jar forge-${version}-installer.jar --offline --installServer installation/
'';
installPhase = ''
mkdir -p $out/{bin,lib/forge}
installPhase = ''
mkdir -p $out/{bin,lib/forge}
cp -r installation/{forge-${version}.jar,libraries} $out/lib/forge/
cp -r installation/{forge-${version}.jar,libraries} $out/lib/forge/
cat > $out/bin/forge-server << EOF
#!${runtimeShell}
set -eu
cat > $out/bin/forge-server << EOF
#!${runtimeShell}
set -eu
# Delete any previous mods directory so that it can be updated
${busybox}/bin/rm -fr mods
# Delete any previous mods directory so that it can be updated
${busybox}/bin/rm -fr mods
${lib.optionalString (mods != null) ''
# Copy the specified mods into the directory. Note that, sadly,
# forge doesn't support symlinks here.
${busybox}/bin/mkdir -p mods
${busybox}/bin/cp -r '${mods}/mods/'*.jar mods
''}
${lib.optionalString (mods != null) ''
# Copy the specified mods into the directory. Note that, sadly,
# forge doesn't support symlinks here.
${busybox}/bin/mkdir -p mods
${busybox}/bin/cp -r '${mods}/mods/'*.jar mods
''}
# Delete any previous config directories so that they can be updated
${busybox}/bin/rm -fr config defaultconfigs
# Delete any previous config directories so that they can be updated
${busybox}/bin/rm -fr config defaultconfigs
${lib.optionalString (modConfig != null) ''
# Copy the specified configs into the directory. Forge (and
# mods) will try to write here, so we cannot symlink.
${busybox}/bin/mkdir -p config
${busybox}/bin/cp -r '${modConfig}'/* config
${busybox}/bin/chmod -R u+w config
''}
${lib.optionalString (modConfig != null) ''
# Copy the specified configs into the directory. Forge (and
# mods) will try to write here, so we cannot symlink.
${busybox}/bin/mkdir -p config
${busybox}/bin/cp -r '${modConfig}'/* config
${busybox}/bin/chmod -R u+w config
''}
${lib.optionalString (defaultconfigs != null) ''
# Copy the specified configs into the directory. Forge (and
# mods) will try to write here, so we cannot symlink.
${busybox}/bin/mkdir -p defaultconfigs
${busybox}/bin/cp -r '${defaultconfigs}'/* defaultconfigs
${busybox}/bin/chmod -R u+w defaultconfigs
''}
${lib.optionalString (defaultconfigs != null) ''
# Copy the specified configs into the directory. Forge (and
# mods) will try to write here, so we cannot symlink.
${busybox}/bin/mkdir -p defaultconfigs
${busybox}/bin/cp -r '${defaultconfigs}'/* defaultconfigs
${busybox}/bin/chmod -R u+w defaultconfigs
''}
exec ${jre_headless}/bin/java \$@ -jar $out'/lib/forge/forge-${version}.jar' nogui
EOF
exec ${jre_headless}/bin/java \$@ -jar $out'/lib/forge/forge-${version}.jar' nogui
EOF
chmod +x $out/bin/forge-server
'';
chmod +x $out/bin/forge-server
'';
meta = with lib; {
description = "Forge Minecraft Server";
homepage = "https://files.minecraftforge.net/";
# Forge itself is open source, but this package pulls in
# minecraft.
license = licenses.unfreeRedistributable;
platforms = platforms.unix;
};
}
meta = with lib; {
description = "Forge Minecraft Server";
homepage = "https://files.minecraftforge.net/";
# Forge itself is open source, but this package pulls in
# minecraft.
license = licenses.unfreeRedistributable;
platforms = platforms.unix;
};
}

View file

@ -1,8 +1,12 @@
{ lib, local-lib, stdenv }:
{
lib,
local-lib,
stdenv,
}:
local-lib.minecraft.mkModpackZip {
name = "voor-kia-client";
version = "1.1";
mods = (builtins.fromJSON (builtins.readFile ./voor-kia/mods.json))
mods =
(builtins.fromJSON (builtins.readFile ./voor-kia/mods.json))
++ (builtins.fromJSON (builtins.readFile ./voor-kia/client-mods.json));
}

View file

@ -1,5 +1,8 @@
{ lib, local-lib, stdenv }:
{
lib,
local-lib,
stdenv,
}:
local-lib.minecraft.mkModpack {
name = "voor-kia";
version = "1.0";