-
Notifications
You must be signed in to change notification settings - Fork 10
/
flake.nix
93 lines (81 loc) · 2.43 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
{
description = "NixOS environment";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = {
self,
nixpkgs,
}: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
devShell.${system} = with pkgs;
mkShell rec {
###
## Library Packages
###
xLibs = with pkgs; [
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
];
dynLibs = with pkgs;
[
alsa-lib
stdenv.cc.cc.lib
udev
vulkan-loader
]
++ xLibs;
###
## Executable Packages
###
buildInputs = with pkgs;
[
clang
# Replace llvmPackages with llvmPackages_X, where X is the latest
# LLVM version (at the time of writing, 16)
llvmPackages_16.bintools
mold
pkg-config
rustup
]
++ dynLibs;
###
## Rust Toolchain Setup
###
RUSTC_VERSION = pkgs.lib.readFile ./rust-toolchain;
shellHook = ''
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
'';
###
## Rust Bindgen Setup
###
# So bindgen can find libclang.so
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [pkgs.llvmPackages_16.libclang.lib];
# Add headers to bindgen search path
BINDGEN_EXTRA_CLANG_ARGS =
# Includes with normal include path
(builtins.map (a: ''-I"${a}/include"'') [
# add dev libraries here (e.g. pkgs.libvmi.dev)
pkgs.glibc.dev
])
# Includes with special directory paths
++ [
''-I"${pkgs.llvmPackages_16.libclang.lib}/lib/clang/${pkgs.llvmPackages_16.libclang.version}/include"''
''-I"${pkgs.glib.dev}/include/glib-2.0"''
''-I${pkgs.glib.out}/lib/glib-2.0/include/''
];
###
## Linking with System libraries
###
# Add precompiled library to rustc search path
RUSTFLAGS = builtins.map (a: ''-L ${a}/lib'') dynLibs;
# For some reason the Vulkan loader needs to be in the dynamic linker path.
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [pkgs.vulkan-loader];
};
};
}