Pantograph/flake.nix

98 lines
2.8 KiB
Nix
Raw Permalink Normal View History

2023-10-20 11:52:09 -07:00
{
description = "Pantograph";
inputs = {
2024-10-26 13:49:03 -07:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
2023-10-20 11:52:09 -07:00
flake-parts.url = "github:hercules-ci/flake-parts";
lean4-nix.url = "github:lenianiva/lean4-nix";
2024-03-28 11:33:15 -07:00
lspec = {
2024-10-08 00:15:30 -07:00
url = "github:argumentcomputer/LSpec?ref=504a8cecf8da601b9466ac727aebb6b511aae4ab";
2024-03-28 11:33:15 -07:00
flake = false;
};
2023-10-20 11:52:09 -07:00
};
outputs = inputs @ {
self,
nixpkgs,
flake-parts,
lean4-nix,
2024-03-28 11:33:15 -07:00
lspec,
2023-10-20 11:52:09 -07:00
...
} : flake-parts.lib.mkFlake { inherit inputs; } {
flake = {
};
systems = [
"x86_64-linux"
"x86_64-darwin"
];
perSystem = { system, pkgs, ... }: let
2024-10-26 13:49:03 -07:00
pkgs = import nixpkgs {
inherit system;
2024-10-26 17:52:37 -07:00
overlays = [ (lean4-nix.readToolchainFile ./lean-toolchain) ];
2024-10-26 13:49:03 -07:00
};
lspecLib = pkgs.lean.buildLeanPackage {
2024-03-28 11:33:15 -07:00
name = "LSpec";
roots = [ "Main" "LSpec" ];
src = "${lspec}";
};
2024-10-26 13:49:03 -07:00
project = pkgs.lean.buildLeanPackage {
2023-10-20 11:52:09 -07:00
name = "Pantograph";
roots = [ "Pantograph" ];
src = pkgs.lib.cleanSource (pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type:
!(pkgs.lib.hasInfix "/Test/" path) &&
!(pkgs.lib.hasSuffix ".md" path) &&
!(pkgs.lib.hasSuffix "Repl.lean" path);
});
};
2024-10-26 13:49:03 -07:00
repl = pkgs.lean.buildLeanPackage {
name = "Repl";
roots = [ "Main" "Repl" ];
deps = [ project ];
src = pkgs.lib.cleanSource (pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type:
!(pkgs.lib.hasInfix "/Test/" path) &&
!(pkgs.lib.hasSuffix ".md" path);
});
2023-10-20 11:52:09 -07:00
};
2024-10-26 13:49:03 -07:00
test = pkgs.lean.buildLeanPackage {
2024-03-28 00:06:35 -07:00
name = "Test";
2024-03-28 11:33:15 -07:00
# 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.
roots = [ "Test.Main" ];
deps = [ lspecLib repl ];
src = pkgs.lib.cleanSource (pkgs.lib.cleanSourceWith {
2024-03-28 11:33:15 -07:00
src = ./.;
filter = path: type:
!(pkgs.lib.hasInfix "Pantograph" path);
});
2024-03-28 00:06:35 -07:00
};
2023-10-20 11:52:09 -07:00
in rec {
2024-03-06 15:26:35 -08:00
packages = {
2024-10-26 13:49:03 -07:00
inherit (pkgs.lean) lean lean-all;
inherit (project) sharedLib iTree;
inherit (repl) executable;
default = repl.executable;
};
legacyPackages = {
2024-10-26 13:49:03 -07:00
inherit project;
leanPkgs = pkgs.lean;
};
2024-03-28 00:06:35 -07:00
checks = {
2024-03-28 11:33:15 -07:00
test = pkgs.runCommand "test" {
2024-10-26 13:49:03 -07:00
buildInputs = [ test.executable pkgs.lean.lean-all ];
2024-03-28 11:33:15 -07:00
} ''
#export LEAN_SRC_PATH="${./.}"
${test.executable}/bin/test > $out
'';
2024-03-28 00:06:35 -07:00
};
2024-03-28 22:26:46 -07:00
devShells.default = pkgs.mkShell {
2024-10-26 13:49:03 -07:00
buildInputs = [ pkgs.lean.lean-all pkgs.lean.lean ];
2024-03-28 22:26:46 -07:00
};
2023-10-20 11:52:09 -07:00
};
};
}