-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
88 lines (84 loc) · 2.64 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
description = "Openssl bindings for Lean";
inputs = {
lean = {
url = github:leanprover/lean4;
};
nixpkgs.url = github:nixos/nixpkgs/nixos-21.05;
utils = {
url = github:yatima-inc/nix-utils;
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, lean, utils, nixpkgs }:
let
supportedSystems = [
# "aarch64-linux"
# "aarch64-darwin"
"i686-linux"
"x86_64-darwin"
"x86_64-linux"
];
inherit (utils) lib;
in
lib.eachSystem supportedSystems (system:
let
leanPkgs = lean.packages.${system};
pkgs = nixpkgs.legacyPackages.${system};
inherit (lib.${system}) buildCLib concatStringsSep;
includes = [ "${pkgs.openssl.dev}/include" "${leanPkgs.lean-bin-tools-unwrapped}/include" ];
INCLUDE_PATH = concatStringsSep ":" includes;
libssl = (pkgs.openssl.out // {
name = "lib/libssl.so";
linkName = "ssl";
libName = "libssl.so";
});
c-shim = buildCLib {
updateCCOptions = d: d ++ (map (i: "-I${i}") includes);
name = "lean-openssl-bindings";
sharedLibDeps = [
libssl
];
src = ./bindings;
extraDrvArgs = {
linkName = "lean-openssl-bindings";
};
};
name = "OpenSSL"; # 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
nativeSharedLibs = [ (libssl // { __toString = d: "${libssl}/lib"; }) c-shim ];
src = ./src;
};
test = leanPkgs.buildLeanPackage
{
name = "Tests";
deps = [ project ];
# Where the lean files are located
src = ./test;
};
joinDepsDerivationns = getSubDrv:
pkgs.lib.concatStringsSep ":" (map (d: "${getSubDrv d}") ([ project ] ++ project.allExternalDeps));
in
{
inherit project test;
packages = {
${name} = project.executable;
};
checks.test = test.executable;
defaultPackage = self.packages.${system}.${name};
devShell = pkgs.mkShell {
inputsFrom = [ project.executable ];
buildInputs = with pkgs; [
leanPkgs.lean
];
LEAN_PATH = joinDepsDerivationns (d: d.modRoot);
LEAN_SRC_PATH = joinDepsDerivationns (d: d.src);
C_INCLUDE_PATH = INCLUDE_PATH;
CPLUS_INCLUDE_PATH = INCLUDE_PATH;
};
});
}