-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
95 lines (82 loc) · 2.49 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
{
inputs = {
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
systems.url = "github:nix-systems/default";
# Dev tools
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs = { flake-parts, nixpkgs, rust-overlay, systems, treefmt-nix, ... }@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import systems;
imports = [
treefmt-nix.flakeModule
];
perSystem = { config, self', pkgs, lib, system, ... }:
let
overlays = [ (import inputs.rust-overlay) ];
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pkgs = import inputs.nixpkgs {
inherit system overlays;
};
in
rec {
# Rust package
packages.default = pkgs.rustPlatform.buildRustPackage {
inherit (cargoToml.package) name version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
};
# Rust dev environment
devShells.default = pkgs.mkShell rec {
inputsFrom = [
config.treefmt.build.devShell
];
shellHook = ''
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc}
'';
buildInputs = with pkgs; [
cargo-cache
cargo-machete
cargo-unused-features
just
mold
probe-rs
fontconfig
libGL
libxkbcommon
python3
pkgs.qt5.full
pkgs.qt6.full
vulkan-headers
vulkan-loader
wayland
wayland-protocols
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
];
nativeBuildInputs = with pkgs; [
pkg-config
(rust-bin.fromRustupToolchainFile
./rust-toolchain.toml)
];
LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}";
RUST_BACKTRACE = 1;
};
treefmt.config = {
projectRootFile = "flake.nix";
programs = {
nixpkgs-fmt.enable = true;
rustfmt.enable = true;
};
};
};
};
}