-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic implementation with core features implemented, including isolation of Nix expressions to enforce module boundaries. One core feature still missing is private member semantics.
- Loading branch information
Showing
7 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
let | ||
fix = import ./std/fix.nix; | ||
filterMap = scopedImport { std = builtins; } ./std/set/filterMap.nix; | ||
parse = scopedImport { std = builtins; } ./std/file/parse.nix; | ||
compose = import ./.; | ||
|
||
filterMod = builtins.filterSource ( | ||
path: type: | ||
let | ||
file = parse (baseNameOf path); | ||
in | ||
type == "regular" && file.ext or null != "nix" | ||
); | ||
|
||
in | ||
dir: | ||
let | ||
atom = fix ( | ||
f: super: dir: | ||
let | ||
contents = builtins.readDir dir; | ||
self = | ||
let | ||
import' = scopedImport ( | ||
{ | ||
inherit atom; | ||
std = compose ./std // builtins; | ||
self = self // { | ||
outPath = filterMod dir; | ||
}; | ||
} | ||
// (if super != { } then { inherit super; } else { }) | ||
); | ||
mod = | ||
if contents ? "mod.nix" && contents."mod.nix" == "regular" then | ||
import' "${dir + "/mod.nix"}" | ||
else | ||
{ }; | ||
in | ||
filterMap ( | ||
name: type: | ||
let | ||
path = dir + "/${name}"; | ||
file = parse name; | ||
in | ||
if type == "directory" then | ||
{ ${name} = f self path; } | ||
else if type == "regular" && file.ext or null == "nix" && name != "mod.nix" then | ||
{ ${file.name} = import' "${path}"; } | ||
else | ||
null # Ignore other file types | ||
) contents | ||
// mod; | ||
in | ||
self | ||
) { } dir; | ||
in | ||
atom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
s: | ||
let | ||
r = std.match "([^.]+)\\.(.+)" s; | ||
in | ||
if r == null || std.length r < 2 then | ||
null | ||
else | ||
{ | ||
name = std.head r; | ||
ext = std.elemAt r 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
f: | ||
let | ||
x = f x; | ||
in | ||
x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
f: set: | ||
std.foldl' ( | ||
acc: key: | ||
let | ||
val = f key set.${key}; | ||
in | ||
if val == null || !std.isAttrs val then acc else acc // val | ||
) { } (std.attrNames set) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ } |