2020-03-12 21:06:57 +00:00
|
|
|
lockFileStr: rootSrc: rootSubdir:
|
2020-03-09 14:28:41 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2020-03-12 21:06:57 +00:00
|
|
|
lockFile = builtins.fromJSON lockFileStr;
|
2020-03-09 14:28:41 +00:00
|
|
|
|
2020-03-12 21:06:57 +00:00
|
|
|
allNodes =
|
|
|
|
builtins.mapAttrs
|
|
|
|
(key: node:
|
|
|
|
let
|
2020-06-11 12:40:21 +00:00
|
|
|
|
2020-04-02 17:04:33 +00:00
|
|
|
sourceInfo =
|
|
|
|
if key == lockFile.root
|
|
|
|
then rootSrc
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]);
|
2020-06-11 12:40:21 +00:00
|
|
|
|
2020-03-12 21:06:57 +00:00
|
|
|
subdir = if key == lockFile.root then rootSubdir else node.locked.dir or "";
|
2020-06-11 12:40:21 +00:00
|
|
|
|
2020-03-12 21:06:57 +00:00
|
|
|
flake = import (sourceInfo + (if subdir != "" then "/" else "") + subdir + "/flake.nix");
|
2020-06-11 12:40:21 +00:00
|
|
|
|
|
|
|
inputs = builtins.mapAttrs
|
|
|
|
(inputName: inputSpec: allNodes.${resolveInput inputSpec})
|
|
|
|
(node.inputs or {});
|
|
|
|
|
|
|
|
# Resolve a input spec into a node name. An input spec is
|
|
|
|
# either a node name, or a 'follows' path from the root
|
|
|
|
# node.
|
|
|
|
resolveInput = inputSpec:
|
|
|
|
if builtins.isList inputSpec
|
|
|
|
then getInputByPath lockFile.root inputSpec
|
|
|
|
else inputSpec;
|
|
|
|
|
|
|
|
# Follow an input path (e.g. ["dwarffs" "nixpkgs"]) from the
|
|
|
|
# root node, returning the final node.
|
|
|
|
getInputByPath = nodeName: path:
|
|
|
|
if path == []
|
|
|
|
then nodeName
|
|
|
|
else
|
|
|
|
getInputByPath
|
|
|
|
# Since this could be a 'follows' input, call resolveInput.
|
|
|
|
(resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path})
|
|
|
|
(builtins.tail path);
|
|
|
|
|
2020-03-12 21:06:57 +00:00
|
|
|
outputs = flake.outputs (inputs // { self = result; });
|
2020-06-11 12:40:21 +00:00
|
|
|
|
2020-03-12 21:06:57 +00:00
|
|
|
result = outputs // sourceInfo // { inherit inputs; inherit outputs; inherit sourceInfo; };
|
|
|
|
in
|
|
|
|
if node.flake or true then
|
|
|
|
assert builtins.isFunction flake.outputs;
|
|
|
|
result
|
|
|
|
else
|
|
|
|
sourceInfo
|
|
|
|
)
|
|
|
|
lockFile.nodes;
|
2020-03-09 14:28:41 +00:00
|
|
|
|
2020-03-12 21:06:57 +00:00
|
|
|
in allNodes.${lockFile.root}
|