From 731a8889d77c5325e33e13ea4fcd45ec1a931f85 Mon Sep 17 00:00:00 2001 From: Ralf Anton Beier Date: Sat, 28 Mar 2026 09:03:17 +0100 Subject: [PATCH] feat: add Nix flake for reproducible development environment (#54) Provides devShell with: Rust 1.93.1 stable + wasm32-wasip2 target (via rust-overlay, matching org convention from meld/synth/sigil), Z3 (with Z3_SYS_Z3_HEADER auto-set), wasmtime, binaryen. Usage: nix develop Closes #54 Co-Authored-By: Claude Opus 4.6 (1M context) --- flake.nix | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6597aa2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,76 @@ +{ + description = "LOOM - provably correct WebAssembly optimizer"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; + + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils }: + flake-utils.lib.eachSystem [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ] (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + + # Rust stable with wasm32-wasip2 target + rustToolchain = pkgs.rust-bin.stable."1.93.1".default.override { + extensions = [ + "rust-src" + "rust-analyzer" + "clippy" + "rustfmt" + ]; + targets = [ "wasm32-wasip2" ]; + }; + + # Z3 paths for the z3-sys crate build + z3Header = "${pkgs.z3.dev}/include/z3.h"; + z3LibPath = "${pkgs.z3.lib}/lib"; + in + { + devShells.default = pkgs.mkShell { + buildInputs = [ + rustToolchain + + # Z3 SMT solver (for --features verification) + pkgs.z3 + + # WebAssembly tooling + pkgs.wasmtime + pkgs.binaryen + + pkgs.pkg-config + ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ + pkgs.darwin.apple_sdk.frameworks.Security + pkgs.darwin.apple_sdk.frameworks.SystemConfiguration + pkgs.libiconv + ]; + + env = { + Z3_SYS_Z3_HEADER = z3Header; + LIBRARY_PATH = z3LibPath; + LD_LIBRARY_PATH = z3LibPath; + RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library"; + }; + + shellHook = '' + echo "loom dev shell" + echo " rust: $(rustc --version)" + echo " z3: ${pkgs.z3.version}" + echo " wasmtime: $(wasmtime --version 2>/dev/null)" + ''; + }; + } + ); +}