-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
192 lines (177 loc) · 5.15 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
{
inputs = {
#nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
#nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.11";
#nixpkgs.follows = "nixpkgs-stable";
nixpkgs.follows = "romen/nixpkgs";
naersk.url = "github:nix-community/naersk/master";
naersk.inputs.nixpkgs.follows = "nixpkgs";
utils.url = "github:numtide/flake-utils";
romen.url = "git+https://gitlab.com/nicola_tuveri_group/nix-tests/my-flakes.git?ref=master";
#romen.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
utils,
naersk,
romen,
...
} @ inputs:
utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
naersk-lib = pkgs.callPackage naersk {};
romen = inputs.romen.packages.${system};
myopenssl = romen.openssl_3_2;
#myopenssl = romen.openssl_3_2_with_oqs-provider;
cc = pkgs.clangStdenv.cc;
aurora-nativeBuildInputs =
[
cc
pkgs.rust-bindgen
pkgs.rustPlatform.bindgenHook
pkgs.pkg-config
pkgs.git
myopenssl
myopenssl.dev
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
aurora-naersk = naersk-lib.buildPackage {
gitSubmodules = true;
gitAllRefs = true;
src = self;
root = self;
copyLibs = true;
release = false;
doDoc = true;
doDocFail = true;
CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG = true;
RUST_BACKTRACE = "full";
nativeBuildInputs = aurora-nativeBuildInputs;
#preBuild = ''
# echo "PWD: $(pwd)"
# ls -la
# echo "$(git describe --tags)"
# cd aurora
# echo "PWD: $(pwd)"
# ls -la
# echo "$(git describe --tags)"
#'';
};
aurora = aurora-naersk;
dockerImage-runner = pkgs.dockerTools.buildImage {
name = "qubip-ossl-rust-runner";
tag = "latest-nix";
compressor = "zstd";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths =
aurora-nativeBuildInputs
++ (with pkgs; [
cargo
rustc
rustfmt
rustPackages.clippy
just
coreutils
bashInteractive
bash-completion
which
readline
cacert
libclang
libclang.lib
findutils
tree
eza
gnugrep
file
]);
};
runAsRoot = ''
#!${pkgs.runtimeShell}
mkdir -p /tmp
'';
config = {
Cmd = ["/bin/bash"];
Env = let
lib = pkgs.lib;
ccVer = lib.getVersion cc.cc;
ccMajorVer = builtins.elemAt (lib.splitVersion ccVer) 0;
in
with pkgs; [
"LIBCLANG_PATH=${libclang.lib}/lib"
"PKG_CONFIG_PATH=/lib/pkgconfig"
"BINDGEN_EXTRA_CLANG_ARGS=-idirafter\"${cc.cc.lib}/lib/clang/${ccMajorVer}/include\" -idirafter\"${cc.libc.dev}/include\""
];
};
};
in {
formatter = pkgs.alejandra;
packages = rec {
inherit myopenssl;
inherit aurora;
inherit dockerImage-runner;
default = aurora;
};
#apps = rec {
# gdb = {
# type = "app";
# #program = "${pkgs.gdb}/bin/gdb -ex 'dir ${myopenssl.src}'";
# program = "${pkgs.gdb}/bin/gdb";
# };
# default = gdb;
#};
devShells = {
default = with pkgs;
mkShell {
buildInputs =
[
romen.openssl_3_2_with_oqs-provider
pkg-config
cargo
rustc
rustfmt
pre-commit
rustPackages.clippy
myopenssl
myopenssl.dev
just
rustPlatform.bindgenHook
nixpkgs-fmt
neovim
ruby
python311Packages.nodeenv
lazygit
]
++ (
if pkgs.stdenv.isLinux
then [
gdb
valgrind
dive
]
else if pkgs.stdenv.isDarwin
then []
else []
)
++ aurora.nativeBuildInputs;
RUST_SRC_PATH = rustPlatform.rustLibSrc;
RUST_BACKTRACE = "full";
#RUST_LOG = "trace";
RUST_LOG = "debug";
#OPENSSL_MODULES = "./result/lib";
OPENSSL_DEV_DIR = myopenssl.dev;
OPENSSL_MODULES = "./target/debug";
OPENSSL_SRC_FILES = myopenssl.src;
OPENSSL_PFX = myopenssl;
OPENSSL_CONF = "/dev/null";
OQSPROVIDER_PATH = myopenssl.out.outPath + "/lib/ossl-modules/oqsprovider.so";
GDB_CUSTOM_ARGS = "-d ${myopenssl.src}";
};
};
});
}