-
-
Notifications
You must be signed in to change notification settings - Fork 325
Expand file tree
/
Copy pathdefault.nix
More file actions
113 lines (105 loc) · 2.77 KB
/
Copy pathdefault.nix
File metadata and controls
113 lines (105 loc) · 2.77 KB
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
{ alsa-lib
, ffmpeg
, fontconfig
, jq
, lib
, libxkbcommon
, llvmPackages
, makeWrapper
, openssl
, pkg-config
, rustPlatform
, vulkan-loader
, vulkan-validation-layers
, wayland
, libx11
, libxcursor
, libxi
, libxrandr
, stdenv
, udev
, XCURSOR_THEME ? "Adwaita"
}:
rustPlatform.buildRustPackage rec {
pname = "nannou";
src = lib.sourceFilesBySuffices ./. [
".rs"
".toml"
".lock"
".wgsl"
];
# All crates inherit the workspace version (`version.workspace = true`), so
# read it from the single source of truth in the workspace manifest.
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"skeptic-0.13.8" = "sha256-LLVrpuyQsMdbp8OYcHN0nq+uKC8xgJzpNy+gyXxTYbo=";
};
};
# Don't run tests every time, we'll do it in a separate CI pass.
doCheck = false;
nativeBuildInputs = [
makeWrapper
llvmPackages.clang
pkg-config
];
buildInputs = ([
ffmpeg
# For filtering `cargo metadata` to get example names.
jq
# Needed by `reqwest`, used in `generative_design` wikipedia example.
openssl
] ++ lib.optionals stdenv.isLinux [
alsa-lib
# Required by `parley`'s `system` font-discovery feature (via
# `yeslogic-fontconfig-sys`) used by the text stack.
fontconfig
udev
libxkbcommon
llvmPackages.bintools
llvmPackages.libclang
vulkan-loader
vulkan-validation-layers
wayland
libx11
libxcursor
libxi
libxrandr
] ++ lib.optionals stdenv.isDarwin [
rustPlatform.bindgenHook
]);
env = (lib.optionalAttrs stdenv.isLinux
{
inherit XCURSOR_THEME;
LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}";
ALSA_LIB_DEV = "${alsa-lib.dev}";
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
});
# Build and include example binaries in `$out/bin/examples`
postBuild = ''
cargo build --locked --release --examples
mkdir -p $out/bin/examples
for example in $(cargo metadata --format-version=1 --no-deps | ${jq}/bin/jq -r '.packages[].targets[] | select(.kind[] | contains("example")) | .name'); do
if [ -f "target/release/examples/$example" ]; then
mv "target/release/examples/$example" $out/bin/examples/
fi
done
'';
# Wrap the binaries to ensure the runtime env vars are set.
postFixup =
let
linuxWrapArgs = lib.optionalString stdenv.isLinux ''\
--set LD_LIBRARY_PATH "${env.LD_LIBRARY_PATH}" \
--set ALSA_LIB_DEV "${env.ALSA_LIB_DEV}" \
--set XCURSOR_THEME "${env.XCURSOR_THEME}"'';
in
''
for prog in $out/bin/* $out/bin/examples/*; do
if [ -f "$prog" -a -x "$prog" ]; then
wrapProgram "$prog" \
${linuxWrapArgs}
fi
done
'';
}