Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
139 lines (128 loc) · 4.39 KB
/
Copy pathflake.nix
File metadata and controls
139 lines (128 loc) · 4.39 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
description = "robolibs crate development shell";
inputs = {
# Pinned to a rev that still accepts the `kernel` arg in
# nvidia-x11/generic.nix. Newer nixpkgs (post 2026-04) dropped
# that arg, which breaks nixGL until upstream catches up. Bump
# together with nixgl when its corresponding fix lands.
nixpkgs.url = "github:NixOS/nixpkgs?rev=4c1018dae018162ec878d42fec712642d214fdfa";
rust-overlay.url = "github:oxalica/rust-overlay?rev=3c27f4c92a7d977556dd2c10bb564d9c61b375e9";
flake-utils.url = "github:numtide/flake-utils";
nixgl.url = "github:nix-community/nixGL";
};
outputs =
{ nixpkgs, rust-overlay, flake-utils, nixgl, ... }:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [
(final: prev: {
xorg = prev.xorg // {
libX11 = final.libx11;
libxcb = final.libxcb;
libxshmfence = final.libxshmfence;
};
})
(import rust-overlay)
];
pkgs = import nixpkgs {
inherit system overlays;
config = {
allowUnfree = true;
nvidia.acceptLicense = true;
};
};
nvidiaVersion = builtins.getEnv "NVIDIA_VERSION";
hasNvidia = nvidiaVersion != "";
nixglPkgs = import "${nixgl}/default.nix" ({
inherit pkgs;
} // pkgs.lib.optionalAttrs hasNvidia {
inherit nvidiaVersion;
nvidiaHash = null;
});
nixGLTarget =
if hasNvidia
then "${nixglPkgs.nixGLNvidia}/bin/nixGLNvidia-${nvidiaVersion}"
else "${nixglPkgs.nixGLIntel}/bin/nixGLIntel";
nixVulkanTarget =
if hasNvidia
then "${nixglPkgs.nixVulkanNvidia}/bin/nixVulkanNvidia-${nvidiaVersion}"
else "${nixglPkgs.nixVulkanIntel}/bin/nixVulkanIntel";
nixGLAlias = pkgs.runCommand "nixGL" { } ''
mkdir -p $out/bin
ln -s ${nixGLTarget} $out/bin/nixGL
'';
nixVulkanAlias = pkgs.runCommand "nixVulkan" { } ''
mkdir -p $out/bin
ln -s ${nixVulkanTarget} $out/bin/nixVulkan
'';
guiLibs = with pkgs; [
alsa-lib
stdenv.cc.cc.lib
udev
vulkan-loader
libxkbcommon
wayland
libx11
libxcursor
libxi
libxrandr
zlib
];
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
fonttools
brotli
pip
# Shapefile / geodata handling, for inspecting and converting the
# field files customers send (see xtra/).
pyshp
shapely
pyproj
fiona
geopandas
matplotlib
# Viewer client for the examples/python_binding scripts; version
# tracks the `rerun` crate in Cargo.toml.
rerun-sdk
]);
in
{
devShells.default = pkgs.mkShell {
packages = [
(pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rustfmt" "clippy" ];
targets = [ "wasm32-unknown-unknown" ];
})
pkgs.clang
pkgs.mold
pkgs.pkg-config
pkgs.rust-cbindgen
pkgs.trunk
pkgs.maturin
# ogrinfo / ogr2ogr for reading shapefiles from the command line.
pkgs.gdal
pythonEnv
nixGLAlias
nixVulkanAlias
nixglPkgs.nixGLIntel
nixglPkgs.nixVulkanIntel
] ++ pkgs.lib.optionals hasNvidia [
nixglPkgs.nixGLNvidia
nixglPkgs.nixVulkanNvidia
] ++ guiLibs;
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
# `cargo test --features python` links a test binary against
# libpython, so the interpreter's lib dir has to be on the loader
# path alongside the GUI libs.
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (guiLibs ++ [ pythonEnv ]);
# Pin the interpreter pyo3's build script probes, so the version it
# links matches the one on LD_LIBRARY_PATH.
PYO3_PYTHON = "${pythonEnv}/bin/python3";
# Consumed by .envrc to put this interpreter first on PATH.
PYTHON = "${pythonEnv}/bin/python3";
WGPU_VALIDATION = "0";
WGPU_DEBUG = "0";
};
}
);
}