-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
96 lines (81 loc) · 2.98 KB
/
Copy pathflake.nix
File metadata and controls
96 lines (81 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{
description = "Rusholme — a toy Haskell compiler in Zig";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
zig-overlay.url = "github:mitchellh/zig-overlay";
};
outputs = { self, nixpkgs, flake-utils, zig-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ zig-overlay.overlays.default ];
};
isDarwin = pkgs.stdenv.isDarwin;
# Shared toolchain used by both dev shells
zigToolchain = with pkgs; [
zigpkgs."0.16.0" # pinned stable release
llvmPackages_19.llvm # LLVM for future backend work
llvmPackages_19.lld # LLVM linker
];
websiteDevScript = pkgs.writeShellScriptBin "website-dev" ''
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
echo "Building Rusholme (zig build)..."
zig build
echo "Installing website dependencies..."
cd website
npm install --silent
echo "Building website (copies repl.wasm, fetches GitHub data)..."
npm run build
echo ""
echo "Serving website on http://localhost:3000"
npx serve .
'';
in
{
devShells = {
default = pkgs.mkShell {
name = "rusholme";
buildInputs = zigToolchain ++ (with pkgs; [
git
pre-commit
wasmtime
graalvmPackages.graalvm-ce # Provides lli for the JIT backend
replxx # C API line editor for the native REPL
hyperfine # Benchmark harness backend (scripts/bench.sh)
]) ++ pkgs.lib.optionals (!isDarwin) [
pkgs.valgrind
];
shellHook = ''
echo "🍛 Rusholme dev environment loaded"
echo " Zig: $(zig version)"
echo " LLVM: $(llvm-config --version)"
echo " Wasmtime: $(wasmtime --version 2>&1 | head -n1 || echo 'not found')"
echo " lli: $(lli --version 2>&1 | head -n1 || echo 'not found')"
echo ""
export REPLXX_PREFIX="${pkgs.replxx}"
'';
};
website = pkgs.mkShell {
name = "rusholme-website";
buildInputs = zigToolchain ++ (with pkgs; [
nodejs_22
git
]);
nativeBuildInputs = [ websiteDevScript ];
shellHook = ''
echo "🍛 Rusholme website dev environment loaded"
echo " Zig: $(zig version)"
echo " Node: $(node --version)"
echo ""
echo "Quick start: website-dev"
echo "Manual: zig build && cd website && npm run build && npx serve ."
echo ""
'';
};
};
}
);
}