From 0d1a37eef3e3954cc698b577edbc37eaa736b859 Mon Sep 17 00:00:00 2001 From: Reed Krantz Date: Sun, 7 Jun 2026 21:58:16 -0500 Subject: [PATCH] feat: add treefmt to flake root --- .rumdl.toml | 8 ++++++++ README.md | 2 +- flake.nix | 10 +++++++++- rust-esp32-c6/template/.rumdl.toml | 4 ++-- rust/default.nix | 17 +++++++++++------ rust/template/.rumdl.toml | 4 ++-- 6 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 .rumdl.toml diff --git a/.rumdl.toml b/.rumdl.toml new file mode 100644 index 0000000..606a151 --- /dev/null +++ b/.rumdl.toml @@ -0,0 +1,8 @@ +[global] +disable = [ + # line length limits + "MD013", +] + +[MD057] +absolute-links = "relative_to_roots" diff --git a/README.md b/README.md index f212a74..92ef307 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # project-templates -Nix flake templates for initializing new projects. \ No newline at end of file +Nix flake templates for initializing new projects. diff --git a/flake.nix b/flake.nix index f196736..4927704 100644 --- a/flake.nix +++ b/flake.nix @@ -36,6 +36,7 @@ ./rust ./rust-esp32-c6 + inputs.treefmt-nix.flakeModule flake-parts.flakeModules.flakeModules # define the flake.templates option ({lib, ...}: { @@ -57,6 +58,13 @@ 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 + }; + }; }; } diff --git a/rust-esp32-c6/template/.rumdl.toml b/rust-esp32-c6/template/.rumdl.toml index caf5b29..606a151 100644 --- a/rust-esp32-c6/template/.rumdl.toml +++ b/rust-esp32-c6/template/.rumdl.toml @@ -1,7 +1,7 @@ [global] disable = [ - # line length limits - "MD013", + # line length limits + "MD013", ] [MD057] diff --git a/rust/default.nix b/rust/default.nix index 7388ed9..84b0731 100644 --- a/rust/default.nix +++ b/rust/default.nix @@ -44,8 +44,9 @@ # Build *just* the cargo dependencies, so we can reuse # all of that work (e.g. via cachix) when running in CI cargoArtifacts = craneLib.buildDepsOnly ({ - inherit src buildInputs nativeBuildInputs; - } // cfg.cargoArtifacts.extraAttrs); + inherit src buildInputs nativeBuildInputs; + } + // cfg.cargoArtifacts.extraAttrs); in { options.krantz.rust = { enable = lib.mkEnableOption "building a cargo project with crane"; @@ -66,7 +67,11 @@ 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 = "${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\""; example = lib.literalExpression "./rust-toolchain"; }; @@ -192,10 +197,10 @@ # Your custom packages # Accessible through 'nix build', 'nix shell', 'nix run', etc packages = lib.mkIf cfg.package.enable { - ${cfg.package.name} = - craneLib.buildPackage ({ + ${cfg.package.name} = craneLib.buildPackage ({ inherit src buildInputs nativeBuildInputs cargoArtifacts; - } // cfg.package.extraAttrs); + } + // cfg.package.extraAttrs); }; # Formatter for nix files, available through 'nix fmt' diff --git a/rust/template/.rumdl.toml b/rust/template/.rumdl.toml index caf5b29..606a151 100644 --- a/rust/template/.rumdl.toml +++ b/rust/template/.rumdl.toml @@ -1,7 +1,7 @@ [global] disable = [ - # line length limits - "MD013", + # line length limits + "MD013", ] [MD057]