From 0ab7b418a020c71adc2d3242e01f84b2d23dcabc Mon Sep 17 00:00:00 2001
From: li
Date: Wed, 18 Dec 2024 13:16:09 +0100
Subject: [PATCH 1/2] feat: implement minimal `use` scope for external deps
---
src/core/compose.nix | 6 +++++-
src/dev/shell.nix | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/core/compose.nix b/src/core/compose.nix
index 55b957d..2a149dc 100644
--- a/src/core/compose.nix
+++ b/src/core/compose.nix
@@ -134,6 +134,10 @@ let
_if = __isStd__;
std = l.removeAttrs (extern // atom) [ "std" ];
}
+ {
+ _if = !__isStd__;
+ use = l.removeAttrs extern [ "std" ];
+ }
{
_if = __internal__test;
# information about the internal module system itself
@@ -197,7 +201,7 @@ let
# Base case: no module
{ };
- atomScope = l.removeAttrs (extern // atom // { inherit extern; }) [
+ atomScope = l.removeAttrs atom [
"atom"
(baseNameOf par)
];
diff --git a/src/dev/shell.nix b/src/dev/shell.nix
index 8c77a8f..e22c625 100644
--- a/src/dev/shell.nix
+++ b/src/dev/shell.nix
@@ -1,5 +1,5 @@
{
- pkgs ? atom.pkgs,
+ pkgs ? use.pkgs,
}:
pkgs.mkShell {
packages = with pkgs; [
From bc7b55fae721793c612b12b04598746c7762bb3c Mon Sep 17 00:00:00 2001
From: li
Date: Thu, 19 Dec 2024 15:33:01 +0100
Subject: [PATCH 2/2] feat: added optional top-level `system`
---
src/core/compose.nix | 8 ++++++++
src/core/errors.nix | 2 +-
src/core/importAtom.nix | 8 +++++---
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/core/compose.nix b/src/core/compose.nix
index 2a149dc..f78fa12 100644
--- a/src/core/compose.nix
+++ b/src/core/compose.nix
@@ -56,11 +56,13 @@
let
l = builtins;
core = import ./mod.nix;
+
in
{
src,
root,
config,
+ system ? null,
extern ? { },
features ? [ ],
# internal features of the composer function
@@ -78,6 +80,8 @@ let
inherit __internal__test;
} (../. + "/std@.toml");
+ systemIsDefined = system != null;
+
coreFeatures' = core.features.resolve core.coreToml.features coreFeatures;
stdFeatures' = core.features.resolve core.stdToml.features stdFeatures;
@@ -134,6 +138,10 @@ let
_if = __isStd__;
std = l.removeAttrs (extern // atom) [ "std" ];
}
+ {
+ _if = !__isStd__ && systemIsDefined;
+ inherit system;
+ }
{
_if = !__isStd__;
use = l.removeAttrs extern [ "std" ];
diff --git a/src/core/errors.nix b/src/core/errors.nix
index b7e3f42..43e169a 100644
--- a/src/core/errors.nix
+++ b/src/core/errors.nix
@@ -44,7 +44,7 @@ in
modFromDir (stripParentDir par path);
import = abort "Importing arbitrary Nix files is forbidden. Declare your dependencies via the module system instead.";
fetch = abort "Ad hoc fetching is illegal. Declare dependencies statically in the manifest instead.";
- system = abort "Accessing the current system is impure. Declare supported systems in the manifest.";
+ system = abort "`system` has been accessed and is undefined";
time = _: warn "currentTime: Ignoring request for current time, returning: 0";
nixPath = _: warn "nixPath: ignoring impure NIX_PATH request, returning: []";
storePath = abort "Making explicit dependencies on store paths is illegal.";
diff --git a/src/core/importAtom.nix b/src/core/importAtom.nix
index f86ed6f..5c31907 100644
--- a/src/core/importAtom.nix
+++ b/src/core/importAtom.nix
@@ -16,6 +16,7 @@
valid input (and the CLI should type check on it's end)
*/
{
+ system ? null,
features ? null,
__internal__test ? false,
}:
@@ -96,11 +97,12 @@ let
in
mod.compose {
inherit
+ src
+ root
+ config
+ system
extern
__internal__test
- config
- root
- src
;
features = features';
coreFeatures =