chore: Add formatter, update lean4-nix

This commit is contained in:
Leni Aniva 2024-12-05 18:59:14 -08:00
parent 13dd11e995
commit fb3d36584f
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
2 changed files with 87 additions and 77 deletions

View File

@ -42,15 +42,16 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1731711316, "lastModified": 1733351931,
"narHash": "sha256-s5u+A2/Ea9gPveB5wwVM5dWW0NST6kamDsTeovGuLEs=", "narHash": "sha256-ngMjY/ci6490G2gofaS9CODtpnmFoYzfaI13U14TkFM=",
"owner": "lenianiva", "owner": "lenianiva",
"repo": "lean4-nix", "repo": "lean4-nix",
"rev": "136fc6057c48de970579e960b62421e9c295b67d", "rev": "157c85903f668fadeb79f330961b7bbe5ee596de",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "lenianiva", "owner": "lenianiva",
"ref": "157c85903f668fadeb79f330961b7bbe5ee596de",
"repo": "lean4-nix", "repo": "lean4-nix",
"type": "github" "type": "github"
} }

157
flake.nix
View File

@ -4,7 +4,7 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
lean4-nix.url = "github:lenianiva/lean4-nix"; lean4-nix.url = "github:lenianiva/lean4-nix?ref=157c85903f668fadeb79f330961b7bbe5ee596de";
lspec = { lspec = {
url = "github:argumentcomputer/LSpec?ref=504a8cecf8da601b9466ac727aebb6b511aae4ab"; url = "github:argumentcomputer/LSpec?ref=504a8cecf8da601b9466ac727aebb6b511aae4ab";
flake = false; flake = false;
@ -18,80 +18,89 @@
lean4-nix, lean4-nix,
lspec, lspec,
... ...
} : flake-parts.lib.mkFlake { inherit inputs; } { }:
flake = { flake-parts.lib.mkFlake {inherit inputs;} {
}; flake = {
systems = [
"x86_64-linux"
"x86_64-darwin"
];
perSystem = { system, pkgs, ... }: let
pkgs = import nixpkgs {
inherit system;
overlays = [ (lean4-nix.readToolchainFile ./lean-toolchain) ];
}; };
lspecLib = pkgs.lean.buildLeanPackage { systems = [
name = "LSpec"; "aarch64-linux"
roots = [ "Main" "LSpec" ]; "aarch64-darwin"
src = "${lspec}"; "x86_64-linux"
}; "x86_64-darwin"
project = pkgs.lean.buildLeanPackage { ];
name = "Pantograph"; perSystem = {
roots = [ "Pantograph" ]; system,
src = pkgs.lib.cleanSource (pkgs.lib.cleanSourceWith { pkgs,
src = ./.; ...
filter = path: type: }: let
!(pkgs.lib.hasInfix "/Test/" path) && pkgs = import nixpkgs {
!(pkgs.lib.hasSuffix ".md" path) && inherit system;
!(pkgs.lib.hasSuffix "Repl.lean" path); overlays = [(lean4-nix.readToolchainFile ./lean-toolchain)];
}); };
}; lspecLib = pkgs.lean.buildLeanPackage {
repl = pkgs.lean.buildLeanPackage { name = "LSpec";
name = "Repl"; roots = ["Main" "LSpec"];
roots = [ "Main" "Repl" ]; src = "${lspec}";
deps = [ project ]; };
src = pkgs.lib.cleanSource (pkgs.lib.cleanSourceWith { project = pkgs.lean.buildLeanPackage {
src = ./.; name = "Pantograph";
filter = path: type: roots = ["Pantograph"];
!(pkgs.lib.hasInfix "/Test/" path) && src = pkgs.lib.cleanSource (pkgs.lib.cleanSourceWith {
!(pkgs.lib.hasSuffix ".md" path); src = ./.;
}); filter = path: type:
}; !(pkgs.lib.hasInfix "/Test/" path)
test = pkgs.lean.buildLeanPackage { && !(pkgs.lib.hasSuffix ".md" path)
name = "Test"; && !(pkgs.lib.hasSuffix "Repl.lean" path);
# NOTE: The src directory must be ./. since that is where the import });
# root begins (e.g. `import Test.Environment` and not `import };
# Environment`) and thats where `lakefile.lean` resides. repl = pkgs.lean.buildLeanPackage {
roots = [ "Test.Main" ]; name = "Repl";
deps = [ lspecLib repl ]; roots = ["Main" "Repl"];
src = pkgs.lib.cleanSource (pkgs.lib.cleanSourceWith { deps = [project];
src = ./.; src = pkgs.lib.cleanSource (pkgs.lib.cleanSourceWith {
filter = path: type: src = ./.;
!(pkgs.lib.hasInfix "Pantograph" path); filter = path: type:
}); !(pkgs.lib.hasInfix "/Test/" path)
}; && !(pkgs.lib.hasSuffix ".md" path);
in rec { });
packages = { };
inherit (pkgs.lean) lean lean-all; test = pkgs.lean.buildLeanPackage {
inherit (project) sharedLib iTree; name = "Test";
inherit (repl) executable; # NOTE: The src directory must be ./. since that is where the import
default = repl.executable; # root begins (e.g. `import Test.Environment` and not `import
}; # Environment`) and thats where `lakefile.lean` resides.
legacyPackages = { roots = ["Test.Main"];
inherit project; deps = [lspecLib repl];
leanPkgs = pkgs.lean; src = pkgs.lib.cleanSource (pkgs.lib.cleanSourceWith {
}; src = ./.;
checks = { filter = path: type:
test = pkgs.runCommand "test" { !(pkgs.lib.hasInfix "Pantograph" path);
buildInputs = [ test.executable pkgs.lean.lean-all ]; });
} '' };
#export LEAN_SRC_PATH="${./.}" in rec {
${test.executable}/bin/test > $out packages = {
''; inherit (pkgs.lean) lean lean-all;
}; inherit (project) sharedLib iTree;
devShells.default = pkgs.mkShell { inherit (repl) executable;
buildInputs = [ pkgs.lean.lean-all pkgs.lean.lean ]; default = repl.executable;
};
formatter = pkgs.alejandra;
legacyPackages = {
inherit project;
leanPkgs = pkgs.lean;
};
checks = {
test =
pkgs.runCommand "test" {
buildInputs = [test.executable pkgs.lean.lean-all];
} ''
#export LEAN_SRC_PATH="${./.}"
${test.executable}/bin/test > $out
'';
};
devShells.default = pkgs.mkShell {
buildInputs = [pkgs.lean.lean-all pkgs.lean.lean];
};
}; };
}; };
};
} }