feat: add treefmt to flake root
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
[global]
|
||||||
|
disable = [
|
||||||
|
# line length limits
|
||||||
|
"MD013",
|
||||||
|
]
|
||||||
|
|
||||||
|
[MD057]
|
||||||
|
absolute-links = "relative_to_roots"
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
./rust
|
./rust
|
||||||
./rust-esp32-c6
|
./rust-esp32-c6
|
||||||
|
|
||||||
|
inputs.treefmt-nix.flakeModule
|
||||||
flake-parts.flakeModules.flakeModules
|
flake-parts.flakeModules.flakeModules
|
||||||
# define the flake.templates option
|
# define the flake.templates option
|
||||||
({lib, ...}: {
|
({lib, ...}: {
|
||||||
@@ -57,6 +58,13 @@
|
|||||||
|
|
||||||
systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin"];
|
systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin"];
|
||||||
|
|
||||||
perSystem = {pkgs, ...}: {formatter = pkgs.alejandra;};
|
perSystem = {pkgs, ...}: {
|
||||||
|
treefmt.programs = {
|
||||||
|
alejandra.enable = true; # nix
|
||||||
|
taplo.enable = true; # toml
|
||||||
|
rumdl-check.enable = true; # markdown
|
||||||
|
rumdl-format.enable = true; # markdown
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-5
@@ -45,7 +45,8 @@
|
|||||||
# all of that work (e.g. via cachix) when running in CI
|
# all of that work (e.g. via cachix) when running in CI
|
||||||
cargoArtifacts = craneLib.buildDepsOnly ({
|
cargoArtifacts = craneLib.buildDepsOnly ({
|
||||||
inherit src buildInputs nativeBuildInputs;
|
inherit src buildInputs nativeBuildInputs;
|
||||||
} // cfg.cargoArtifacts.extraAttrs);
|
}
|
||||||
|
// cfg.cargoArtifacts.extraAttrs);
|
||||||
in {
|
in {
|
||||||
options.krantz.rust = {
|
options.krantz.rust = {
|
||||||
enable = lib.mkEnableOption "building a cargo project with crane";
|
enable = lib.mkEnableOption "building a cargo project with crane";
|
||||||
@@ -66,7 +67,11 @@
|
|||||||
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.path;
|
||||||
default = "${if cfg.src != null then cfg.src else "/dev/null"}/rust-toolchain.toml";
|
default = "${
|
||||||
|
if cfg.src != null
|
||||||
|
then cfg.src
|
||||||
|
else "/dev/null"
|
||||||
|
}/rust-toolchain.toml";
|
||||||
defaultText = lib.literalExpression "cfg.src + \"/rust-toolchain.toml\"";
|
defaultText = lib.literalExpression "cfg.src + \"/rust-toolchain.toml\"";
|
||||||
example = lib.literalExpression "./rust-toolchain";
|
example = lib.literalExpression "./rust-toolchain";
|
||||||
};
|
};
|
||||||
@@ -192,10 +197,10 @@
|
|||||||
# Your custom packages
|
# Your custom packages
|
||||||
# Accessible through 'nix build', 'nix shell', 'nix run', etc
|
# Accessible through 'nix build', 'nix shell', 'nix run', etc
|
||||||
packages = lib.mkIf cfg.package.enable {
|
packages = lib.mkIf cfg.package.enable {
|
||||||
${cfg.package.name} =
|
${cfg.package.name} = craneLib.buildPackage ({
|
||||||
craneLib.buildPackage ({
|
|
||||||
inherit src buildInputs nativeBuildInputs cargoArtifacts;
|
inherit src buildInputs nativeBuildInputs cargoArtifacts;
|
||||||
} // cfg.package.extraAttrs);
|
}
|
||||||
|
// cfg.package.extraAttrs);
|
||||||
};
|
};
|
||||||
|
|
||||||
# Formatter for nix files, available through 'nix fmt'
|
# Formatter for nix files, available through 'nix fmt'
|
||||||
|
|||||||
Reference in New Issue
Block a user