Skip to content

Commit b7fb301

Browse files
committed
wip: lock format parser
1 parent 6afc88c commit b7fb301

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

atom-nix/core/importAtom.nix

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ let
5757
fetcher = nix.fetcher or "native"; # native doesn't exist yet
5858
conf = config.fetcher or { };
5959
f = conf.${fetcher} or { };
60-
root = f.root or "npins";
60+
fetchRoot = f.root or "npins";
6161
in
6262
if fetcher == "npins" then
6363
let
64-
pins = import (dirOf path + "/${root}");
64+
pins = import (dirOf path + "/${fetchRoot}");
6565
in
6666
mod.filterMap (
6767
k: v:
@@ -89,7 +89,34 @@ let
8989
) config.fetch or { }
9090
# else if fetcher = "native", etc
9191
else
92-
{ };
92+
let
93+
lockPath = "${root}/${src}.lock";
94+
lock = builtins.fromTOML (builtins.readFile lockPath);
95+
in
96+
if builtins.pathExists lockPath && lock.version == 1 then
97+
builtins.listToAttrs (
98+
map (dep: {
99+
inherit (dep) name;
100+
value =
101+
let
102+
path = "${root}/${dep.path}@.toml";
103+
in
104+
if dep ? version && dep ? path && builtins.pathExists path then
105+
(import ./importAtom.nix) { } path
106+
else if dep ? rev then
107+
let
108+
repo = builtins.fetchGit {
109+
inherit (dep) url rev;
110+
shallow = true;
111+
};
112+
in
113+
import repo
114+
else
115+
{ };
116+
}) lock.deps
117+
)
118+
else
119+
{ };
93120

94121
meta = atom.meta or { };
95122

atom-nix/core/mod.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ rec {
2626
stdFilter
2727
stdToml
2828
coreToml
29+
importAtom
2930
;
3031

3132
path = {

0 commit comments

Comments
 (0)