feat(nix): switch to provisioning toolchains using fenix

rust-overlay's `fromRustupToolchainFile` does not provision the provided
components from the `rust-toolchain.toml` file which makes the experience
subpar compared to fenix that treats `rust-toolchain.toml` similar to rustup.
This commit is contained in:
Harsh Shandilya 2023-05-15 11:16:45 +05:30
parent 8ac5fa51cb
commit f8daba4de4
No known key found for this signature in database
2 changed files with 59 additions and 23 deletions

View File

@ -27,9 +27,7 @@
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": [
"rust-overlay"
]
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1679285709,
@ -45,6 +43,27 @@
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1684390923,
"narHash": "sha256-8LSe1K8ua8uyqc0B8wsQEY9qNCTX2h78mzUt2A7Uqhg=",
"owner": "nix-community",
"repo": "fenix",
"rev": "8a69206e50ca6a2cc4ae7a22eef4bfcbe6dbc9f6",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -96,27 +115,46 @@
"inputs": {
"advisory-db": "advisory-db",
"crane": "crane",
"fenix": "fenix",
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
"nixpkgs": "nixpkgs"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1684145961,
"narHash": "sha256-Ms99ML1P53EC50TnznmV55QwhOJtql75BbXfyiGuFvU=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "2f8cd66fb4c98026d2bdbdf17270e3472e1ca42a",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": [
"crane",
"flake-utils"
],
"nixpkgs": [
"crane",
"nixpkgs"
]
},
"locked": {
"lastModified": 1678069954,
"narHash": "sha256-52oErh9xblq9hS3eQurgKLVT8W85TpcMB7mIJCaGuIk=",
"lastModified": 1684376381,
"narHash": "sha256-XVFTXADfvBXKwo4boqfg80awUbT+JgQvlQ8uZ+Xgo1s=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "695b8bb0af23d4ad3826fe7a372a5d677ad5c2bd",
"rev": "7c9a265c2eaa5783bc18593b1aec39a85653c076",
"type": "github"
},
"original": {

View File

@ -4,6 +4,13 @@
inputs = {
nixpkgs = {url = "github:NixOS/nixpkgs/nixpkgs-unstable";};
fenix = {
url = "github:nix-community/fenix";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
flake-utils = {url = "github:numtide/flake-utils";};
flake-compat = {
@ -11,21 +18,12 @@
flake = false;
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
crane = {
url = "github:ipetkov/crane";
inputs = {
flake-compat.follows = "flake-compat";
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
rust-overlay.follows = "rust-overlay";
};
};
@ -38,20 +36,20 @@
outputs = {
self,
nixpkgs,
fenix,
crane,
flake-utils,
advisory-db,
rust-overlay,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {inherit system;};
rustStable = (import fenix {inherit pkgs;}).fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-eMJethw5ZLrJHmoN2/l0bIyQjoTX1NsvalWSscTixpI=";
};
rustStable =
pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustStable;
commonArgs = {
src = craneLib.cleanCargoSource ./.;