diff --git a/flake.lock b/flake.lock index aa71771..d1703c0 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,24 @@ { "nodes": { + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1643437378, + "narHash": "sha256-nciShE41PZ5wU54Sm7xSLsZxzgcSlab2UNrf5GGjndc=", + "owner": "nix-community", + "repo": "fenix", + "rev": "af56bbdd36b7644ea466cef5a4b1163d923296a7", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flakeCompat": { "flake": false, "locked": { @@ -33,25 +52,46 @@ }, "nixpkgs": { "locked": { - "lastModified": 1643119265, - "narHash": "sha256-mmDEctIkHSWcC/HRpeaw6QOe+DbNOSzc0wsXAHOZWwo=", + "lastModified": 1643347846, + "narHash": "sha256-O0tyXF//ppRpe9yT1Uu5n34yI2MWDyY6ZiJ4Qn5zIkE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b05d2077ebe219f6a47825767f8bab5c6211d200", + "rev": "5bb20f9dc70e9ee16e21cc404b6508654931ce41", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { + "fenix": "fenix", "flakeCompat": "flakeCompat", "flakeUtils": "flakeUtils", - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "fenix", + "nixpkgs" + ] + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1643383912, + "narHash": "sha256-QtpTMM54jozLsjpOt3tMvnAoL+nc5bezbwxilHooOzM=", + "owner": "rust-analyzer", + "repo": "rust-analyzer", + "rev": "6634eaf13a7e3a2b30f98f6e69af952f2d760df4", + "type": "github" + }, + "original": { + "owner": "rust-analyzer", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index ef29276..61ff3fb 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,9 @@ flakeCompat.url = github:edolstra/flake-compat; flakeCompat.flake = false; flakeUtils.url = "github:numtide/flake-utils"; - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nixpkgs.follows = "fenix/nixpkgs"; + # add https://app.cachix.org/cache/nix-community to your `nix.conf` + fenix.url = "github:nix-community/fenix"; }; outputs = inputs: @@ -11,6 +13,7 @@ ( system: let + toolchain = "stable"; nixpkgs = import inputs.nixpkgs { inherit system; }; cargoToml = builtins.fromTOML ( builtins.readFile ./Cargo.toml ); in @@ -21,7 +24,9 @@ }; defaultApp = { type = "app"; program = "${ inputs.self.defaultPackage.${ system } }/bin/alejandra"; }; defaultPackage = - nixpkgs.rustPlatform.buildRustPackage + (nixpkgs.makeRustPlatform { + inherit (inputs.fenix.packages.${ system }.${ toolchain }) cargo rustc; + }).buildRustPackage { pname = cargoToml.package.name; version = @@ -43,11 +48,16 @@ devShell = nixpkgs.mkShell { - packages = [ nixpkgs.cargo-tarpaulin nixpkgs.rustup ]; - shellHook = - '' - rustup toolchain install nightly - ''; + packages = [ + inputs.fenix.packages.${ system }.rust-analyzer + (inputs.fenix.packages.${ system }.${ toolchain }.withComponents [ + "cargo" + "clippy" + "rust-src" + "rustc" + "rustfmt" + ]) + ]; }; packages = { nixpkgsFormatted =