Reformat niv sources
This commit is contained in:
parent
3d7c3f75d3
commit
7105db994f
1 changed files with 53 additions and 46 deletions
|
@ -1,37 +1,44 @@
|
||||||
# This file has been generated by Niv.
|
# This file has been generated by Niv.
|
||||||
|
|
||||||
# A record, from name to path, of the third-party packages
|
# A record, from name to path, of the third-party packages
|
||||||
with rec {
|
with rec
|
||||||
pkgs = if hasNixpkgsPath then
|
{
|
||||||
if hasThisAsNixpkgsPath then
|
pkgs =
|
||||||
import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; })
|
if hasNixpkgsPath
|
||||||
{ }
|
then
|
||||||
|
if hasThisAsNixpkgsPath
|
||||||
|
then import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {}
|
||||||
|
else import <nixpkgs> {}
|
||||||
else
|
else
|
||||||
import <nixpkgs> { }
|
import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {};
|
||||||
else
|
|
||||||
import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; })
|
|
||||||
{ };
|
|
||||||
|
|
||||||
sources_nixpkgs = if builtins.hasAttr "nixpkgs" sources then
|
sources_nixpkgs =
|
||||||
sources.nixpkgs
|
if builtins.hasAttr "nixpkgs" sources
|
||||||
else
|
then sources.nixpkgs
|
||||||
abort ''
|
else abort
|
||||||
|
''
|
||||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||||
add a package called "nixpkgs" to your sources.json.
|
add a package called "nixpkgs" to your sources.json.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# fetchTarball version that is compatible between all the versions of Nix
|
# fetchTarball version that is compatible between all the versions of Nix
|
||||||
builtins_fetchTarball = { url, sha256 }@attrs:
|
builtins_fetchTarball =
|
||||||
let inherit (builtins) lessThan nixVersion fetchTarball;
|
{ url, sha256 }@attrs:
|
||||||
in if lessThan nixVersion "1.12" then
|
let
|
||||||
|
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||||
|
in
|
||||||
|
if lessThan nixVersion "1.12" then
|
||||||
fetchTarball { inherit url; }
|
fetchTarball { inherit url; }
|
||||||
else
|
else
|
||||||
fetchTarball attrs;
|
fetchTarball attrs;
|
||||||
|
|
||||||
# fetchurl version that is compatible between all the versions of Nix
|
# fetchurl version that is compatible between all the versions of Nix
|
||||||
builtins_fetchurl = { url, sha256 }@attrs:
|
builtins_fetchurl =
|
||||||
let inherit (builtins) lessThan nixVersion fetchurl;
|
{ url, sha256 }@attrs:
|
||||||
in if lessThan nixVersion "1.12" then
|
let
|
||||||
|
inherit (builtins) lessThan nixVersion fetchurl;
|
||||||
|
in
|
||||||
|
if lessThan nixVersion "1.12" then
|
||||||
fetchurl { inherit url; }
|
fetchurl { inherit url; }
|
||||||
else
|
else
|
||||||
fetchurl attrs;
|
fetchurl attrs;
|
||||||
|
@ -41,17 +48,14 @@ with rec {
|
||||||
fetchzip = { url, sha256 }@attrs: pkgs.fetchzip attrs;
|
fetchzip = { url, sha256 }@attrs: pkgs.fetchzip attrs;
|
||||||
|
|
||||||
hasNixpkgsPath = (builtins.tryEval <nixpkgs>).success;
|
hasNixpkgsPath = (builtins.tryEval <nixpkgs>).success;
|
||||||
hasThisAsNixpkgsPath = (builtins.tryEval <nixpkgs>).success && <nixpkgs>
|
hasThisAsNixpkgsPath =
|
||||||
== ./.;
|
(builtins.tryEval <nixpkgs>).success && <nixpkgs> == ./.;
|
||||||
|
|
||||||
sources = builtins.fromJSON (builtins.readFile ./sources.json);
|
sources = builtins.fromJSON (builtins.readFile ./sources.json);
|
||||||
|
|
||||||
mapAttrs = builtins.mapAttrs or (f: set:
|
mapAttrs = builtins.mapAttrs or
|
||||||
with builtins;
|
(f: set: with builtins;
|
||||||
listToAttrs (map (attr: {
|
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)));
|
||||||
name = attr;
|
|
||||||
value = f attr set.${attr};
|
|
||||||
}) (attrNames set)));
|
|
||||||
|
|
||||||
# borrowed from nixpkgs
|
# borrowed from nixpkgs
|
||||||
functionArgs = f: f.__functionArgs or (builtins.functionArgs f);
|
functionArgs = f: f.__functionArgs or (builtins.functionArgs f);
|
||||||
|
@ -60,11 +64,10 @@ with rec {
|
||||||
in f (auto // args);
|
in f (auto // args);
|
||||||
|
|
||||||
getFetcher = spec:
|
getFetcher = spec:
|
||||||
let
|
let fetcherName =
|
||||||
fetcherName = if builtins.hasAttr "type" spec then
|
if builtins.hasAttr "type" spec
|
||||||
builtins.getAttr "type" spec
|
then builtins.getAttr "type" spec
|
||||||
else
|
else "builtin-tarball";
|
||||||
"builtin-tarball";
|
|
||||||
in builtins.getAttr fetcherName {
|
in builtins.getAttr fetcherName {
|
||||||
"tarball" = fetchzip;
|
"tarball" = fetchzip;
|
||||||
"builtin-tarball" = builtins_fetchTarball;
|
"builtin-tarball" = builtins_fetchTarball;
|
||||||
|
@ -74,9 +77,13 @@ with rec {
|
||||||
};
|
};
|
||||||
# NOTE: spec must _not_ have an "outPath" attribute
|
# NOTE: spec must _not_ have an "outPath" attribute
|
||||||
mapAttrs (_: spec:
|
mapAttrs (_: spec:
|
||||||
if builtins.hasAttr "outPath" spec then
|
if builtins.hasAttr "outPath" spec
|
||||||
abort "The values in sources.json should not have an 'outPath' attribute"
|
then abort
|
||||||
else if builtins.hasAttr "url" spec && builtins.hasAttr "sha256" spec then
|
"The values in sources.json should not have an 'outPath' attribute"
|
||||||
spec // { outPath = callFunctionWith spec (getFetcher spec) { }; }
|
else
|
||||||
else
|
if builtins.hasAttr "url" spec && builtins.hasAttr "sha256" spec
|
||||||
spec) sources
|
then
|
||||||
|
spec //
|
||||||
|
{ outPath = callFunctionWith spec (getFetcher spec) { }; }
|
||||||
|
else spec
|
||||||
|
) sources
|
||||||
|
|
Loading…
Reference in a new issue