Skip to content

Commit

Permalink
Add rust-toolchain and nix flake.
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 committed Dec 5, 2024
1 parent efa0c9e commit 7df799d
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# If nix is installed hook into it.
if [ $(which nix) ]
then
use flake
fi

# If nu is the current shell use toolkit.nu
if [ $(echo $SHELL) == $(which nu) ]
then
nu -e "use toolkit.nu"
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

.vscode/*
.DS_Store
.direnv
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.

37 changes: 37 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
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
pkgs.rust-analyzer
];
};
}
);
}
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
profile = "default"
channel = "1.81.0"

0 comments on commit 7df799d

Please sign in to comment.