Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add nix flake #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/build
/lean_packages
result*
1 change: 1 addition & 0 deletions LSpec/LSpec.lean
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ testing frameworks

namespace LSpec

open Lean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? I try to avoid opening namespaces like that. This file compiles just fine without this line

/--
# TODO: No longer accurate

Expand Down
196 changes: 196 additions & 0 deletions flake.lock

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

52 changes: 52 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
inputs = {
lean = {
url = "github:leanprover/lean4/v4.0.0-m5";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using leanprover/lean4:nightly-2022-08-09 in the lean-toolchain file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no tag for that release. You can ofc set it to the explicit git commit hash.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we need to get the git commit hash of the Lean 4 version every time we do a toolchain bump?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, idk how lake fetches the data. It is probably possible to tie into that with nix as well.

};
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, lean, flake-utils, nixpkgs }:
let
supportedSystems = [
"aarch64-linux"
"aarch64-darwin"
"i686-linux"
"x86_64-darwin"
"x86_64-linux"
];
inherit (flake-utils) lib;
in
lib.eachSystem supportedSystems (system:
let
leanPkgs = lean.packages.${system};
pkgs = nixpkgs.legacyPackages.${system};
name = "LSpec"; # must match the name of the top-level .lean file
project = leanPkgs.buildLeanPackage {
inherit name;
# deps = [ lean-ipld.project.${system} ];
# Where the lean files are located
src = ./.;
};
in
{
inherit project;
packages = project // {
${name} = project.sharedLib;
};

defaultPackage = self.packages.${system}.${name};
devShell = pkgs.mkShell {
inputsFrom = [ project.executable ];
buildInputs = with pkgs; [
leanPkgs.lean-dev
];
LEAN_PATH = "./src:./test";
LEAN_SRC_PATH = "./src:./test";
};
});
}