{ path ? "/../aws-list.txt", }: with import ./common.nix; let pkgs = import pkgsSrc {}; lib = pkgs.lib; /* Converts a key list and a value list to a set Example: listToSet [ "name" "version" ] [ "latex" "3.14" ] => { name = "latex"; version = "3.14"; } */ listToSet = keys: values: builtins.listToAttrs (lib.zipListsWith (a: b: { name = a; value = b; }) keys values); /* Says if datetime a is more recent than datetime b Example: cmpDate { date = "2021-09-10"; time = "22:12:15"; } { date = "2021-02-03"; time = "23:54:12"; } => true */ cmpDate = a: b: let da = (builtins.head a.builds).date; db = (builtins.head b.builds).date; in if da == db then (builtins.head a.builds).time > (builtins.head b.builds).time else da > db; /* Pretty platforms */ prettyPlatform = name: if name == "aarch64-unknown-linux-musl" then "linux/arm64" else if name == "armv6l-unknown-linux-musleabihf" then "linux/arm" else if name == "x86_64-unknown-linux-musl" then "linux/amd64" else if name == "i686-unknown-linux-musl" then "linux/386" else name; /* Parsing */ list = builtins.readFile (./. + path); entries = lib.splitString "\n" list; elems = builtins.filter (e: (builtins.length e) == 4) (map (x: builtins.filter (e: e != "") (lib.splitString " " x)) entries); keys = ["date" "time" "size" "path"]; parsed = map (entry: listToSet keys entry) elems; subkeys = ["root" "version" "platform" "binary" ]; builds = map (entry: entry // listToSet subkeys (lib.splitString "/" entry.path)) parsed; /* Aggregation */ builds_per_version = lib.foldl (acc: v: acc // { ${v.version} = if builtins.hasAttr v.version acc then acc.${v.version} ++ [ v ] else [ v ]; }) {} builds; versions = builtins.attrNames builds_per_version; versions_release = builtins.filter (x: builtins.match "v[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?" x != null) versions; versions_commit = builtins.filter (x: builtins.match "[0-9a-f]{40}" x != null) versions; versions_extra = lib.subtractLists (versions_release ++ versions_commit) versions; sorted_builds = [ { name = "Release"; hide = false; type = "tag"; description = "Release builds are the official builds, they are tailored for productions and are the most tested."; builds = builtins.sort (a: b: a.version > b.version) (map (x: { version = x; builds = builtins.getAttr x builds_per_version; }) versions_release); } { name = "Extra"; hide = true; type = "tag"; description = "Extra builds are built on demand to test a specific feature or a specific need."; builds = builtins.sort cmpDate (map (x: { version = x; builds = builtins.getAttr x builds_per_version; }) versions_extra); } { name = "Development"; hide = true; type = "commit"; description = "Development builds are built periodically. Use them if you want to test a specific feature that is not yet released."; builds = builtins.sort cmpDate (map (x: { version = x; builds = builtins.getAttr x builds_per_version; }) versions_commit); } ]; in pkgs.writeText "index.html" ''
${r.description}
${if r.hide then "See this build on
Binaries:
Sources:
'')) } ${ if builtins.length r.builds == 0 then "There is no build for this category" else "" } ${if r.hide then "