Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ff4124d
Initial bindings/examples for writing Nix functions in Rust
edolstra Sep 17, 2025
fcc2a0c
Split the crate
edolstra Sep 29, 2025
71b1cc0
Add tests
edolstra Sep 29, 2025
0cf3b4d
Enable GitHub CI
edolstra Sep 29, 2025
e304040
Don't call copy_list unnecessarily
edolstra Sep 30, 2025
169780f
Add another test
edolstra Sep 30, 2025
29958b1
flake.lock: Update
edolstra Sep 30, 2025
f61717e
flake.lock: Update
edolstra Dec 20, 2025
791ff64
Add mandelbrot example
edolstra Dec 20, 2025
6c1e729
Use num::complex
edolstra Dec 20, 2025
4168b4a
Use dynamic allocation
edolstra Dec 20, 2025
6fd374c
Use RGB colors
edolstra Dec 20, 2025
5d76948
Smooth interpolation
edolstra Dec 20, 2025
042000b
get_attrset(): Handle empty attrsets
edolstra Dec 20, 2025
d4db705
Make width configurable
edolstra Dec 20, 2025
156e231
Switch wasm branch to nix-src
edolstra Dec 25, 2025
02c6bc1
Use determinate-nix-action
edolstra Dec 25, 2025
bf8b902
Remove unnecessary stuff
edolstra Dec 25, 2025
a7e1e26
Apply coderabbit comments
edolstra Dec 25, 2025
31ce026
flake.lock: Update
edolstra Dec 25, 2025
e8526c6
Use parallel eval
edolstra Dec 25, 2025
780cc70
Apply coderabbit comments
edolstra Dec 25, 2025
5c1fdfd
Add Mandelbrot test
edolstra Dec 25, 2025
acf4fd4
flake.lock: Update
edolstra Dec 29, 2025
07e7278
flake.lock: Update
edolstra Dec 31, 2025
c55d922
Host interface update
edolstra Dec 31, 2025
99acaa0
Add a test of function application
edolstra Dec 31, 2025
0dade6c
flake.lock: Update
edolstra Dec 31, 2025
0816e5e
Add panic handler
edolstra Jan 1, 2026
e288213
flake.lock: Update
edolstra Jan 1, 2026
dec1ec0
Cleanup
edolstra Jan 1, 2026
3d508af
Performance test
edolstra Jan 1, 2026
654f48e
Make the call test bigger
edolstra Jan 4, 2026
d54ca7a
Test that multiple calls to a WASM function are pure
edolstra Jan 4, 2026
004bf00
flake.lock: Update
edolstra Jan 4, 2026
6e88a7f
Add README
edolstra Jan 5, 2026
3f922df
Run CI on macOS
edolstra Jan 5, 2026
7ce6734
flake.lock: Update
edolstra Jan 6, 2026
b203fe6
flake.lock: Update
edolstra Jan 19, 2026
828461c
Enable wasm-builtin experimental feature
edolstra Jan 19, 2026
76c5f06
Turn warn() into a macro
edolstra Jan 19, 2026
4a239f7
Rename map -> strictMap
edolstra Jan 19, 2026
715eaa1
Add ability to create lazy function applications
edolstra Jan 19, 2026
03d511b
flake.lock: Update
edolstra Jan 19, 2026
12681c3
Tweak optimization settings
edolstra Jan 19, 2026
7321375
Add path primitives
edolstra Jan 19, 2026
96fadda
Add a grep function
edolstra Jan 19, 2026
5919ec6
flake.lock: Update
edolstra Jan 19, 2026
9da88f0
Use get_attr host function
edolstra Jan 20, 2026
7c95461
WASM -> Wasm
edolstra Jan 20, 2026
63a1f51
flake.lock: Update
edolstra Jan 20, 2026
92b2443
Apply suggestions from code review
edolstra Jan 21, 2026
bff5988
Enable parallel eval
edolstra Jan 21, 2026
cd2a1fb
flake.lock: Update
edolstra Jan 21, 2026
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
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "CI"

on:
pull_request:
push:
branches:
- main

permissions:
id-token: "write"
contents: "read"
pull-requests: "write"

jobs:
ci:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: git checkout
uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/determinate-nix-action@main

- name: Set up FlakeHub Cache
uses: DeterminateSystems/flakehub-cache-action@main

- name: Build and test
run: |
nix flake check --all-systems --eval-cores 0 -L
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.wasm
result
/target/
*~
/*/tests/*.out
25 changes: 25 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cargo",
"command": "build",
"args": [
"--release"
],
"options": {
"env": {
"CARGO_BUILD_TARGET": "wasm32-unknown-unknown"
}
},
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
},
"label": "rust: cargo build"
}
]
}
286 changes: 286 additions & 0 deletions Cargo.lock

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

16 changes: 16 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[workspace]
members = [
"nix-wasm-rust",
"nix-wasm-plugin-fib",
"nix-wasm-plugin-ini",
"nix-wasm-plugin-yaml",
"nix-wasm-plugin-mandelbrot",
"nix-wasm-plugin-test",
"nix-wasm-plugin-grep",
]
resolver = "2"

[profile.release]
lto = true
opt-level = 'z'
strip = true
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# `nix-wasm-rust`

This crate helps you to write functions in Rust that can be executed by Nix at evaluation time using `builtins.wasm`. This repository also contains a number of tests and demos.

To try it out:

```console
# nix shell .#nix # to get a version of Nix that has `builtins.wasm`

# nix build # to build the Wasm functions

# ls -l ./result/
-r--r--r-- 3 root root 17396 Jan 1 1970 nix_wasm_plugin_fib.wasm
-r--r--r-- 3 root root 64292 Jan 1 1970 nix_wasm_plugin_ini.wasm
-r--r--r-- 3 root root 33277 Jan 1 1970 nix_wasm_plugin_mandelbrot.wasm
-r--r--r-- 3 root root 29635 Jan 1 1970 nix_wasm_plugin_test.wasm
-r--r--r-- 3 root root 205035 Jan 1 1970 nix_wasm_plugin_yaml.wasm

# nix eval --impure --expr 'builtins.wasm ./result/nix_wasm_plugin_fib.wasm "fib" 40'
warning: '/nix/store/1c9yg0mv…-nix-wasm-rust-0.1.0/nix_wasm_plugin_fib.wasm' function 'fib': greetings from Wasm!
165580141

# nix eval --raw --impure --expr 'builtins.wasm ./result/nix_wasm_plugin_mandelbrot.wasm "mandelbrot" { width = 150; }'
```
Loading