feat: add support for custom rust toolchains compatible with rustup

This commit is contained in:
2026-05-31 20:16:39 -05:00
parent 30264efdb4
commit 3fefb3570a
3 changed files with 41 additions and 1 deletions
Generated
+21
View File
@@ -262,9 +262,30 @@
"crane": "crane",
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay",
"treefmt-nix": "treefmt-nix"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1780197589,
"narHash": "sha256-FVCr2Ij/jKf59a4LW481eeOF6rJRreOBrVgW/aUBTrw=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "21632e942d89bf1cce4e5a63d7e58a215a0cbfcc",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
+5
View File
@@ -13,6 +13,11 @@
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
cadquery = {
url = "github:vinszent/cq-flake";
# unfortunately dependencies are out of date so this needs it's own nixpkgs
+15 -1
View File
@@ -25,10 +25,17 @@
}: let
cfg = config.krantz.rust;
craneLib = inputs.crane.mkLib pkgs;
src = cfg.srcFiltered;
manifest = (lib.importTOML "${src}/Cargo.toml").package;
craneLib =
if builtins.pathExists cfg.srcToolchain
then
(inputs.crane.mkLib (pkgs.extend inputs.rust-overlay.overlays.default)).overrideToolchain (
p: p.rust-bin.fromRustupToolchainFile cfg.srcToolchain
)
else inputs.crane.mkLib pkgs;
buildInputs = cfg.runtimeDeps;
# build dependencies
@@ -55,6 +62,13 @@
defaultText = lib.literalExpression "config.krantz.rust.craneLib cfg.src";
example = lib.literalExpression "./.";
};
srcToolchain = lib.mkOption {
description = "A path to the rust-toolchain(.toml) file for the repo. Will use the toolchain from nixpkgs if the file does not exist.";
type = lib.types.path;
default = "${cfg.src}/rust-toolchain.toml";
defaultText = lib.literalExpression "cfg.src + \"/rust-toolchain.toml\"";
example = lib.literalExpression "./rust-toolchain";
};
runtimeDeps = lib.mkOption {
description = "Packages needed for the app to run.";