From 9e7dd2e3ddb2d3b7b7afeb5167480f8764423382 Mon Sep 17 00:00:00 2001 From: Bauke Date: Fri, 19 Jan 2024 14:00:02 +0100 Subject: [PATCH] Add Rust and the toolchain via an overlay. --- .gitignore | 1 + flake.lock | 77 ++++++++++++++++++++++++++++++++++++++++--- flake.nix | 10 ++++-- rustup-toolchain.toml | 3 ++ shell.nix | 10 +++++- 5 files changed, 93 insertions(+), 8 deletions(-) create mode 100644 rustup-toolchain.toml diff --git a/.gitignore b/.gitignore index 7973c82..d8027d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .direnv/ +.vscode/ coverage/ debug/ hooked-book/book/ diff --git a/flake.lock b/flake.lock index b88d363..43cde84 100644 --- a/flake.lock +++ b/flake.lock @@ -18,13 +18,31 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1705403940, - "narHash": "sha256-bl7E3w35Bleiexg01WsN0RuAQEL23HaQeNBC2zjt+9w=", + "lastModified": 1705635624, + "narHash": "sha256-DU0schxQOtBNO1c9hUsgYl+QMOXQMfRT7Qw/mg+ayno=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f0326542989e1bdac955ad6269b334a8da4b0c95", + "rev": "4471857c0a4a8a0ffc7bdbeaf1b998746ce12a82", "type": "github" }, "original": { @@ -32,10 +50,46 @@ "type": "indirect" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1705630663, + "narHash": "sha256-f+kcR17ZtwMyCEtNAfpD0Mv6qObNKoJ41l+6deoaXi8=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "47cac072a313d9cce884b9ea418d2bf712fa23dd", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } }, "systems": { @@ -52,6 +106,21 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 5f8a2c5..b394bb9 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,14 @@ { - inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay.url = "github:oxalica/rust-overlay"; + }; - outputs = { self, nixpkgs, flake-utils }: + outputs = { self, nixpkgs, flake-utils, rust-overlay }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; in { devShells.default = import ./shell.nix { inherit pkgs; }; diff --git a/rustup-toolchain.toml b/rustup-toolchain.toml new file mode 100644 index 0000000..0a15096 --- /dev/null +++ b/rustup-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +components = ["cargo", "clippy", "rustfmt", "rust-src"] diff --git a/shell.nix b/shell.nix index d4e3047..b81e85f 100644 --- a/shell.nix +++ b/shell.nix @@ -2,6 +2,14 @@ with pkgs; +let + rustup-toolchain = rust-bin.fromRustupToolchainFile ./rustup-toolchain.toml; +in mkShell rec { - packages = [ cargo-make mdbook mdbook-linkcheck ]; + packages = [ + cargo-make + mdbook + mdbook-linkcheck + rustup-toolchain + ]; }