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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,22 @@ wrapper that skips gracefully if the tool isn't installed).
[BSD-3-Clause](LICENSE) for the port code (© 2026 Reuben Brooks). The vendored
Shen kernel under `kernel/` is © 2010–2022 Mark Tarver and retains its own
BSD-3-Clause license (`kernel/LICENSE.txt`).
## Optional Nix environment

Nix is optional; the normal shen-rust build and launcher commands continue to work
with tools installed by any method. For a pinned development toolchain:

```sh
nix develop
```

The flake also exports `packages.toolchain` for composition by
[Bifrost](https://github.com/pyrex41/bifrost):

```sh
nix shell .#toolchain
```

If direnv is installed, `direnv allow` opts this checkout into the same dev
shell automatically. Nothing activates until that explicit authorization, and
Nix is never required at runtime.
11 changes: 5 additions & 6 deletions crates/shen-rust/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,11 @@ fn register_core(interp: &mut Interp) {
))),
});
interp.register_native("string->n", 1, |_, args| match args[0].as_str() {
Some(s) => {
s.chars()
.next()
.map(|c| Value::int(c as i64))
.ok_or_else(|| ShenError::new("string->n: empty string"))
}
Some(s) => s
.chars()
.next()
.map(|c| Value::int(c as i64))
.ok_or_else(|| ShenError::new("string->n: empty string")),
None => Err(ShenError::new(format!(
"string->n: not a string: {:?}",
args[0]
Expand Down
14 changes: 11 additions & 3 deletions crates/shen-rust/tests/boot_kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ fn shen_batteries_features_query_reports_sha_host() {
let value = eval(&mut interp, "(shen.x.features.current)");
let pure = std::env::var("SHEN_X_SHA256").ok().as_deref() == Some("pure");
if pure {
assert!(value.is_nil(), "pure SHA mode must advertise no host feature: {value:?}");
assert!(
value.is_nil(),
"pure SHA mode must advertise no host feature: {value:?}"
);
} else {
let feature = value
.head()
Expand All @@ -108,8 +111,13 @@ fn shen_batteries_features_query_reports_sha_host() {
let sym = interp.intern("shen.x.features.current");
let direct = interp.get_aot_direct(sym).expect("AOT feature query");
let direct_value = direct(&mut interp, &[]).expect("feature query succeeds");
assert_eq!(direct_value.head().and_then(|v| v.as_sym()).map(|s| interp.resolve(s).to_string()),
Some("shen.x/sha256-host".to_string()));
assert_eq!(
direct_value
.head()
.and_then(|v| v.as_sym())
.map(|s| interp.resolve(s).to_string()),
Some("shen.x/sha256-host".to_string())
);
}
}

Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 15 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
tools = [
pkgs.rustc
pkgs.cargo
pkgs.rustfmt
pkgs.clippy
pkgs.rust-analyzer
pkgs.pkg-config
];
in {
packages.toolchain = pkgs.buildEnv {
name = "shen-rust-toolchain";
paths = tools;
};
packages.default = self.packages.${system}.toolchain;

devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.rustc
pkgs.cargo
pkgs.rustfmt
pkgs.clippy
pkgs.rust-analyzer
pkgs.pkg-config
];
packages = tools;

shellHook = ''
echo "shen-rust dev shell"
Expand Down