-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathdefault.nix
More file actions
56 lines (51 loc) · 1.55 KB
/
default.nix
File metadata and controls
56 lines (51 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
lib,
callPackage,
vanillaServers,
}:
let
inherit (lib.our) escapeVersion;
inherit (lib)
nameValuePair
flatten
last
versionOlder
mapAttrsToList
versions
;
sortBy = attr: f: builtins.sort (a: b: f a.${attr} b.${attr});
loaderLocks = lib.importJSON ./loader_locks.json;
libraryLocks = lib.importJSON ./library_locks.json;
gameLocks = lib.importJSON ./game_locks.json;
packages = mapAttrsToList (
gameVersion: builds:
sortBy "version" versionOlder (
mapAttrsToList (
buildVersion: build:
callPackage ./derivation.nix {
inherit libraryLocks;
build = build // {
version = buildVersion;
};
gameVersion = gameLocks.${gameVersion} // {
version = gameVersion;
};
minecraft-server = vanillaServers."vanilla-${escapeVersion gameVersion}";
}
) builds
)
) loaderLocks;
# without padding, versionOlder will incorrectly sort `1.21-21.1.000` before `1.21.8-21.8.000`
sortableVersion = drv: "${versions.pad 3 drv.passthru.gameVersion}-${drv.passthru.loaderVersion}";
# Latest build for each MC version
latestBuilds = builtins.sort (a: b: versionOlder (sortableVersion a) (sortableVersion b)) (
map last packages
);
in
lib.recurseIntoAttrs (
builtins.listToAttrs (
(map (x: nameValuePair (escapeVersion x.name) x) (flatten packages))
++ (map (x: nameValuePair "${x.pname}-${escapeVersion x.passthru.gameVersion}" x) latestBuilds)
++ [ (nameValuePair "neoforge" (last latestBuilds)) ]
)
)