Throw an error if there is channel prefix

For example if someone just puts in a date

Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
Marcel Müller 2025-03-04 11:04:11 +01:00
parent 520a91a22e
commit bd031f9105
2 changed files with 15 additions and 9 deletions

View file

@ -32,7 +32,7 @@
lints = [
{
toolchain = "2025-01-09";
toolchain = "nightly-2025-01-09";
package = dylintLib.cargo-dylint-general;
}
];

View file

@ -13,13 +13,17 @@ let
driver_names = lib.groupBy (v: v.toolchain) lints;
driverMap = builtins.mapAttrs (
name: _:
mkCargoDylintDriver "${name}" (
pkgs.rust-bin.nightly."${lib.removePrefix "nightly-" name}".default.override {
extensions = [
"rustc-dev"
];
}
)
lib.throwIf ((builtins.match "^[[:digit:]].*$" name) != null)
"Rust toolchains generally do not start with numbers. Make sure you include the channel, as in `nightly-YYYY-MM-DD`. Given '${name}'"
mkCargoDylintDriver
"${name}"
(
pkgs.rust-bin.nightly."${lib.removePrefix "nightly-" name}".default.override {
extensions = [
"rustc-dev"
];
}
)
) driver_names;
drivers = pkgs.runCommandLocal "dylint-drivers" { } ''
mkdir -p $out
@ -37,6 +41,8 @@ pkgs.runCommandLocal "cargo-dylint-wrapped"
}
''
makeWrapper ${cargo-dylint}/bin/cargo-dylint $out/bin/cargo-dylint \
--set-default DYLINT_LIBRARY_PATH "${lib.strings.makeLibraryPath (builtins.map (v: v.package) lints)}" \
--set-default DYLINT_LIBRARY_PATH "${
lib.strings.makeLibraryPath (builtins.map (v: v.package) lints)
}" \
--set DYLINT_DRIVER_PATH ${drivers};
''