Skip to content

Commit a72ac37

Browse files
authored
Add rust-toolchain and nix flake (#20)
rust-toolchain will allow us to ensure that everyone developing on the repository is using the same version of rust. Nix flake will provide out-of-the-box development environment for nix users with the right rust version.
1 parent 4d4418e commit a72ac37

File tree

4 files changed

+150
-0
lines changed

4 files changed

+150
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44

55
.vscode/*
66
.DS_Store
7+
8+
# Allow everyone to customize .envrc
9+
/.envrc
10+
# Output / cache from direnv
11+
/.direnv
12+
# Output from nix
13+
/result

flake.lock

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
# This is a Nix Flake that defines development environment for this project.
3+
#
4+
# Using Nix is NOT required to develop this project.
5+
#
6+
# Nix provides a declariative way to define reproducible development environment
7+
# and aims to remove the issue of "works on my machine".
8+
#
9+
# If you use Nix, you can install and activate all dependencies required to
10+
# develop on this project with:
11+
#
12+
# $ nix develop
13+
#
14+
# If in addition you have `direnv` installed, you can create `.envrc` file with
15+
# `use flake` content, so that development environment activates automatically
16+
# when the project root directory is entered.
17+
#
18+
# More information:
19+
# - Nix: https://nixos.org
20+
# - Nix flakes: https://wiki.nixos.org/wiki/Flakes
21+
# - Direnv: https://direnv.net
22+
description = "The New Nushell Parser";
23+
24+
inputs = {
25+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
26+
flake-utils.url = "github:numtide/flake-utils";
27+
rust-overlay = {
28+
url = "github:oxalica/rust-overlay";
29+
inputs.nixpkgs.follows = "nixpkgs";
30+
};
31+
};
32+
33+
outputs =
34+
{
35+
nixpkgs,
36+
rust-overlay,
37+
flake-utils,
38+
...
39+
}:
40+
flake-utils.lib.eachDefaultSystem (
41+
system:
42+
let
43+
overlays = [ (import rust-overlay) ];
44+
pkgs = import nixpkgs { inherit system overlays; };
45+
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
46+
in
47+
{
48+
devShells.default = pkgs.mkShell {
49+
nativeBuildInputs = [
50+
(rustToolchain.override {
51+
extensions = [
52+
"rust-src"
53+
"rust-analyzer"
54+
];
55+
})
56+
];
57+
};
58+
}
59+
);
60+
}

rust-toolchain.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
# The default profile includes rustc, rust-std, cargo, rust-docs, rustfmt and clippy.
44
# https://rust-lang.github.io/rustup/concepts/profiles.html
55
profile = "default"
6+
# When updating, it might be necessary to run `nix flake update`.
67
channel = "1.81.0"

0 commit comments

Comments
 (0)