lib: let inherit (builtins) splitVersion head fromJSON readFile mapAttrs map listToAttrs foldl' attrNames; inherit (lib) unique; ncVersions = ["29" "30" "31"]; getMajorVersion = version: head (splitVersion version); readJSON = path: fromJSON (readFile path); getVersionData = data: { inherit (data) url version; sha256 = data.hash; }; getByNcVersion = ncVersion: mapAttrs (app: data: {"${getMajorVersion data.version}" = getVersionData data;}) (readJSON ./${ncVersion}.json); byNcVersion = map getByNcVersion ncVersions; mergeVersions = a: b: let allApps = unique (attrNames a ++ attrNames b); mergeApp = app: (a.${app} or {}) // (b.${app} or {}); in listToAttrs (map (app: { name = app; value = mergeApp app; }) allApps); in foldl' (acc: apps: mergeVersions acc apps) {} byNcVersion