-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
54 lines (46 loc) · 1.76 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
{
description = "A Nix-flake-based Rust development environment";
# GitHub URLs for the Nix inputs we're using
inputs = {
# Simply the greatest package repository on the planet
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# A set of helper functions for using flakes
flake-utils.url = "github:numtide/flake-utils";
# A utility library for working with Rust
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.inputs.flake-utils.follows = "flake-utils";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [
# This overlay adds the "rust-bin" package to nixpkgs
(import rust-overlay)
];
# System-specific nixpkgs with rust-overlay applied
pkgs = import nixpkgs { inherit system overlays; };
# Use the specific version of the Rust toolchain specified by the toolchain file
localRust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
# Cargo subcommands commonly used in Rust projects
cargoSubCommands = with pkgs; [
cargo-audit
cargo-edit
cargo-release
cargo-watch
];
# Placeholder for utilities commonly used in Rust projects (but not in this example project)
others = with pkgs; [ just ];
in {
devShells = {
default = pkgs.mkShell {
# Packages included in the environment
buildInputs = [ localRust ] ++ cargoSubCommands ++ others;
# Run when the shell is started up
shellHook = ''
${localRust}/bin/cargo --version
'';
};
};
});
}