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:41:25 +05:30
parent 92eb12ce08
commit 4efc08c8ec
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": [
"nixpkgs" "nixpkgs"
], ],
"rust-overlay": [ "rust-overlay": "rust-overlay"
"rust-overlay"
]
}, },
"locked": { "locked": {
"lastModified": 1683505101, "lastModified": 1683505101,
@ -45,6 +43,27 @@
"type": "github" "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-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -99,27 +118,46 @@
"inputs": { "inputs": {
"advisory-db": "advisory-db", "advisory-db": "advisory-db",
"crane": "crane", "crane": "crane",
"fenix": "fenix",
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs"
"rust-overlay": "rust-overlay" }
},
"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": { "rust-overlay": {
"inputs": { "inputs": {
"flake-utils": [ "flake-utils": [
"crane",
"flake-utils" "flake-utils"
], ],
"nixpkgs": [ "nixpkgs": [
"crane",
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1684030847, "lastModified": 1684117262,
"narHash": "sha256-z4tOxaN9Cl8C80u6wyZBpPt9A9MbL21fZ3zdB/vG+AU=", "narHash": "sha256-ZSF4CZqeyk6QwTjal73KPMuTWiU6w/p8ygEimrPb7u4=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "aa1480f16bec7dda3c62b8cdb184c7e823331ba2", "rev": "4679872d2dd3e94ffef75efcbf77ea11549d90a7",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

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