feat: JumpAcademy.tf maps

This commit is contained in:
Madeleine Sydney committed 2025-04-13 09:05:40 -06:00
1 parent e885c411e0
commit 2b3bc04751
11 files changed
+188 -36

No files matched your search

+2 -1
View File
@@ -1 +1,2 @@
tf2/packages/huds/hud-db/hud-db.json linguist-generated=true
tf2/packages/huds/hud-db/hud-db.json linguist-generated=true
tf2/packages/maps/jump-academy/jump-academy.json linguist-generated=true
+1 -1
View File
@@ -134,7 +134,7 @@ Don't hesitate to open issues/PRs not only for "real issues" (bugs, missing feat
- [ ] Tests.
- [X] Figure out installation for Impermanence users.
- [ ] Package Paysus' animation overhauls.
- [ ] Generate package set from [[https://cdn.jumpacademy.tf/][jumpacademy.tf]].
- [X] Generate package set from [[https://cdn.jumpacademy.tf/][jumpacademy.tf]].
* See also
+36 -19
View File
@@ -1,7 +1,7 @@
{ stdenv, lib }:
{ pname
, version ? "nover"
, version ? ""
, custom ? []
, cfg ? []
, maps ? []
@@ -19,9 +19,9 @@ let
${lib.toShellVar "outputList_${output}" var}
for i in "''${outputList_${output}[@]}"; do
name="$(stripHash "$i")"
vpkDir="#vpk-''${name}#"
if [ -d "$vpkDir" ]; then
mv "$vpkDir/$name" "$out/${output}/$name"
wrapperDir="#''${name}#"
if [ -d "$wrapperDir" ]; then
mv "$wrapperDir"/* "$out/${output}/"
else
mv "$name" "$out/${output}/$name"
fi
@@ -38,21 +38,38 @@ in stdenv.mkDerivation ({
inherit pname version;
# Adapted from stdenv's _defaultUnpack().
unpackCmd = ''
if [ "''${curSrc##*.}" = "vpk" ]; then
destination="#vpk-$(stripHash "$curSrc")#/$(stripHash "$curSrc")"
mkdir "$(dirname "$destination")"
if [ -e "$destination" ]; then
echo "Cannot copy $curSrc to $destination: destination already exists!"
echo "Did you specify two \"srcs\" with the same \"name\"?"
return 1
fi
# We can't preserve hardlinks because they may have been
# introduced by store optimization, which might break things
# in the build.
cp -r --preserve=mode,timestamps --reflink=auto -- "$curSrc" "$destination"
else
return 1
fi
echo "hello i am unpackcmdjkj"
set -e
case "$curSrc" in
*.vpk)
name="$(stripHash "$curSrc")"
destination="#$name#/$name"
mkdir "$(dirname "$destination")"
if [ -e "$destination" ]; then
echo "Cannot copy $curSrc to $destination: destination already exists!"
echo "Did you specify two \"srcs\" with the same \"name\"?"
return 1
fi
# We can't preserve hardlinks because they may have been
# introduced by store optimization, which might break things
# in the build.
cp -r --preserve=mode,timestamps --reflink=auto -- "$curSrc" "$destination"
;;
*.bsp.bz2)
bzfile="$(stripHash "$curSrc")"
file="''${bzfile%.bz2}"
destination="#$bzfile#/$file"
mkdir "$(dirname "$destination")"
bunzip2 -c "$curSrc" > "$destination"
;;
*)
return 1
;;
esac
'';
preUnpack = ''
echo "$unpackCmd"
echo "$unpackCmdHooks"
'';
installPhase = ''
set -xe
+1 -1
View File
@@ -40,7 +40,7 @@ in lib.mergeAttrsList [
{ inherit mkTf2Config fetchFromGameBanana mkCfg mergeTf2Configs; }
{ mastercomfig = callPackage ./mastercomfig.nix {}; }
{ huds = callPackage ./huds {}; }
{ maps = callPackage ./maps.nix {}; }
{ maps = callPackage ./maps {}; }
(callPackage ./misc.nix {})
(callPackage ./scripts.nix {})
]
-14
View File
@@ -1,14 +0,0 @@
{ fetchFromGameBanana, mkTf2Config }:
{
jump_beef = mkTf2Config {
pname = "jump_beef";
maps = [
(fetchFromGameBanana {
name = "jump_beef";
id = "323807";
hash = "sha256-A/MqnQJAt+MOZGnZOy7CgbLuXwKdbU0DjudMkTZoW6c=";
})
];
};
}
+6
View File
@@ -0,0 +1,6 @@
{ pkgs, callPackage, fetchFromGitHub, mkTf2Config }@args:
let
jump-academy = callPackage ./jump-academy {};
extras = callPackage ./extras.nix {};
in jump-academy // extras
+14
View File
@@ -0,0 +1,14 @@
{ fetchFromGameBanana, mkTf2Config }:
{
# jump_beef = mkTf2Config {
# pname = "jump_beef";
# maps = [
# (fetchFromGameBanana {
# name = "jump_beef";
# id = "323807";
# hash = "sha256-A/MqnQJAt+MOZGnZOy7CgbLuXwKdbU0DjudMkTZoW6c=";
# })
# ];
# };
}
@@ -0,0 +1,13 @@
{ mkTf2Config, fetchurl }:
builtins.mapAttrs
(name: e: mkTf2Config {
pname = name;
env.description = e.description;
maps = [
(fetchurl {
inherit (e.src) url hash;
})
];
})
(builtins.fromJSON (builtins.readFile ./jump-academy.json))
@@ -0,0 +1,113 @@
(ns fetch-jump-academy
(:require [babashka.fs :as fs]
[babashka.process :as p]
[babashka.http-client :as http]
[cheshire.core :as json]
[clojure.tools.logging :as l]
[clojure.string :as str]
[clojure.java.io :as io]
[clojure.edn :as edn]))
(def ^:dynamic *dry-run?* true)
(def cache-dir (fs/xdg-cache-home "fetch-jump-academy"))
(def maps-cache-dir (fs/file cache-dir "maps"))
(defn list-maps []
(let [map-list-file (fs/file cache-dir "map-list.edn")]
(fs/create-dirs cache-dir)
(if (fs/exists? map-list-file)
(with-open [r (io/reader map-list-file)]
(edn/read (java.io.PushbackReader. r)))
(if *dry-run?*
(throw (ex-info (str "Cannot list maps during a dry run "
"unless previous result is cached.")
{}))
(let [resp (http/post
"https://cdn.jumpacademy.tf/?generate"
{:headers {:content-type "application/x-www-form-urlencoded"}
:body (slurp "./request")})]
(if (= (:status resp) 200)
(as-> (:body resp)
$
(str/replace $ "wget " "")
(str/split $ #"[\n\r]")
(pr-str $)
(spit map-list-file $))
(throw (ex-info "Bad response from jumpacademny.tf" resp))))))))
(defmacro race [x y]
`(let [p# (promise)
f1# (future (deliver p# ~x))
f2# (future (deliver p# ~y))
winner# @p#]
(future-cancel f1#)
(future-cancel f2#)
winner#))
(defn prefetch [url]
(let [command ["nix store prefetch-file --json" url]]
(if *dry-run?*
(do (apply println "$" command)
"«hash»")
(when-some [data
(race (apply p/shell {:out :string} command)
(do (Thread/sleep (* 120 1000))
(binding [*out* *err*]
(l/warnf "Timed out whilst prefetching %s" url))
nil))]
(-> data :out (json/decode keyword) :hash)))))
(defn prefetch*
"A caching variant of `prefetch`."
[url]
(let [[_ file-name] (re-find #"/([^/]*)$" url)
cache-entry (fs/file maps-cache-dir (str file-name ".hash"))]
(if (fs/exists? cache-entry)
(let [cached-result (slurp cache-entry)]
cached-result)
(let [hash (prefetch url)]
(when (and hash
;; During dry runs, `prefetch` will return fake hashes that
;; we don't want to pollute the cache with.
(not *dry-run?*))
(fs/create-dirs (fs/parent cache-entry))
(spit cache-entry hash))
hash))))
(defn fetch-map
"Construct a map with the necessary info to package a map from JumpAcademy.
`name` is expected to be the package's name. URL is the map's CDN URL on
JumpAcademy. Returns nil on failure."
[name url]
(binding [*out* *err*]
(l/infof "Fetching %s" name))
(when-some [hash (prefetch* url)]
{:description (format "Map %s for TF2" name)
;; For forward-compatibility, when we hopefully add support those
;; pesky non-GitHub downloads.
:src {:__type "zip"
:url url
:hash hash}}))
(defn parse-map-name [url]
(let [[_ name] (re-find #"/([^/]*)\.bsp\.bz2$" url)]
name))
(defn fetch-jump-academy []
(into {}
(for [map-url (list-maps)]
(let [map-name (parse-map-name map-url)]
(if-some [map-info (fetch-map map-name map-url)]
[(keyword map-name)
map-info]
(binding [*out* *err*]
(l/warnf "Skipping map `%s`" map-name)
nil))))))
(defn -main []
(binding [*dry-run?* false]
(-> (fetch-jump-academy)
json/encode
print)))
+1
View File
@@ -0,0 +1 @@
{"jump_academy_beta3_v1":{"description":"Map jump_academy_beta3_v1 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_academy_beta3_v1.bsp.bz2","hash":"sha256-PGfCa8qdwLjVrsjJq+w+/vW00uejBxwLNXaJtc2y7KU="}},"jump_christmas_zip":{"description":"Map jump_christmas_zip for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_christmas_zip.bsp.bz2","hash":"sha256-v0OlrK4AwQU/hUOYiKUCTjKp/y6Bg2mgQ1M5hxpeLyM="}},"jump_attached_rc6":{"description":"Map jump_attached_rc6 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_attached_rc6.bsp.bz2","hash":"sha256-Ig72ApuZxvrpFM9wenmD9FjBcp5x/reZtUqv+XG1Jw4="}},"jump_toot_rc4":{"description":"Map jump_toot_rc4 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_toot_rc4.bsp.bz2","hash":"sha256-EoDVgrSB1u6Q7n1tXYoJLozPRChEk3P+xptO1tSjKMY="}},"jump_simply":{"description":"Map jump_simply for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_simply.bsp.bz2","hash":"sha256-lmndzCjc659oBPaqi7fxxAvSZ9aQgBeMDpylfDR2Ubk="}},"plr_hightower_tdm_r8b_jungle":{"description":"Map plr_hightower_tdm_r8b_jungle for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/plr_hightower_tdm_r8b_jungle.bsp.bz2","hash":"sha256-Y0Ntl60/ZrZQPdqCaXrkfvfvlNiq74qXY/qmIJD7iok="}},"jump_rush_h_b4":{"description":"Map jump_rush_h_b4 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_rush_h_b4.bsp.bz2","hash":"sha256-TncPEw8dYoDb8ebindNu1s4iZaWzNOvBTKvPq21o0pg="}},"jump_everest_a1":{"description":"Map jump_everest_a1 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_everest_a1.bsp.bz2","hash":"sha256-JIKI0MUiShqbG/f+8SUgz1Pka20HmTjr46sKDKMUieI="}},"jump_ofthehats_rc6":{"description":"Map jump_ofthehats_rc6 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_ofthehats_rc6.bsp.bz2","hash":"sha256-/ibYpgG4ozBsFGTY1L/CNFeM2x4vaqI02icxm6hCY1k="}},"jump_skylight":{"description":"Map jump_skylight for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_skylight.bsp.bz2","hash":"sha256-xdK1yPCoigy6Wcx822jyCQvrfRO0nOo16hg517i2FFs="}},"jump_box":{"description":"Map jump_box for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_box.bsp.bz2","hash":"sha256-IS+3pEezAgS38TijB6TlNhb4ppJt1IGbN2VIQBIlCTE="}},"jump_tpn_final1":{"description":"Map jump_tpn_final1 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_tpn_final1.bsp.bz2","hash":"sha256-ks1UYgsh3qxfaIw0ZSL2doUXg7xfFKPUR3IKboezWRQ="}},"plr_tdm_helltower_rc1a":{"description":"Map plr_tdm_helltower_rc1a for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/plr_tdm_helltower_rc1a.bsp.bz2","hash":"sha256-XluBwPvSpJrMol1QaoFZ5+Gea38VTSM1tMWatjDZ334="}},"jump_lost_a6":{"description":"Map jump_lost_a6 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_lost_a6.bsp.bz2","hash":"sha256-uzbe91+vhAHG3DSBgelsc+QgR5E7FaSYmYt44+gZAFo="}},"freestyle_hydro":{"description":"Map freestyle_hydro for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/freestyle_hydro.bsp.bz2","hash":"sha256-nbgfkyTXf7wALQzEyMZhe9xszoiZ/iFhI8spg94Q21Y="}},"jump_auga_b2":{"description":"Map jump_auga_b2 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_auga_b2.bsp.bz2","hash":"sha256-5OFHzrhDLstRHFRprrwZN4naE5KfIDX9ulD4CQ04wrw="}},"conc_speed_b1_fix":{"description":"Map conc_speed_b1_fix for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/conc_speed_b1_fix.bsp.bz2","hash":"sha256-ckK7iPyY3fHo7WyUnsFtjCfg5viWyJ3FzCvX6z3ixpk="}},"jump_toxic_v6":{"description":"Map jump_toxic_v6 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_toxic_v6.bsp.bz2","hash":"sha256-lGOPwo3Rwi26mQRCGP0de8Dca4OMCYWEjlGMfdkq5nc="}},"tdm_hightower_r11":{"description":"Map tdm_hightower_r11 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/tdm_hightower_r11.bsp.bz2","hash":"sha256-l+IC1gDYEf8ay7cKpHwtCiqX97aXJilfNIGPJJxsjls="}},"jump_ruelee_a6":{"description":"Map jump_ruelee_a6 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_ruelee_a6.bsp.bz2","hash":"sha256-tbrhSozGJM99qE3e7daYoBb14AGO9vKf4YdkWp4L1Qs="}},"jump_jynkky_final1":{"description":"Map jump_jynkky_final1 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_jynkky_final1.bsp.bz2","hash":"sha256-egsHrUZfgWEDplwRQZPadJBJKyKn387kH6letCtg/hY="}},"jump_kael_final4":{"description":"Map jump_kael_final4 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/jump_kael_final4.bsp.bz2","hash":"sha256-M8BEm3D0+NRc2vIyYbWVvhJh7bGPORJfJJFtDBpfDB4="}},"jump_panama_v3":{"description":"Map jump_panama_v3 for TF2","src":{"__type":"zip","url":"https://cdn.jumpacademy.tf/fastdl/maps/Line truncated
+1
View File
@@ -0,0 +1 @@
selection%5B%5D=charge_pork&selection%5B%5D=colour_jumper_rocket&selection%5B%5D=concmap&selection%5B%5D=concmap2&selection%5B%5D=concmap3&selection%5B%5D=concmap_cave&selection%5B%5D=concmap_eu_a2p&selection%5B%5D=concmap_eu_a2p_fix&selection%5B%5D=concmap_exist&selection%5B%5D=concmap_eze2_b3p&selection%5B%5D=conc_aando_b1&selection%5B%5D=conc_aggregate&selection%5B%5D=conc_arc_b1&selection%5B%5D=conc_evolution_beta_b1p&selection%5B%5D=conc_finale_r_a1p&selection%5B%5D=conc_groove4_p&selection%5B%5D=conc_retry_b1&selection%5B%5D=conc_retry_b1_fix&selection%5B%5D=conc_school&selection%5B%5D=conc_speed_b1&selection%5B%5D=conc_speed_b1_fix&selection%5B%5D=cp_5gorge_ja_r3&selection%5B%5D=cp_easy_jump_final&selection%5B%5D=cp_jumpspirit_b2&selection%5B%5D=cp_jump_7skill&selection%5B%5D=cp_jump_b4&selection%5B%5D=cp_jump_tower_v1&selection%5B%5D=cp_process_ja_r2&selection%5B%5D=cp_snakewater_ja_r3&selection%5B%5D=cp_sunshine_ja_r3&selection%5B%5D=ctf_ballin&selection%5B%5D=fan_skillpea_b1&selection%5B%5D=freestyle_88&selection%5B%5D=freestyle_altra&selection%5B%5D=freestyle_axolotl&selection%5B%5D=freestyle_bliss_b1-3&selection%5B%5D=freestyle_bliss_b2&selection%5B%5D=freestyle_brickyard&selection%5B%5D=freestyle_chromatic&selection%5B%5D=freestyle_egypt&selection%5B%5D=freestyle_hydro&selection%5B%5D=freestyle_lick2_b1&selection%5B%5D=freestyle_peaceful&selection%5B%5D=freestyle_pinewood&selection%5B%5D=freestyle_rottenburg&selection%5B%5D=freestyle_woods&selection%5B%5D=gm_bigcity&selection%5B%5D=jujump_nob_a0&selection%5B%5D=jujump_zirco_b1&selection%5B%5D=jumping_trials&selection%5B%5D=jump_&selection%5B%5D=jump_077072067_b2&selection%5B%5D=jump_4dakids&selection%5B%5D=jump_4dakids_final&selection%5B%5D=jump_4demo_fixed5&selection%5B%5D=jump_4demo_fixed6&selection%5B%5D=jump_4friends_v3&selection%5B%5D=jump_4holers_final_fix&selection%5B%5D=jump_4holers_fix&selection%5B%5D=jump_4rockets_v1&selection%5B%5D=jump_4soldier&selection%5B%5D=jump_4soldier_a2&selection%5B%5D=jump_4soldier_redo&selection%5B%5D=jump_4starters&selection%5B%5D=jump_4starters_a2&selection%5B%5D=jump_4starters_a4&selection%5B%5D=jump_4starters_a5&selection%5B%5D=jump_4starters_a8&selection%5B%5D=jump_4starters_a9&selection%5B%5D=jump_4starters_b1_fix&selection%5B%5D=jump_4starters_rc1&selection%5B%5D=jump_4starters_rebuilt&selection%5B%5D=jump_5holers_final&selection%5B%5D=jump_15puzzle&selection%5B%5D=jump_aando_b1_tmps&selection%5B%5D=jump_abandon&selection%5B%5D=jump_ablation_b1&selection%5B%5D=jump_ablation_b3&selection%5B%5D=jump_ablation_b4&selection%5B%5D=jump_above_a420&selection%5B%5D=jump_above_rc1&selection%5B%5D=jump_abuq&selection%5B%5D=jump_abyss_rc1&selection%5B%5D=jump_abyss_rc2&selection%5B%5D=jump_academy2_rc7&selection%5B%5D=jump_academy2_rc8&selection%5B%5D=jump_academy2_rc9&selection%5B%5D=jump_academy2_rc9a&selection%5B%5D=jump_academy_beta3a_v1&selection%5B%5D=jump_academy_beta3_v1&selection%5B%5D=jump_academy_beta_v1&selection%5B%5D=jump_academy_classic&selection%5B%5D=jump_academy_classic_a&selection%5B%5D=jump_academy_classic_b&selection%5B%5D=jump_academy_easy&selection%5B%5D=jump_academy_easy_a&selection%5B%5D=jump_academy_easy_b&selection%5B%5D=jump_academy_easy_c&selection%5B%5D=jump_academy_easy_d&selection%5B%5D=jump_academy_easy_e&selection%5B%5D=jump_academy_easy_halloween15&selection%5B%5D=jump_academy_halloween17&selection%5B%5D=jump_academy_medium_beta4&selection%5B%5D=jump_academy_winter16a&selection%5B%5D=jump_academy_winter_3a&selection%5B%5D=jump_acepogo&selection%5B%5D=jump_achlys&selection%5B%5D=jump_across_a27&selection%5B%5D=jump_adam&selection%5B%5D=jump_adventure&selection%5B%5D=jump_adventure_fixed&selection%5B%5D=jump_aggregate&selection%5B%5D=jump_aggregate_zip&selection%5B%5D=jump_ahh_c&selection%5B%5D=jump_ahrabaid_b2&selection%5B%5D=jump_aigis_a2&selection%5B%5D=jump_aigis_a4&selection%5B%5D=jump_air&selection%5B%5D=jump_airshift_a4&selection%5B%5D=jump_airships_v2&selection%5B%5D=jump_air_beta2&selection%5B%5D=jump_alder_rc3&selection%5B%5D=jump_alienvspredator_v3&selection%5B%5D=jump_alinigt_beta&selection%5B%5D=jump_alle&selection%5B%5D=jump_alle_a2&selection%5B%5D=jump_allstars&selection%5B%5D=jump_allstars_fix&selection%5B%5D=jump_altra&selection%5B%5D=jump_amazon_b1&selection%5B%5D=jump_ancient_beta1&selection%5B%5D=jump_and&selection%5B%5D=jump_andromeda&selection%5B%5D=jump_and_rc1&selection%5B%5D=jump_anime&selection%5B%5D=jump_annex&selection%5B%5D=jump_annex_v2&selection%5B%5D=jump_annex_v3&selection%5B%5D=jump_annex_v4&selection%5B%5D=jump_annex_v5&selection%5B%5D=jump_anothermap_rc3&selection%5B%5D=jump_ante&selection%5B%5D=jump_ante_b5&selection%5B%5D=jump_antiquity&selection%5B%5D=jump_anxiety_a3&selection%5B%5D=jump_anxiety_a9&selection%5B%5D=jump_aperture&selection%5B%5D=jump_aperture_rc15&selection%5B%5D=jump_apex_b1&selection%5B%5D=jump_apparition&selection%5B%5D=jump_apparition_b1&selection%5B%5D=jump_aqua&selection%5B%5D=jump_aqua_rc1&selection%5B%5D=jump_arcane_fLine truncated