|
49 | 49 | export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig" |
50 | 50 | ${script} |
51 | 51 | ''); |
| 52 | + |
| 53 | + # Pure package for miri-test (built in sandbox) |
| 54 | + miriTestPure = pkgs.writeShellApplication { |
| 55 | + name = "miri-test-pure"; |
| 56 | + runtimeInputs = [ |
| 57 | + nightlyToolchain |
| 58 | + ] ++ commonBuildInputs; |
| 59 | + |
| 60 | + text = '' |
| 61 | + set -e |
| 62 | + # Additional environment setup (runtimeInputs handles PATH for binaries) |
| 63 | + export LD_LIBRARY_PATH="${pkgs.openssl.out}/lib" |
| 64 | + export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig" |
| 65 | + # MIRI_SYSROOT needs to be writable - use a cache directory |
| 66 | + # cargo miri setup will create the sysroot here |
| 67 | + export MIRI_SYSROOT="''${MIRI_SYSROOT:-$HOME/.cache/miri}" |
| 68 | + mkdir -p "$MIRI_SYSROOT" |
| 69 | + cargo miri setup |
| 70 | + cargo miri test miri |
| 71 | + ''; |
| 72 | + }; |
52 | 73 | in { |
53 | 74 | devShells.default = pkgs.mkShell { |
54 | 75 | buildInputs = [ |
|
104 | 125 | ''; |
105 | 126 | }; |
106 | 127 |
|
| 128 | + # Pure package for miri-test (built in sandbox) |
| 129 | + packages.miri-test-pure = miriTestPure; |
| 130 | + |
| 131 | + # App that uses the pure package (built in sandbox when run) |
| 132 | + # When you run `nix run .#miri-test`, it will build the pure package first |
107 | 133 | apps.miri-test = { |
108 | 134 | type = "app"; |
109 | | - program = writeShellScriptWithError "miri-test" '' |
110 | | - export PATH="${nightlyToolchain}/bin:$PATH" |
111 | | - # Ensure cargo uses the nightly toolchain from PATH (not rustup) |
112 | | - unset RUSTUP_TOOLCHAIN |
113 | | - # nix run preserves the working directory, but ensure we're in project root |
114 | | - if [ ! -f "Cargo.toml" ]; then |
115 | | - # Try to find project root |
116 | | - while [ "$PWD" != "/" ] && [ ! -f "Cargo.toml" ]; do |
117 | | - cd .. |
118 | | - done |
119 | | - if [ ! -f "Cargo.toml" ]; then |
120 | | - echo "Error: Could not find Cargo.toml" >&2 |
121 | | - exit 1 |
122 | | - fi |
123 | | - fi |
124 | | - # Verify we're using nightly (using case-insensitive check without grep) |
125 | | - RUSTC_VERSION=$(rustc --version) |
126 | | - case "$RUSTC_VERSION" in |
127 | | - *nightly*) ;; |
128 | | - *) echo "Error: Not using nightly toolchain, got: $RUSTC_VERSION" >&2; exit 1;; |
129 | | - esac |
130 | | - # Verify cargo is also nightly |
131 | | - CARGO_VERSION=$(cargo --version) |
132 | | - case "$CARGO_VERSION" in |
133 | | - *nightly*) ;; |
134 | | - *) echo "Error: cargo is not nightly, got: $CARGO_VERSION" >&2; exit 1;; |
135 | | - esac |
136 | | - # Verify cargo-miri is available and comes from nightly |
137 | | - if ! command -v cargo-miri >/dev/null 2>&1; then |
138 | | - echo "Error: cargo-miri not found in PATH" >&2 |
139 | | - exit 1 |
140 | | - fi |
141 | | - # Verify cargo-miri is from the nightly toolchain we set in PATH |
142 | | - CARGO_MIRI_PATH=$(command -v cargo-miri) |
143 | | - case "$CARGO_MIRI_PATH" in |
144 | | - *nightly*) ;; |
145 | | - *) echo "Error: cargo-miri not from nightly toolchain, found at: $CARGO_MIRI_PATH" >&2; exit 1;; |
146 | | - esac |
147 | | - cargo miri setup |
148 | | - cargo miri test miri |
149 | | - ''; |
| 135 | + program = "${miriTestPure}/bin/miri-test-pure"; |
150 | 136 | }; |
151 | 137 |
|
152 | 138 | apps.build-book = { |
|
0 commit comments