Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
files=(shell.nix src/dev/shell.nix)
files=(shell.nix atom-nix/dev/shell.nix)

watch_file "${files[@]}"

Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@ jobs:
- uses: nixbuild/nix-quick-install-action@v28
- name: Code Format Check
run: eval "$(nix print-dev-env -f shell.nix)" && treefmt --fail-on-change
std-config:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nixbuild/nix-quick-install-action@v28
- name: Std Library Config Test
run: cd test/std-import && ./import.sh > /dev/null
features:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nixbuild/nix-quick-install-action@v28
- name: Feature Parsing Test
run: cd test/features && ./resolve.sh > /dev/null
purity:
runs-on: ubuntu-latest
steps:
Expand Down
9 changes: 1 addition & 8 deletions atom-nix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ name = "dev"
version = "0.1.0"
description = "Development environment"

[features]
default = []

[fetch.pkgs]
name = "nixpkgs"
import = true
Expand All @@ -128,11 +125,7 @@ let
atom = builtins.fetchGit "https://github.com/ekala-project/atom";
importAtom = import "${atom}/atom-nix/core/importAtom.nix";
in
importAtom {
features = [
# enabled flags
];
} ./atom-nix/dev.toml
importAtom { } ./atom-nix/dev.toml
```

## Future Directions: Ekala Platform
Expand Down
4 changes: 0 additions & 4 deletions atom-nix/core@.toml → atom-nix/core/atom.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@
id = "core"
version = "0.3.0"
description = "A purpose built, unopinionated, and performant module system for Nix code."

[features]
std = []
default = ["std"]
64 changes: 21 additions & 43 deletions atom-nix/core/compose.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,23 @@ let
l = builtins;
core = import ./mod.nix;
in
root:
{
src,
root,
config,
extern ? { },
features ? [ ],
# internal features of the composer function
stdFeatures ? core.stdToml.features.default or [ ],
coreFeatures ? core.coreToml.features.default,
# enable testing code paths
__internal__test ? false,
__isStd__ ? false,
}:
let
par = (root + "/${src}");
par = core.prepDir root;

std = core.importStd {
features = stdFeatures;
inherit __internal__test;
} (../. + "/std@.toml");

coreFeatures' = core.features.resolve core.coreToml.features coreFeatures;
stdFeatures' = core.features.resolve core.stdToml.features stdFeatures;

cfg = config // {
features = config.features or { } // {
resolved = {
atom = features;
core = coreFeatures';
std = stdFeatures';
};
};
};

cfg = config;

msg = core.errors.debugMsg config;

f =
Expand All @@ -105,31 +88,30 @@ let

scope =
let
scope' = with core; {
inherit cfg;
mod = modScope;
builtins = std;
import = errors.import;
scopedImport = errors.import;
__fetchurl = errors.fetch;
__currentSystem = errors.system;
__currentTime = errors.time 0;
__nixPath = errors.nixPath [ ];
__storePath = errors.storePath;
__getEnv = errors.getEnv "";
__getFlake = errors.import;
get = extern;
};
scope' =
with core;
{
inherit cfg;
mod = modScope;
builtins = std;
import = errors.import;
scopedImport = errors.import;
__fetchurl = errors.fetch;
__currentSystem = errors.system;
__currentTime = errors.time 0;
__nixPath = errors.nixPath [ ];
__storePath = errors.storePath;
__getEnv = errors.getEnv "";
__getFlake = errors.import;
}
// extern;

scope'' = core.set.inject scope' [
preOpt
{
_if = !__isStd__;
atom = atomScope;
_else.std = atomScope;
}
{
_if = !__isStd__ && l.elem "std" coreFeatures';
inherit std;
}
{
Expand Down Expand Up @@ -206,10 +188,6 @@ let
in
core.set.inject fixed [
({ _if = __isStd__; } // core.pureBuiltinsForStd fixed)
{
_if = __isStd__ && l.elem "lib" cfg.features.resolved.atom;
inherit (extern) lib;
}
{
_if = __isStd__ && __internal__test;
__internal = {
Expand Down
65 changes: 0 additions & 65 deletions atom-nix/core/features.nix

This file was deleted.

87 changes: 6 additions & 81 deletions atom-nix/core/importAtom.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,103 +16,28 @@
valid input (and the CLI should type check on it's end)
*/
{
features ? null,
remoteUrl ? null,
__internal__test ? false,

}:
path':
root':
let
mod = import ./mod.nix;

path = mod.prepDir path';
root = mod.prepDir root';

file = builtins.readFile path;
file = builtins.readFile (root + "/atom.toml");
config = builtins.fromTOML file;
atom = config.atom or { };
id = builtins.seq version (atom.id or (mod.errors.missingAtom path' "id"));
version = atom.version or (mod.errors.missingAtom path' "version");

core = config.core or { };
std = config.std or { };

features' =
let
featSet = config.features or { };
featIn = if features == null then featSet.default or [ ] else features;
in
mod.features.resolve featSet featIn;

backend = config.backend or { };
nix = backend.nix or { };

root = mod.prepDir (dirOf path);
src = builtins.seq id (
let
file = mod.parse (baseNameOf path);
len = builtins.stringLength file.name;
in
builtins.substring 0 (len - 1) file.name
);
extern =
let
fetcher = nix.fetcher or "native"; # native doesn't exist yet
conf = config.fetcher or { };
f = conf.${fetcher} or { };
root = f.root or "npins";
in
if fetcher == "npins" then
let
pins = import (dirOf path + "/${root}");
in
mod.filterMap (
k: v:
let
src = "${pins.${v.name or k}}/${v.subdir or ""}";
val =
if v.import or false then
if v.args or [ ] != [ ] then
builtins.foldl' (
f: x:
let
intersect = x // (builtins.intersectAttrs x extern);
in
if builtins.isAttrs x then f intersect else f x
) (import src) v.args
else
import src
else
src;
in
if (v.optional or false && builtins.elem k features') || (!v.optional or false) then
{ "${k}" = val; }
else
null
) config.fetch or { }
# else if fetcher = "native", etc
else
{ };

meta = atom.meta or { };

in
mod.compose {
mod.compose root {
inherit
extern
__internal__test
config
root
src
;
features = features';
coreFeatures =
let
feat = core.features or mod.coreToml.features.default;
in
mod.features.resolve mod.coreToml.features feat;
stdFeatures =
let
feat = std.features or mod.stdToml.features.default;
in
mod.features.resolve mod.stdToml.features feat;

__isStd__ = meta.__is_std__ or false;
}
14 changes: 9 additions & 5 deletions atom-nix/core/mod.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ let
std = builtins;
mod = scopedImport { inherit mod std; } ../std/string/mod.nix;
} ../std/string/toLowerCase.nix;
stdToml = l.fromTOML (l.readFile (../. + "/std@.toml"));
coreToml = l.fromTOML (l.readFile (../. + "/core@.toml"));
stdToml = l.fromTOML (l.readFile (../std/atom.toml));
coreToml = l.fromTOML (l.readFile (../core/atom.toml));
in
rec {
inherit
Expand All @@ -32,6 +32,7 @@ rec {
stdFilter
stdToml
coreToml
importAtom
;

path = {
Expand All @@ -49,8 +50,6 @@ rec {

errors = import ./errors.nix;

features = import ./features.nix;

lowerKeys = filterMap (k: v: { ${toLowerCase k} = v; });

collectPublic = filterMap (
Expand Down Expand Up @@ -78,7 +77,12 @@ rec {
);
};

importStd = opts: importAtom { inherit (opts) __internal__test features; };
importStd =
opts:
compose ../std {
inherit (opts) __internal__test;
__isStd__ = true;
};

modIsValid =
mod: dir:
Expand Down
7 changes: 7 additions & 0 deletions atom-nix/dev/atom.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version = 1

[[deps]]
name = "nixpkgs"
url = "https://github.com/NixOS/nixpkgs/archive/c2ae88e026f9525daf89587f3cbee584b92b6134.tar.gz"
type = "pin+tar"
checksum = "sha256:1fsnvjvg7z2nvs876ig43f8z6cbhhma72cbxczs30ld0cqgy5dks"
3 changes: 3 additions & 0 deletions atom-nix/dev/atom.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[atom]
id = "dev"
version = "0.2.0"
5 changes: 4 additions & 1 deletion atom-nix/dev/mod.nix
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{ Shell = mod.shell; }
{
pkgs = from.nixpkgs { };
Shell = mod.shell;
}
Loading
Loading