Skip to content

Commit

Permalink
Add rust-toolchain and nix flake (#20)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
doriath authored Jan 8, 2025
1 parent 4d4418e commit a72ac37
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@

.vscode/*
.DS_Store

# Allow everyone to customize .envrc
/.envrc
# Output / cache from direnv
/.direnv
# Output from nix
/result
82 changes: 82 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
# This is a Nix Flake that defines development environment for this project.
#
# Using Nix is NOT required to develop this project.
#
# Nix provides a declariative way to define reproducible development environment
# and aims to remove the issue of "works on my machine".
#
# If you use Nix, you can install and activate all dependencies required to
# develop on this project with:
#
# $ nix develop
#
# If in addition you have `direnv` installed, you can create `.envrc` file with
# `use flake` content, so that development environment activates automatically
# when the project root directory is entered.
#
# More information:
# - Nix: https://nixos.org
# - Nix flakes: https://wiki.nixos.org/wiki/Flakes
# - Direnv: https://direnv.net
description = "The New Nushell Parser";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs =
{
nixpkgs,
rust-overlay,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
in
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
(rustToolchain.override {
extensions = [
"rust-src"
"rust-analyzer"
];
})
];
};
}
);
}
1 change: 1 addition & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# The default profile includes rustc, rust-std, cargo, rust-docs, rustfmt and clippy.
# https://rust-lang.github.io/rustup/concepts/profiles.html
profile = "default"
# When updating, it might be necessary to run `nix flake update`.
channel = "1.81.0"

0 comments on commit a72ac37

Please sign in to comment.