1args@{
2 callPackage,
3 lib,
4 ...
5}:
6
7# Type aliases
8# Release = {
9# version: String
10# hash: String
11# supportedGpuTargets: List String
12# }
13
14let
15 inherit (lib) lists strings trivial;
16
17 computeName = version: "magma_${strings.replaceStrings [ "." ] [ "_" ] version}";
18
19 # buildMagmaPackage :: Release -> Derivation
20 buildMagmaPackage =
21 magmaRelease:
22 callPackage ./generic.nix (
23 (builtins.removeAttrs args [ "callPackage" ])
24 // {
25 inherit magmaRelease;
26 }
27 );
28
29 # Reverse the list to have the latest release first
30 # magmaReleases :: List Release
31 magmaReleases = lists.reverseList (builtins.import ./releases.nix);
32
33 # The latest release is the first element of the list and will be our default choice
34 # latestReleaseName :: String
35 latestReleaseName = computeName (builtins.head magmaReleases).version;
36
37 # Function to transform our releases into build attributes
38 # toBuildAttrs :: Release -> { name: String, value: Derivation }
39 toBuildAttrs = release: {
40 name = computeName release.version;
41 value = buildMagmaPackage release;
42 };
43
44 # Add all supported builds as attributes
45 # allBuilds :: AttrSet String Derivation
46 allBuilds = builtins.listToAttrs (lists.map toBuildAttrs magmaReleases);
47
48 # The latest release will be our default build
49 # defaultBuild :: AttrSet String Derivation
50 defaultBuild.magma = allBuilds.${latestReleaseName};
51
52 # builds :: AttrSet String Derivation
53 builds = allBuilds // defaultBuild;
54in
55
56builds