1# This file has been generated by Niv.
6 # The fetchers. fetch_<type> fetches specs of type <type>.
9 fetch_file = pkgs: spec:
10 if spec.builtin or true then
11 builtins_fetchurl { inherit (spec) url sha256; }
13 pkgs.fetchurl { inherit (spec) url sha256; };
15 fetch_tarball = pkgs: spec:
16 if spec.builtin or true then
17 builtins_fetchTarball { inherit (spec) url sha256; }
19 pkgs.fetchzip { inherit (spec) url sha256; };
21 fetch_git = pkgs: spec:
22 pkgs.fetchgit { url = spec.repo; inherit (spec) rev deepClone sha256; };
24 fetch_builtin-tarball = spec:
28 The niv type "builtin-tarball" will soon be deprecated. You should
29 instead use `builtin = true`.
31 $ niv modify <package> -a type=tarball -a builtin=true
33 builtins_fetchTarball { inherit (spec) url sha256; };
35 fetch_builtin-url = spec:
39 The niv type "builtin-url" will soon be deprecated. You should
40 instead use `builtin = true`.
42 $ niv modify <package> -a type=file -a builtin=true
44 (builtins_fetchurl { inherit (spec) url sha256; });
50 # The set of packages used when specs are fetched using non-builtins.
54 import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
55 hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
56 hasThisAsNixpkgsPath = <nixpkgs> == ./.;
58 if builtins.hasAttr "nixpkgs" sources
60 else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
65 Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
66 add a package called "nixpkgs" to your sources.json.
69 # The actual fetching function.
70 fetch = pkgs: name: spec:
72 if ! builtins.hasAttr "type" spec then
73 abort "ERROR: niv spec ${name} does not have a 'type' attribute"
74 else if spec.type == "file" then fetch_file pkgs spec
75 else if spec.type == "tarball" then fetch_tarball pkgs spec
76 else if spec.type == "git" then fetch_git pkgs spec
77 else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
78 else if spec.type == "builtin-url" then fetch_builtin-url spec
80 abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
82 # Ports of functions for older nix versions
84 # a Nix version of mapAttrs if the built-in doesn't exist
85 mapAttrs = builtins.mapAttrs or (
86 f: set: with builtins;
87 listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
90 # fetchTarball version that is compatible between all the versions of Nix
91 builtins_fetchTarball = { url, sha256 }@attrs:
93 inherit (builtins) lessThan nixVersion fetchTarball;
95 if lessThan nixVersion "1.12" then
96 fetchTarball { inherit url; }
100 # fetchurl version that is compatible between all the versions of Nix
101 builtins_fetchurl = { url, sha256 }@attrs:
103 inherit (builtins) lessThan nixVersion fetchurl;
105 if lessThan nixVersion "1.12" then
106 fetchurl { inherit url; }
110 # Create the final "sources" from the config
114 if builtins.hasAttr "outPath" spec
116 "The values in sources.json should not have an 'outPath' attribute"
118 spec // { outPath = fetch config.pkgs name spec; }
121 # The "config" used by the fetchers
123 { sourcesFile ? ./sources.json
124 , sources ? builtins.fromJSON (builtins.readFile sourcesFile)
125 , pkgs ? mkPkgs sources
127 # The sources, i.e. the attribute set of spec name to spec
130 # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
134mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list