forked from lix-project/lix
950b46821f
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.
30 lines
981 B
Nix
30 lines
981 B
Nix
lockFileStr: rootSrc: rootSubdir:
|
|
|
|
let
|
|
|
|
lockFile = builtins.fromJSON lockFileStr;
|
|
|
|
allNodes =
|
|
builtins.mapAttrs
|
|
(key: node:
|
|
let
|
|
sourceInfo =
|
|
if key == lockFile.root
|
|
then rootSrc
|
|
else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]);
|
|
subdir = if key == lockFile.root then rootSubdir else node.locked.dir or "";
|
|
flake = import (sourceInfo + (if subdir != "" then "/" else "") + subdir + "/flake.nix");
|
|
inputs = builtins.mapAttrs (inputName: key: allNodes.${key}) (node.inputs or {});
|
|
outputs = flake.outputs (inputs // { self = result; });
|
|
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;
|
|
|
|
in allNodes.${lockFile.root}
|