Skip to content

Commit 7604a25

Browse files
author
Atticus Kuhn
committed
change lean version error??
1 parent 6e2cf46 commit 7604a25

File tree

4 files changed

+52
-36
lines changed

4 files changed

+52
-36
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,16 @@ To set up your new GitHub repository, follow these steps:
1111
* In the **Source** dropdown menu, select "GitHub Actions".
1212

1313
After following the steps above, you can remove this section from the README file.
14+
15+
## Development
16+
17+
- Enter the dev shell with `nix develop`. The shell uses `elan` to provide the
18+
Lean toolchain specified in `lean-toolchain` (currently `leanprover/lean4:v4.24.0`).
19+
The flake does not pin a Lean version via nix overlays to avoid version skew.
20+
21+
- First time in the shell, `elan` will install the requested toolchain. Then:
22+
- Check the compiler: `lean --version` should report `4.24.0`.
23+
- Build the project: `lake build`.
24+
25+
If you prefer not to use the dev shell, you can install `elan` separately and run
26+
`elan toolchain install $(cat lean-toolchain)` to provision Lean + Lake, then `lake build`.

docs/techContext.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ Stack:
77
- Dependencies: `Std` (TreeMap), `Mathlib` (lexicographic ordering helpers).
88
- Rust toolchain (`rustc` and `cargo`) available in dev/CI environments.
99

10+
Dev environment:
11+
12+
- Enter with `nix develop`. The shell uses `elan` to install and expose the
13+
Lean/Lake toolchain specified in `lean-toolchain` (currently `leanprover/lean4:v4.24.0`).
14+
We avoid pinning Lean via a Nix overlay to prevent version skew with Mathlib; the
15+
shell prepends the matching `elan` toolchain `bin` directory to `PATH`.
16+
1017
Key modules:
1118

1219
- `PartIiProject/Term.lean`: core types, semimodule evidence, tensor, PHOAS terms, interpreter, printers, examples.

flake.nix

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
66
flake-parts.url = "github:hercules-ci/flake-parts";
7+
# Keep lean4-nix as an input in case we restore Nix builds later,
8+
# but do not depend on its toolchain overlay for dev shells.
79
lean4-nix.url = "github:lenianiva/lean4-nix";
810
};
911

1012
outputs = inputs @ {
1113
nixpkgs,
1214
flake-parts,
1315
lean4-nix,
16+
# lean4-nix is intentionally unused in devShell to avoid pinning Lean
17+
# in Nix. We rely on `elan` + `lean-toolchain` instead.
18+
# It remains available in `inputs` for future use.
1419
...
1520
}:
1621
flake-parts.lib.mkFlake { inherit inputs; } {
@@ -23,44 +28,35 @@
2328

2429
perSystem = { system, ... }:
2530
let
26-
pkgs = import nixpkgs {
27-
inherit system;
28-
overlays = [ (lean4-nix.readToolchainFile ./lean-toolchain) ];
29-
};
30-
lake = (lean4-nix.lake { inherit pkgs; });
31-
# Build the test executable via lake-manifest integration
32-
sdqlTests = (lake.mkPackage {
33-
src = ./.;
34-
# Explicit roots to avoid auto-capitalization from manifest name
35-
roots = [ "Tests" ];
36-
}).executable;
31+
# Use plain nixpkgs for the dev shell; do not pin Lean here.
32+
# Lean/Lake will come from `elan` according to `lean-toolchain`.
33+
pkgs = import nixpkgs { inherit system; };
3734
in
3835
{
39-
packages = {
40-
default = sdqlTests;
41-
sdql-tests = sdqlTests;
42-
};
43-
44-
# The executable name defaults to the lowercased manifest name
45-
# (see lean4-nix buildLeanPackage), which for this repo is
46-
# "part_ii_project".
47-
apps = let exePath = "${sdqlTests}/bin/part_ii_project"; in {
48-
default = {
49-
type = "app";
50-
program = exePath;
51-
};
52-
sdql-tests = {
53-
type = "app";
54-
program = exePath;
55-
};
56-
};
57-
5836
devShells.default = pkgs.mkShell {
59-
# Provide Lean + Lake matching ./lean-toolchain, plus essential tools.
60-
# Keep this minimal to avoid attr or non-derivation issues on some channels.
61-
packages =
62-
(with pkgs.lean; [ lean-all ])
63-
++ (with pkgs; [ git unzip rustc cargo codex uv ]);
37+
# Keep the shell minimal and reproducible. We rely on `elan`
38+
# to supply Lean/Lake that match `./lean-toolchain`.
39+
packages = with pkgs; [ git unzip rustc cargo codex uv elan ];
40+
41+
# Ensure the desired toolchain is available and preferred.
42+
# This avoids depending on a Lean version packaged in nixpkgs
43+
# or an overlay that may lag behind the toolchain file.
44+
shellHook = ''
45+
if command -v elan >/dev/null 2>&1; then
46+
TOOLCHAIN=$(cat lean-toolchain)
47+
echo "Using Lean toolchain $TOOLCHAIN via elan"
48+
# Try to install silently if missing (ignore failures offline)
49+
elan toolchain install "$TOOLCHAIN" >/dev/null 2>&1 || true
50+
# Derive the toolchain path used by elan without shell parameter expansion
51+
ELAN_TC=$(printf "%s" "$TOOLCHAIN" | sed -e 's#/#--#g' -e 's#:#---#g')
52+
ELAN_BIN="$HOME/.elan/toolchains/$ELAN_TC/bin"
53+
if [ -d "$ELAN_BIN" ]; then
54+
export PATH="$ELAN_BIN:$PATH"
55+
fi
56+
else
57+
echo "Warning: elan not found; system Lean/Lake (if any) will be used."
58+
fi
59+
'';
6460
};
6561
};
6662
};

lean-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:v4.23.0
1+
leanprover/lean4:v4.24.0

0 commit comments

Comments
 (0)