RustCallLean/flake.nix

79 lines
2.0 KiB
Nix
Raw Normal View History

2024-03-04 21:08:55 -08:00
{
description = "RustCallLean";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
lean.url = "github:leanprover/lean4?ref=v4.1.0";
2024-03-06 13:03:40 -08:00
rust-crate2nix = {
url = "github:kolloch/crate2nix";
flake = false;
};
2024-03-04 21:08:55 -08:00
};
outputs = inputs @ {
self,
nixpkgs,
flake-parts,
lean,
2024-03-06 13:03:40 -08:00
rust-crate2nix,
2024-03-04 21:08:55 -08:00
...
} : flake-parts.lib.mkFlake { inherit inputs; } {
flake = {
};
systems = [
"x86_64-linux"
"x86_64-darwin"
];
perSystem = { system, pkgs, ... }: let
leanPkgs = lean.packages.${system};
callee = leanPkgs.buildLeanPackage {
name = "Callee";
roots = [ "Callee" ];
src = ./Callee;
};
2024-03-06 13:03:40 -08:00
nativeBuildInputs = [
2024-03-06 14:37:56 -08:00
pkgs.rustPlatform.bindgenHook
pkgs.llvmPackages.clang
2024-03-06 13:03:40 -08:00
];
buildInputs = [
2024-03-05 14:00:04 -08:00
leanPkgs.lean-all
pkgs.libiconv
];
2024-03-06 13:03:40 -08:00
caller = let
crateTools = pkgs.callPackage "${rust-crate2nix}/tools.nix" { inherit pkgs; };
in import (crateTools.generatedCargoNix {
name = "caller";
src = ./.;
}) {
inherit pkgs;
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
caller = attrs: {
inherit nativeBuildInputs;
inherit buildInputs;
CALLEE_PATH = callee.sharedLib;
LEAN_ROOT = leanPkgs.lean-all;
};
};
};
2024-03-04 21:08:55 -08:00
in rec {
packages = {
inherit (leanPkgs) lean iTree stage1 lean-all;
callee = callee.sharedLib;
2024-03-06 13:03:40 -08:00
caller = caller.rootCrate.build;
bindgen = pkgs.rustPlatform.bindgenHook;
2024-03-04 21:08:55 -08:00
};
devShells.default = pkgs.mkShell {
CALLEE_PATH = callee.sharedLib;
2024-03-05 14:00:04 -08:00
LEAN_ROOT = leanPkgs.lean-all;
2024-03-06 14:37:56 -08:00
inherit nativeBuildInputs;
buildInputs = buildInputs ++ [
2024-03-04 21:08:55 -08:00
pkgs.rustc
2024-03-05 15:57:48 -08:00
# This is not needed for compilation. It is here for diagnostic purposes
pkgs.rust-bindgen
2024-03-04 21:08:55 -08:00
];
};
};
};
}