ci/treefmt: add markdown-code-runner (#427460)

authored by Wolfgang Walther and committed by GitHub be57485f c5739c7f

+28 -40
+17
ci/default.nix
··· 75 75 includes = [ "*" ]; 76 76 priority = 1; 77 77 }; 78 + 79 + # TODO: Upstream this into treefmt-nix eventually: 80 + # https://github.com/numtide/treefmt-nix/issues/387 81 + settings.formatter.markdown-code-runner = { 82 + command = pkgs.lib.getExe pkgs.markdown-code-runner; 83 + options = 84 + let 85 + config = pkgs.writers.writeTOML "markdown-code-runner-config" { 86 + presets.nixfmt = { 87 + language = "nix"; 88 + command = [ (pkgs.lib.getExe pkgs.nixfmt) ]; 89 + }; 90 + }; 91 + in 92 + [ "--config=${config}" ]; 93 + includes = [ "*.md" ]; 94 + }; 78 95 }; 79 96 fs = pkgs.lib.fileset; 80 97 nixFilesSrc = fs.toSource {
-1
doc/doc-support/package.nix
··· 137 137 138 138 tests = { 139 139 manpage-urls = callPackage ../tests/manpage-urls.nix { }; 140 - check-nix-code-blocks = callPackage ../tests/check-nix-code-blocks.nix { }; 141 140 }; 142 141 }; 143 142 }
-32
doc/tests/check-nix-code-blocks.nix
··· 1 - { 2 - runCommand, 3 - markdown-code-runner, 4 - nixfmt-rfc-style, 5 - }: 6 - 7 - runCommand "manual_check-nix-code-blocks" 8 - { 9 - nativeBuildInputs = [ 10 - markdown-code-runner 11 - nixfmt-rfc-style 12 - ]; 13 - } 14 - '' 15 - set +e 16 - 17 - mdcr --check --config ${./mdcr-config.toml} ${./..} 18 - 19 - if [ $? -ne 0 ]; then 20 - cat <<EOF 21 - Error: `mdcr` command failed. Please make sure the Nix code snippets in Markdown files are correctly formatted. 22 - 23 - Run this command from the Nixpkgs repository root for automatic formatting: 24 - 25 - mdcr --log debug --config ${toString ./..}/tests/mdcr-config.toml ${toString ./..} 26 - 27 - EOF 28 - exit 1 29 - fi 30 - 31 - touch "$out" 32 - ''
-3
doc/tests/mdcr-config.toml
··· 1 - [presets.nixfmt] 2 - language = "nix" 3 - command = ["nixfmt"]
+9 -2
nixos/doc/manual/development/modular-services.md
··· 45 45 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: 46 46 47 47 ```nix 48 - { config, options, lib, ... }: { 48 + { 49 + config, 50 + options, 51 + lib, 52 + ... 53 + }: 54 + { 49 55 _class = "service"; 50 56 config = { 51 57 process.argv = [ (lib.getExe config.foo.program) ]; 52 - } // lib.optionalAttrs (options?systemd) { 58 + } 59 + // lib.optionalAttrs (options ? systemd) { 53 60 # ... systemd-specific definitions ... 54 61 }; 55 62 }
+2 -2
nixos/modules/services/mail/mailman.md
··· 19 19 local_recipient_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ]; 20 20 relay_domains = [ "hash:/var/lib/mailman/data/postfix_domains" ]; 21 21 smtpd_tls_chain_files = [ 22 - config.security.acme.certs."lists.example.org".directory + "/full.pem" 23 - config.security.acme.certs."lists.example.org".directory + "/key.pem" 22 + (config.security.acme.certs."lists.example.org".directory + "/full.pem") 23 + (config.security.acme.certs."lists.example.org".directory + "/key.pem") 24 24 ]; 25 25 }; 26 26 };