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 bc1efaa7d0
commit c0f86645bc
No known key found for this signature in database
2 changed files with 59 additions and 23 deletions

54
flake.lock generated
View file

@ -27,9 +27,7 @@
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": [
"rust-overlay"
]
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1683505101,
@ -45,6 +43,27 @@
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1684045209,
"narHash": "sha256-d6WRNsb5+P7wocC/wCMjkvF0pycKuZ7SHgj5NGmESNQ=",
"owner": "nix-community",
"repo": "fenix",
"rev": "7c8be7e3312ba06dc95491a44c3c9ba71a175bc4",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -99,27 +118,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": 1684005690,
"narHash": "sha256-m0Dya15vVk4swQdWKqDYHmdU3cirySRjaQ6EgMa2Mcg=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "cbd14e98403dc5e19f19fdf913808656d81a0516",
"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": 1684030847,
"narHash": "sha256-z4tOxaN9Cl8C80u6wyZBpPt9A9MbL21fZ3zdB/vG+AU=",
"lastModified": 1684117262,
"narHash": "sha256-ZSF4CZqeyk6QwTjal73KPMuTWiU6w/p8ygEimrPb7u4=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "aa1480f16bec7dda3c62b8cdb184c7e823331ba2",
"rev": "4679872d2dd3e94ffef75efcbf77ea11549d90a7",
"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 ./.;