-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
120 lines (104 loc) · 3.59 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
{
description = "yaaaaaaaaaaaaaaaaaaaaa";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = inputs@{self, ...}:
inputs.flake-utils.lib.eachSystem ["x86_64-linux"] (system: let
pkgs = import inputs.nixpkgs {
inherit system;
};
unstable = import inputs.nixpkgs-unstable {
inherit system;
};
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
# - [bevy/docs/linux_dependencies.md at main · bevyengine/bevy · GitHub](https://github.com/bevyengine/bevy/blob/main/docs/linux_dependencies.md#nixos)
packages = pkgs: with pkgs; [
# - [RPATH, or why lld doesn't work on NixOS](https://matklad.github.io/2022/03/14/rpath-or-why-lld-doesnt-work-on-nixos.html)
llvmPackages.bintools
llvmPackages_15.clang
# - [Using mold as linker prevents - NixOS Discourse](https://discourse.nixos.org/t/using-mold-as-linker-prevents-libraries-from-being-found/18530/5)
unstable.mold-wrapped
openssl
xdotool
alsa-oss
alsa-lib
systemd
libGL
udev
alsa-lib
# WGPU_BACKEND=vulkan
vulkan-loader
vulkan-headers
vulkan-validation-layers
glslang
libxkbcommon
# WINIT_UNIX_BACKEND=wayland
wayland
# - [No appropiate adapter found](https://github.com/gfx-rs/wgpu/issues/3033)
# WINIT_UNIX_BACKEND=x11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
xorg.libX11
pkg-config
# tools
# glxinfo # glxinfo
# wgpu-utils # wgpuinfo
# vulkan-tools # vulkaninfo
];
in {
packages.default = unstable.rustPlatform.buildRustPackage {
pname = manifest.name;
version = manifest.version;
cargoLock.lockFile = ./Cargo.lock;
# src = pkgs.lib.cleanSource ./.;
# - [nix flake rust and pkgconfig](https://discourse.nixos.org/t/nix-and-rust-how-to-use-pkgconfig/17465/3)
buildInputs = packages pkgs;
nativeBuildInputs = with pkgs; [
pkg-config
];
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs;
[
unstable.rust-analyzer
unstable.rustfmt
unstable.clippy
(pkgs.buildFHSEnv {
name = "game";
targetPkgs = packages;
runScript = ''
#!/usr/bin/env bash
nvidia-offload ./target/debug/${manifest.name}
'';
})
(pkgs.buildFHSEnv {
name = "game-release";
targetPkgs = packages;
runScript = ''
#!/usr/bin/env bash
nvidia-offload ./target/release/${manifest.name}
'';
})
(pkgs.buildFHSEnv {
name = "fhs-shell";
targetPkgs = packages;
runScript = "${pkgs.zsh}/bin/zsh";
profile = ''
export FHS=1
'';
})
]
++ self.packages."${system}".default.nativeBuildInputs
++ self.packages."${system}".default.buildInputs;
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath self.packages."${system}".default.buildInputs;
shellHook = ''
export RUST_BACKTRACE="1"
# export RUSTFLAGS="-C target-feature=-crt-static"
'';
};
});
}