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
pkgs/build-support

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";
})