Skip to content

Add setting to force one tool invocation per affected file #1471

@dwt

Description

@dwt

Summary

I have a comrak hook like this:

{
  "always_run": false,
  "args": [],
  "entry": "/nix/store/k523i1b277780ckli10khbz0p7vkxny4-comrak-0.48.0/bin/comrak --inplace",
  "exclude": "^$",
  "exclude_types": [],
  "fail_fast": false,
  "files": "",
  "id": "comrak",
  "language": "system",
  "name": "comrak",
  "pass_filenames": true,
  "require_serial": false,
  "stages": ["pre-commit"],
  "types": ["markdown"],
  "types_or": [],
  "verbose": false,
}

The problem is, that the comrak tool can only accept at most one file argument per invocation, but prek calls it with all affected files at once (sometimes split over multiple invocations for parallelism, but never with only one file).

I can probably write a local wrapper that works around this limitation, but I'd rather have a setting for this, especially because it would be fine to run a set of these processes in parallel.

Platform

MacOs 26.2

Version

prek 0.2.30

.pre-commit-config.yaml

# DO NOT MODIFY
# This file was generated by git-hooks.nix
{
  "default_stages": ["pre-commit"],
  "repos":
    [
      {
        "hooks":
          [
            {
              "always_run": false,
              "args": [],
              "entry": "/nix/store/k523i1b277780ckli10khbz0p7vkxny4-comrak-0.48.0/bin/comrak --inplace",
              "exclude": "^$",
              "exclude_types": [],
              "fail_fast": false,
              "files": "",
              "id": "comrak",
              "language": "system",
              "name": "comrak",
              "pass_filenames": true,
              "require_serial": false,
              "stages": ["pre-commit"],
              "types": ["markdown"],
              "types_or": [],
              "verbose": false,
            },
            {
              "always_run": false,
              "args": [],
              "entry": "/nix/store/nfp2cdrqp6h6nsqyvjfa7jmzxfmmxn7w-deadnix-1.3.1/bin/deadnix  --fail",
              "exclude": "^$",
              "exclude_types": [],
              "fail_fast": false,
              "files": "\\.nix$",
              "id": "deadnix",
              "language": "system",
              "name": "deadnix",
              "pass_filenames": true,
              "require_serial": false,
              "stages": ["pre-commit"],
              "types": ["file"],
              "types_or": [],
              "verbose": false,
            },
            {
              "always_run": false,
              "args": [],
              "entry": "/nix/store/h0ywf44n0dmhrdrnslpjl1r4sh6ia5fg-flake-checker-0.2.10/bin/flake-checker -f",
              "exclude": "^$",
              "exclude_types": [],
              "fail_fast": false,
              "files": "(^flake\\.nix$|^flake\\.lock$)",
              "id": "flake-checker",
              "language": "system",
              "name": "flake-checker",
              "pass_filenames": false,
              "require_serial": false,
              "stages": ["pre-commit"],
              "types": ["file"],
              "types_or": [],
              "verbose": false,
            },
          ],
        "repo": "local",
      },
    ],
}

Log file

❯ prek -vvv run --all-files
2026-01-24T19:31:28.723142Z DEBUG prek: 0.2.30
2026-01-24T19:31:28.723185Z DEBUG Args: ["prek", "-vvv", "run", "--all-files"]
2026-01-24T19:31:28.727814Z TRACE get_root: close time.busy=4.60ms time.idle=3.54µs
2026-01-24T19:31:28.727858Z DEBUG Git root: /Users/dwt/Code/Projekte/nix/pi
2026-01-24T19:31:28.727883Z DEBUG Found workspace root at `/Users/dwt/Code/Projekte/nix/pi`
2026-01-24T19:31:28.727894Z TRACE Include selectors: ``
2026-01-24T19:31:28.727901Z TRACE Skip selectors: ``
2026-01-24T19:31:28.727946Z DEBUG discover{root="/Users/dwt/Code/Projekte/nix/pi" config=None refresh=false}: Loaded workspace from cache
2026-01-24T19:31:28.727967Z DEBUG discover{root="/Users/dwt/Code/Projekte/nix/pi" config=None refresh=false}: Loading project configuration path=.pre-commit-config.yaml
2026-01-24T19:31:28.728448Z TRACE discover{root="/Users/dwt/Code/Projekte/nix/pi" config=None refresh=false}:read_config{path="/Users/dwt/Code/Projekte/nix/pi/.pre-commit-config.yaml"}: close time.busy=460µs time.idle=500ns
2026-01-24T19:31:28.728481Z TRACE discover{root="/Users/dwt/Code/Projekte/nix/pi" config=None refresh=false}: close time.busy=569µs time.idle=792ns
2026-01-24T19:31:28.728571Z TRACE Checking lock resource="store" path=/Users/dwt/.cache/prek/.lock
2026-01-24T19:31:28.728593Z DEBUG Acquired lock resource="store"
2026-01-24T19:31:28.728638Z DEBUG Hooks going to run: ["comrak", "deadnix", "flake-checker"]
2026-01-24T19:31:28.728863Z DEBUG Hook `comrak` does not need installation
2026-01-24T19:31:28.728895Z DEBUG Hook `deadnix` does not need installation
2026-01-24T19:31:28.728907Z DEBUG Hook `flake-checker` does not need installation
2026-01-24T19:31:28.728924Z TRACE Released lock path=/Users/dwt/.cache/prek/.lock
2026-01-24T19:31:28.728958Z TRACE collect_files:ls_files{cwd="/Users/dwt/Code/Projekte/nix/pi" path="/Users/dwt/Code/Projekte/nix/pi"}: Executing `cd /Users/dwt/Code/Projekte/nix/pi && /nix/store/pqfrzb89ldydly6hmr8qga9f0pbhik7g-git-2.51.2/bin/git ls-files -z -- /Users/dwt/Code/Projekte/nix/pi`
2026-01-24T19:31:28.734561Z TRACE collect_files:ls_files{cwd="/Users/dwt/Code/Projekte/nix/pi" path="/Users/dwt/Code/Projekte/nix/pi"}: close time.busy=410µs time.idle=5.19ms
2026-01-24T19:31:28.734600Z DEBUG collect_files: All files in the workspace: 46
2026-01-24T19:31:28.734620Z TRACE collect_files: close time.busy=482µs time.idle=5.19ms
2026-01-24T19:31:28.734670Z TRACE for_project{project=.}: close time.busy=3.25µs time.idle=666ns
2026-01-24T19:31:28.734685Z TRACE Files for project `.` after filtered: 46
2026-01-24T19:31:28.734701Z TRACE get_diff{path="/Users/dwt/Code/Projekte/nix/pi"}: Executing `/nix/store/pqfrzb89ldydly6hmr8qga9f0pbhik7g-git-2.51.2/bin/git diff -- /Users/dwt/Code/Projekte/nix/pi`
2026-01-24T19:31:28.742360Z TRACE get_diff{path="/Users/dwt/Code/Projekte/nix/pi"}: close time.busy=301µs time.idle=7.36ms
2026-01-24T19:31:28.742381Z DEBUG Running priority group with priority 0 with concurrency 14: ["comrak"]
2026-01-24T19:31:28.742940Z TRACE for_hook{hook="comrak"}: close time.busy=546µs time.idle=333ns
2026-01-24T19:31:28.742960Z TRACE Files for hook `comrak` after filtered: 8
2026-01-24T19:31:28.743017Z TRACE run{hook_id=comrak language=system}: Resolved command: /nix/store/k523i1b277780ckli10khbz0p7vkxny4-comrak-0.48.0/bin/comrak
2026-01-24T19:31:28.743090Z TRACE run{hook_id=comrak language=system}: Running comrak total_files=8 concurrency=14
2026-01-24T19:31:28.743253Z TRACE run{hook_id=comrak language=system}: Executing `cd /Users/dwt/Code/Projekte/nix/pi && /nix/store/k523i1b277780ckli10khbz0p7vkxny4-comrak-0.48.0/bin/comrak --inplace docs/bringing-up-a-new-pi.md Readme.md docs/sops.md docs/firmware-update.md`
2026-01-24T19:31:28.744567Z TRACE run{hook_id=comrak language=system}: Executing `cd /Users/dwt/Code/Projekte/nix/pi && /nix/store/k523i1b277780ckli10khbz0p7vkxny4-comrak-0.48.0/bin/comrak --inplace docs/wireless-debugging.md docs/time-machine.md docs/use-sata-drive.md docs/raspi-temperature.md`
2026-01-24T19:31:28.747673Z TRACE run{hook_id=comrak language=system}: close time.busy=2.68ms time.idle=2.02ms
2026-01-24T19:31:28.747734Z TRACE get_diff{path="/Users/dwt/Code/Projekte/nix/pi"}: Executing `/nix/store/pqfrzb89ldydly6hmr8qga9f0pbhik7g-git-2.51.2/bin/git diff -- /Users/dwt/Code/Projekte/nix/pi`
2026-01-24T19:31:28.755445Z TRACE get_diff{path="/Users/dwt/Code/Projekte/nix/pi"}: close time.busy=210µs time.idle=7.50ms
comrak...................................................................Failed
- hook id: comrak
- duration: 0.00s
- exit code: 4

  cannot have more than 1 input file with in-place mode
  cannot have more than 1 input file with in-place mode
2026-01-24T19:31:28.755529Z DEBUG Running priority group with priority 1 with concurrency 14: ["deadnix"]
2026-01-24T19:31:28.755734Z TRACE for_hook{hook="deadnix"}: close time.busy=192µs time.idle=583ns
2026-01-24T19:31:28.755763Z TRACE Files for hook `deadnix` after filtered: 15
2026-01-24T19:31:28.755825Z TRACE run{hook_id=deadnix language=system}: Resolved command: /nix/store/nfp2cdrqp6h6nsqyvjfa7jmzxfmmxn7w-deadnix-1.3.1/bin/deadnix
2026-01-24T19:31:28.755892Z TRACE run{hook_id=deadnix language=system}: Running deadnix total_files=15 concurrency=14
2026-01-24T19:31:28.756061Z TRACE run{hook_id=deadnix language=system}: Executing `cd /Users/dwt/Code/Projekte/nix/pi && /nix/store/nfp2cdrqp6h6nsqyvjfa7jmzxfmmxn7w-deadnix-1.3.1/bin/deadnix --fail hosts/pi-test/configuration.nix modules/sd-image.nix hosts/pi/time-machine.nix hosts/pi/configuration.nix`
2026-01-24T19:31:28.757288Z TRACE run{hook_id=deadnix language=system}: Executing `cd /Users/dwt/Code/Projekte/nix/pi && /nix/store/nfp2cdrqp6h6nsqyvjfa7jmzxfmmxn7w-deadnix-1.3.1/bin/deadnix --fail modules/usbc-serial.nix modules/sops.nix modules/locale.nix hosts/pi/home-automation.nix`
2026-01-24T19:31:28.758233Z TRACE run{hook_id=deadnix language=system}: Executing `cd /Users/dwt/Code/Projekte/nix/pi && /nix/store/nfp2cdrqp6h6nsqyvjfa7jmzxfmmxn7w-deadnix-1.3.1/bin/deadnix --fail modules/hardware-config.nix shell.nix modules/remote-access.nix flake.nix`
2026-01-24T19:31:28.759160Z TRACE run{hook_id=deadnix language=system}: Executing `cd /Users/dwt/Code/Projekte/nix/pi && /nix/store/nfp2cdrqp6h6nsqyvjfa7jmzxfmmxn7w-deadnix-1.3.1/bin/deadnix --fail modules/nix-setup.nix modules/user.nix modules/standard-packages.nix`
2026-01-24T19:31:28.761952Z TRACE run{hook_id=deadnix language=system}: close time.busy=4.48ms time.idle=1.69ms
2026-01-24T19:31:28.761997Z TRACE get_diff{path="/Users/dwt/Code/Projekte/nix/pi"}: Executing `/nix/store/pqfrzb89ldydly6hmr8qga9f0pbhik7g-git-2.51.2/bin/git diff -- /Users/dwt/Code/Projekte/nix/pi`
2026-01-24T19:31:28.769242Z TRACE get_diff{path="/Users/dwt/Code/Projekte/nix/pi"}: close time.busy=239µs time.idle=7.01ms
deadnix..................................................................Passed
- hook id: deadnix
- duration: 0.01s
2026-01-24T19:31:28.769318Z DEBUG Running priority group with priority 2 with concurrency 14: ["flake-checker"]
2026-01-24T19:31:28.769478Z TRACE for_hook{hook="flake-checker"}: close time.busy=136µs time.idle=541ns
2026-01-24T19:31:28.769497Z TRACE Files for hook `flake-checker` after filtered: 2
2026-01-24T19:31:28.769549Z TRACE run{hook_id=flake-checker language=system}: Resolved command: /nix/store/h0ywf44n0dmhrdrnslpjl1r4sh6ia5fg-flake-checker-0.2.10/bin/flake-checker
2026-01-24T19:31:28.769611Z TRACE run{hook_id=flake-checker language=system}: Running flake-checker total_files=0 concurrency=14
2026-01-24T19:31:28.769744Z TRACE run{hook_id=flake-checker language=system}: Executing `cd /Users/dwt/Code/Projekte/nix/pi && /nix/store/h0ywf44n0dmhrdrnslpjl1r4sh6ia5fg-flake-checker-0.2.10/bin/flake-checker -f`
2026-01-24T19:31:29.537728Z TRACE run{hook_id=flake-checker language=system}: close time.busy=1.76ms time.idle=766ms
2026-01-24T19:31:29.537924Z TRACE get_diff{path="/Users/dwt/Code/Projekte/nix/pi"}: Executing `/nix/store/pqfrzb89ldydly6hmr8qga9f0pbhik7g-git-2.51.2/bin/git diff -- /Users/dwt/Code/Projekte/nix/pi`
2026-01-24T19:31:29.550746Z TRACE get_diff{path="/Users/dwt/Code/Projekte/nix/pi"}: close time.busy=596µs time.idle=12.2ms
flake-checker............................................................Passed
- hook id: flake-checker
- duration: 0.77s

  Flake checker results:

  The flake checker scanned your flake.lock and didn't identify any issues. All
  Nixpkgs inputs:

  > Use supported branches
  > Are less than 30 days old
  > Use upstream Nixpkgs

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideaJust an idea

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions