-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
68 lines (54 loc) · 1.69 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
{
description = "A dev environment for Rust.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
nixConfig = {
bash-prompt-prefix = "(rust-dev) ";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
# Specify Rust version here
_rustToolchain = (pkgs.rust-bin.stable.latest.default.override {
extensions = ["rust-src" "cargo" "rustc"];
});
_rustPlatform = pkgs.makeRustPlatform {
rustc = _rustToolchain;
cargo = _rustToolchain;
rust-src = _rustToolchain;
};
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
in {
packages = {
mimi = _rustPlatform.buildRustPackage {
pname = manifest.name;
inherit (manifest) version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
preCheck = ''
export RUST_BACKTRACE=1
'';
};
# Default target for nix commands
default = self.packages.${system}.mimi;
};
devShells.default = pkgs.mkShell {
name = "rust-dev";
buildInputs = with pkgs; [
_rustToolchain
rust-analyzer
];
RUST_SRC_PATH = "${_rustToolchain}/lib/rustlib/src/rust/library";
CARGO_TERM_COLOR = "always";
# RUST_BACKTRACE = "full";
};
}
);
}