1
1
mirror of https://github.com/nmattia/snack.git synced 2024-09-19 07:37:33 +03:00
snack/nix/fetch.nix
2019-01-18 10:39:40 +01:00

27 lines
812 B
Nix

# A record, from name to path, of the third-party packages
let
versions = builtins.fromJSON (builtins.readFile ./versions.json);
fetchTarball =
# fetchTarball version that is compatible between all the versions of
# Nix
{ url, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball { inherit url; }
else
fetchTarball attrs;
mapAttrs = builtins.mapAttrs or
(f: set: with builtins;
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)));
in
mapAttrs (_: spec:
fetchTarball {
url =
with spec;
"https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = spec.sha256;
}
) versions