-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathflake.nix
58 lines (50 loc) · 1.84 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
naersk.url = "github:nix-community/naersk/master";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
perSystem = { config, self', pkgs, lib, system, ... }:
let
naersk-lib = pkgs.callPackage inputs.naersk { };
# Use the nightly channel so that we can use the faster cranelift
# backend for development builds.
rustToolchain = pkgs.rust-bin.nightly.latest.default.override {
extensions =
[ "rust-src" "rust-analyzer" "clippy" "rustc-codegen-cranelift" ];
};
# Some packages are required for building the native dependencies.
rustBuildInputs = with pkgs; [
patchelf
cmake
gcc
mold
openssl
pkg-config
python3
];
in {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ inputs.rust-overlay.overlays.default ];
};
packages.default = naersk-lib.buildPackage ./.;
devShells.default = pkgs.mkShell {
name = "optik-dev";
buildInputs = rustBuildInputs;
nativeBuildInputs =
[ rustToolchain pkgs.maturin pkgs.python3Packages.numpy ];
shellHook = ''
# For rust-analyzer 'hover' tooltips to work.
export RUST_SRC_PATH="${rustToolchain}/lib/rustlib/src/rust/library";
'';
LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.stdenv.cc.cc.lib ];
};
};
};
}