From d3caafc32f68040ba90848d73555c8ed304af02d Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Tue, 5 Aug 2025 17:08:01 +0200 Subject: [PATCH 1/3] nixos/doc/mailman: fix syntax in code block --- nixos/modules/services/mail/mailman.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/mail/mailman.md b/nixos/modules/services/mail/mailman.md index d5a8e5ba84fa..341c3d6744b6 100644 --- a/nixos/modules/services/mail/mailman.md +++ b/nixos/modules/services/mail/mailman.md @@ -19,8 +19,8 @@ For a basic configuration with Postfix as the MTA, the following settings are su local_recipient_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ]; relay_domains = [ "hash:/var/lib/mailman/data/postfix_domains" ]; smtpd_tls_chain_files = [ - config.security.acme.certs."lists.example.org".directory + "/full.pem" - config.security.acme.certs."lists.example.org".directory + "/key.pem" + (config.security.acme.certs."lists.example.org".directory + "/full.pem") + (config.security.acme.certs."lists.example.org".directory + "/key.pem") ]; }; }; From fed181fac11b376fc242c4805b91d852902fbc35 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Tue, 5 Aug 2025 17:08:25 +0200 Subject: [PATCH 2/3] nixos/doc/modular-services: run nixfmt on code blocks --- nixos/doc/manual/development/modular-services.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nixos/doc/manual/development/modular-services.md b/nixos/doc/manual/development/modular-services.md index eadead5c4a40..c34871f7725f 100644 --- a/nixos/doc/manual/development/modular-services.md +++ b/nixos/doc/manual/development/modular-services.md @@ -45,11 +45,18 @@ So note that the default value of `system.services.` is not a complete ser It is possible to write service modules that are portable. This is done by either avoiding the `systemd` option tree, or by defining process-manager-specific definitions in an optional way: ```nix -{ config, options, lib, ... }: { +{ + config, + options, + lib, + ... +}: +{ _class = "service"; config = { process.argv = [ (lib.getExe config.foo.program) ]; - } // lib.optionalAttrs (options?systemd) { + } + // lib.optionalAttrs (options ? systemd) { # ... systemd-specific definitions ... }; } From a7b3b2584a7b9f204f634714fe9fbe3a3965b06c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Tue, 22 Jul 2025 16:12:42 +0200 Subject: [PATCH 3/3] ci/treefmt: add markdown-code-runner This was run as a test in `doc/tests/check-nix-code-blocks.nix` before, but its DX can be improved: By including it in `treefmt` we get better error reporting and auto-fixing, as well as running it on *all* markdown files (including READMEs etc.) for free. --- ci/default.nix | 17 +++++++++++++++ doc/doc-support/package.nix | 1 - doc/tests/check-nix-code-blocks.nix | 32 ----------------------------- doc/tests/mdcr-config.toml | 3 --- 4 files changed, 17 insertions(+), 36 deletions(-) delete mode 100644 doc/tests/check-nix-code-blocks.nix delete mode 100644 doc/tests/mdcr-config.toml diff --git a/ci/default.nix b/ci/default.nix index eaa1879c34b4..727e591a90b8 100644 --- a/ci/default.nix +++ b/ci/default.nix @@ -75,6 +75,23 @@ let includes = [ "*" ]; priority = 1; }; + + # TODO: Upstream this into treefmt-nix eventually: + # https://github.com/numtide/treefmt-nix/issues/387 + settings.formatter.markdown-code-runner = { + command = pkgs.lib.getExe pkgs.markdown-code-runner; + options = + let + config = pkgs.writers.writeTOML "markdown-code-runner-config" { + presets.nixfmt = { + language = "nix"; + command = [ (pkgs.lib.getExe pkgs.nixfmt) ]; + }; + }; + in + [ "--config=${config}" ]; + includes = [ "*.md" ]; + }; }; fs = pkgs.lib.fileset; nixFilesSrc = fs.toSource { diff --git a/doc/doc-support/package.nix b/doc/doc-support/package.nix index aefc301ec81c..8ed6865a1c90 100644 --- a/doc/doc-support/package.nix +++ b/doc/doc-support/package.nix @@ -137,7 +137,6 @@ stdenvNoCC.mkDerivation ( tests = { manpage-urls = callPackage ../tests/manpage-urls.nix { }; - check-nix-code-blocks = callPackage ../tests/check-nix-code-blocks.nix { }; }; }; } diff --git a/doc/tests/check-nix-code-blocks.nix b/doc/tests/check-nix-code-blocks.nix deleted file mode 100644 index 5ec934f6bba8..000000000000 --- a/doc/tests/check-nix-code-blocks.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ - runCommand, - markdown-code-runner, - nixfmt-rfc-style, -}: - -runCommand "manual_check-nix-code-blocks" - { - nativeBuildInputs = [ - markdown-code-runner - nixfmt-rfc-style - ]; - } - '' - set +e - - mdcr --check --config ${./mdcr-config.toml} ${./..} - - if [ $? -ne 0 ]; then - cat <