2019-04-07 20:56:40 +03:00
|
|
|
# This file has been generated by Niv.
|
|
|
|
|
2019-01-31 21:05:00 +03:00
|
|
|
# A record, from name to path, of the third-party packages
|
2019-04-07 20:56:40 +03:00
|
|
|
with rec
|
2019-01-31 21:05:00 +03:00
|
|
|
{
|
2019-04-07 20:56:40 +03:00
|
|
|
pkgs =
|
|
|
|
if hasNixpkgsPath
|
|
|
|
then
|
|
|
|
if hasThisAsNixpkgsPath
|
2019-04-11 00:10:46 +03:00
|
|
|
then import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {}
|
2019-04-07 20:56:40 +03:00
|
|
|
else import <nixpkgs> {}
|
|
|
|
else
|
2019-04-11 00:10:46 +03:00
|
|
|
import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {};
|
2019-04-07 20:56:40 +03:00
|
|
|
|
|
|
|
sources_nixpkgs =
|
|
|
|
if builtins.hasAttr "nixpkgs" sources
|
|
|
|
then sources.nixpkgs
|
|
|
|
else abort
|
|
|
|
''
|
|
|
|
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
|
|
|
add a package called "nixpkgs" to your sources.json.
|
|
|
|
'';
|
|
|
|
|
2019-05-23 22:36:18 +03:00
|
|
|
# fetchTarball version that is compatible between all the versions of Nix
|
2019-04-07 20:56:40 +03:00
|
|
|
builtins_fetchTarball =
|
|
|
|
{ url, sha256 }@attrs:
|
|
|
|
let
|
|
|
|
inherit (builtins) lessThan nixVersion fetchTarball;
|
|
|
|
in
|
|
|
|
if lessThan nixVersion "1.12" then
|
|
|
|
fetchTarball { inherit url; }
|
|
|
|
else
|
|
|
|
fetchTarball attrs;
|
|
|
|
|
2019-05-23 22:36:18 +03:00
|
|
|
# fetchurl version that is compatible between all the versions of Nix
|
|
|
|
builtins_fetchurl =
|
|
|
|
{ url, sha256 }@attrs:
|
|
|
|
let
|
|
|
|
inherit (builtins) lessThan nixVersion fetchurl;
|
|
|
|
in
|
|
|
|
if lessThan nixVersion "1.12" then
|
|
|
|
fetchurl { inherit url; }
|
|
|
|
else
|
|
|
|
fetchurl attrs;
|
|
|
|
|
|
|
|
# A wrapper around pkgs.fetchzip that has inspectable arguments,
|
|
|
|
# annoyingly this means we have to specify them
|
|
|
|
fetchzip = { url, sha256 }@attrs: pkgs.fetchzip attrs;
|
|
|
|
|
2019-04-07 20:56:40 +03:00
|
|
|
hasNixpkgsPath = (builtins.tryEval <nixpkgs>).success;
|
|
|
|
hasThisAsNixpkgsPath =
|
|
|
|
(builtins.tryEval <nixpkgs>).success && <nixpkgs> == ./.;
|
|
|
|
|
2019-02-07 16:14:47 +03:00
|
|
|
sources = builtins.fromJSON (builtins.readFile ./sources.json);
|
2019-01-31 21:05:00 +03:00
|
|
|
|
2019-02-01 17:51:40 +03:00
|
|
|
mapAttrs = builtins.mapAttrs or
|
|
|
|
(f: set: with builtins;
|
|
|
|
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)));
|
2019-01-31 21:05:00 +03:00
|
|
|
|
2019-05-23 22:36:18 +03:00
|
|
|
# borrowed from nixpkgs
|
|
|
|
functionArgs = f: f.__functionArgs or (builtins.functionArgs f);
|
|
|
|
callFunctionWith = autoArgs: f: args:
|
|
|
|
let auto = builtins.intersectAttrs (functionArgs f) autoArgs;
|
|
|
|
in f (auto // args);
|
|
|
|
|
2019-04-07 20:56:40 +03:00
|
|
|
getFetcher = spec:
|
|
|
|
let fetcherName =
|
|
|
|
if builtins.hasAttr "type" spec
|
|
|
|
then builtins.getAttr "type" spec
|
2019-05-23 22:36:39 +03:00
|
|
|
else "builtin-tarball";
|
2019-04-07 20:56:40 +03:00
|
|
|
in builtins.getAttr fetcherName {
|
2019-05-23 22:36:18 +03:00
|
|
|
"tarball" = fetchzip;
|
|
|
|
"builtin-tarball" = builtins_fetchTarball;
|
2019-04-07 20:56:40 +03:00
|
|
|
"file" = pkgs.fetchurl;
|
2019-05-23 22:36:18 +03:00
|
|
|
"builtin-url" = builtins_fetchurl;
|
2019-04-07 20:56:40 +03:00
|
|
|
};
|
|
|
|
};
|
2019-01-31 21:05:00 +03:00
|
|
|
# NOTE: spec must _not_ have an "outPath" attribute
|
2019-02-01 17:51:40 +03:00
|
|
|
mapAttrs (_: spec:
|
2019-01-31 21:05:00 +03:00
|
|
|
if builtins.hasAttr "outPath" spec
|
|
|
|
then abort
|
2019-02-07 16:14:47 +03:00
|
|
|
"The values in sources.json should not have an 'outPath' attribute"
|
2019-01-31 21:05:00 +03:00
|
|
|
else
|
|
|
|
if builtins.hasAttr "url" spec && builtins.hasAttr "sha256" spec
|
|
|
|
then
|
|
|
|
spec //
|
2019-05-23 22:36:18 +03:00
|
|
|
{ outPath = callFunctionWith spec (getFetcher spec) { }; }
|
2019-01-31 21:05:00 +03:00
|
|
|
else spec
|
2019-02-07 16:14:47 +03:00
|
|
|
) sources
|