Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Trust the flake's nixConfig (the Cachix substituter) without prompting, so
# the cache applies to every nix command in this shell, not just the devShell
# build. Non-direnv users are unaffected: nix asks them before using it.
export NIX_CONFIG="accept-flake-config = true"
use flake
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,22 @@ jobs:
- uses: leanprover/lean-action@v1
with:
build-args: "--wfail"

# Builds the library and runs the test suite via Nix flake checks
nix-test:
name: Nix Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v16
with:
name: argumentcomputer
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
# Build the library and test binary
- run: nix build --print-build-logs --accept-flake-config
# Run the test suite as a flake check
- run: nix flake check --print-build-logs --accept-flake-config
2 changes: 1 addition & 1 deletion LSpec/LSpec.lean
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ instance (priority := 25) (p : Prop) [d : Decidable p] : Testable p :=
| isTrue h => .isTrue h

open SlimCheck in
instance instTestableOfCheckable (p : Prop) (cfg : Configuration) [Checkable p] : Testable p :=
abbrev instTestableOfCheckable (p : Prop) (cfg : Configuration) [Checkable p] : Testable p :=
let ((res, numSamples), _) := ReaderT.run (Checkable.runSuite p cfg) (.up mkStdGen)
match res with
| .success (.inr h) => .isTrue h
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

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

35 changes: 31 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
description = "LSpec Nix Flake";

nixConfig = {
extra-substituters = [
"https://argumentcomputer.cachix.org"
];
extra-trusted-public-keys = [
"argumentcomputer.cachix.org-1:ovhbTx1V56BYDerOWInQvXKXl68LlhNwEA+n7EWk1m4="
];
};

inputs = {
nixpkgs.follows = "lean4-nix/nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
Expand Down Expand Up @@ -29,17 +38,35 @@
...
}: let
lake2nix = pkgs.callPackage lean4-nix.lake {};

# Library build, shared between the package output and the test check
# so the `tests` exe reuses these artifacts instead of recompiling them.
lspec = lake2nix.mkPackage {
name = "LSpec";
src = ./.;
};

# `mkPackage "LSpec"` only builds the library target, so the `tests`
# exe is built explicitly, reusing `lspec`'s build artifacts.
lspecTest = lake2nix.mkPackage {
name = "tests";
src = ./.;
lakeArtifacts = lspec;
};
in {
_module.args.pkgs = import nixpkgs {
inherit system;
overlays = [(lean4-nix.readToolchainFile ./lean-toolchain)];
};

# Build the library with `nix build`
packages.default = lake2nix.mkPackage {
name = "LSpec";
src = ./.;
};
packages.default = lspec;

# Build and run the test suite as a flake check (`nix flake check`).
checks.tests = pkgs.runCommand "LSpec-tests" { } ''
${lspecTest}/bin/tests
touch $out
'';

devShells.default = pkgs.mkShell {
packages = with pkgs.lean; [lean-all];
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:v4.29.0
leanprover/lean4:v4.31.0
Loading