refactor(rust): update the way the rust.srcToolchain default works and also some defaultText
This commit is contained in:
+16
-8
@@ -29,7 +29,7 @@
|
|||||||
manifest = (lib.importTOML "${src}/Cargo.toml").package;
|
manifest = (lib.importTOML "${src}/Cargo.toml").package;
|
||||||
|
|
||||||
craneLib =
|
craneLib =
|
||||||
if builtins.pathExists cfg.srcToolchain
|
if cfg.srcToolchain != null && builtins.pathExists cfg.srcToolchain
|
||||||
then
|
then
|
||||||
(inputs.crane.mkLib (pkgs.extend inputs.rust-overlay.overlays.default)).overrideToolchain (
|
(inputs.crane.mkLib (pkgs.extend inputs.rust-overlay.overlays.default)).overrideToolchain (
|
||||||
p: p.rust-bin.fromRustupToolchainFile cfg.srcToolchain
|
p: p.rust-bin.fromRustupToolchainFile cfg.srcToolchain
|
||||||
@@ -61,18 +61,26 @@
|
|||||||
description = "A path to the filtered directory of the root of the crate.";
|
description = "A path to the filtered directory of the root of the crate.";
|
||||||
type = lib.types.path;
|
type = lib.types.path;
|
||||||
default = craneLib.cleanCargoSource cfg.src;
|
default = craneLib.cleanCargoSource cfg.src;
|
||||||
defaultText = lib.literalExpression "config.krantz.rust.craneLib cfg.src";
|
defaultText = lib.literalExpression "config.krantz.rust.craneLib.cleanCargoSource cfg.src";
|
||||||
example = lib.literalExpression "./.";
|
example = lib.literalExpression "./.";
|
||||||
};
|
};
|
||||||
srcToolchain = lib.mkOption {
|
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.";
|
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;
|
type = lib.types.nullOr lib.types.path;
|
||||||
default = "${
|
default =
|
||||||
if cfg.src != null
|
if cfg.src != null
|
||||||
then cfg.src
|
then cfg.src + "/rust-toolchain.toml"
|
||||||
else "/dev/null"
|
else null;
|
||||||
}/rust-toolchain.toml";
|
defaultText =
|
||||||
defaultText = lib.literalExpression "cfg.src + \"/rust-toolchain.toml\"";
|
lib.literalExpression
|
||||||
|
/*
|
||||||
|
nix
|
||||||
|
*/
|
||||||
|
''
|
||||||
|
if cfg.src != null
|
||||||
|
then cfg.src + "/rust-toolchain.toml"
|
||||||
|
else null;
|
||||||
|
'';
|
||||||
example = lib.literalExpression "./rust-toolchain";
|
example = lib.literalExpression "./rust-toolchain";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user