forked from argumentcomputer/OpenSSL.lean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
114 lines (110 loc) · 3.39 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
description = "OpenSSL bindings for Lean";
inputs = {
lean = {
url = github:leanprover/lean4;
};
nixpkgs.url = github:nixos/nixpkgs/nixos-unstable;
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" ./native ];
INCLUDE_PATH = concatStringsSep ":" includes;
libssl = (pkgs.openssl.out // {
name = "lib/libssl.so";
linkName = "ssl";
libName = "libssl.so";
__toString = d: "${d.out}/lib";
});
c-shim = buildCLib {
updateCCOptions = d: d ++ (map (i: "-I${i}") includes);
name = "lean-openssl-bindings";
sharedLibDeps = [
libssl
];
src = ./native;
extraDrvArgs = {
linkName = "lean-openssl-bindings";
};
};
c-shim-debug = c-shim.override {
debug = true;
updateCCOptions = d: d ++ (map (i: "-I${i}") includes) ++ [ "-O0" ];
};
name = "OpenSSL"; # must match the name of the top-level .lean file
OpenSSL = leanPkgs.buildLeanPackage
{
inherit name;
# Where the lean files are located
nativeSharedLibs = [ libssl c-shim ];
src = ./src;
};
Cli = leanPkgs.buildLeanPackage
{
name = "Main";
deps = [ OpenSSL ];
src = ./.;
};
project-debug = OpenSSL.override {
debug = true;
nativeSharedLibs = [ libssl c-shim-debug ];
};
test = leanPkgs.buildLeanPackage
{
name = "Tests";
deps = [ OpenSSL ];
# Where the lean files are located
src = ./test;
};
test-debug = test.override {
debug = true;
deps = [ project-debug ];
};
joinDepsDerivations = getSubDrv:
pkgs.lib.concatStringsSep ":" (map (d: "${getSubDrv d}") (OpenSSL.allExternalDeps));
in
{
project = OpenSSL;
packages = {
inherit OpenSSL Cli;
inherit (OpenSSL) lean-package;
test = test.executable;
test-debug = test-debug.executable;
};
checks.test = test.executable;
defaultPackage = self.packages.${system}.Cli.executable;
devShells.default = pkgs.mkShell {
# inputsFrom = [ OpenSSL.executable ];
buildInputs = with pkgs; [
elan
openssl
pkg-config
# leanPkgs.lean-dev
];
OPENSSL_DIR = "${pkgs.openssl.out}";
# LEAN_PATH = "./src:./test:" + joinDepsDerivations (d: d.modRoot);
# LEAN_SRC_PATH = "./src:./test:" + joinDepsDerivations (d: d.src);
C_INCLUDE_PATH = INCLUDE_PATH;
CPLUS_INCLUDE_PATH = INCLUDE_PATH;
};
});
}