-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
88 lines (84 loc) · 2.26 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 = "project_name";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
systems.url = "github:nix-systems/default";
crane.url = "github:ipetkov/crane";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
crane,
fenix,
systems,
...
}: let
forEachSystem = nixpkgs.lib.genAttrs (import systems);
pkgsFor = forEachSystem (system:
import nixpkgs {
inherit system;
overlays = [
fenix.overlays.default
];
});
rust-toolchain = forEachSystem (system:
pkgsFor.${system}.fenix.stable.withComponents [
"cargo"
"llvm-tools"
"rustc"
]);
craneLib = forEachSystem (system: (crane.mkLib pkgsFor.${system}).overrideToolchain rust-toolchain.${system});
bevy-runtime-deps = forEachSystem (system:
with pkgsFor.${system}; [
pkg-config
alsa-lib
vulkan-tools
vulkan-headers
vulkan-loader
vulkan-validation-layers
libudev-zero
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
xorg.libxcb
libxkbcommon
wayland
]);
bevy-build-deps = forEachSystem (system:
with pkgsFor.${system}; [
clang
lld
]);
all-deps = forEachSystem (system: bevy-build-deps.${system} ++ bevy-runtime-deps.${system});
in {
formatter = forEachSystem (system: pkgsFor.${system}.alejandra);
devShells = forEachSystem (system: {
default = craneLib.${system}.devShell {
packages = all-deps.${system};
shellHook = ''
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgsFor.${system}.lib.makeLibraryPath (with pkgsFor.${system}; [
libxkbcommon
vulkan-loader
])}"
'';
};
});
packages = forEachSystem (system: {
default = craneLib.${system}.buildPackage {
src = craneLib.${system}.cleanCargoSource ./.;
nativeBuildInputs = all-deps.${system};
};
});
apps = forEachSystem (system: {
default = {
type = "app";
program = "${self.packages.${system}.default}/bin/project_name";
};
});
};
}