Skip to content

fix(nufmt): match .nu files instead of unrecognized type tag - #739

Open
Malix-Labs wants to merge 1 commit into
cachix:masterfrom
Malix-Labs:fix/nufmt-file-pattern
Open

fix(nufmt): match .nu files instead of unrecognized type tag#739
Malix-Labs wants to merge 1 commit into
cachix:masterfrom
Malix-Labs:fix/nufmt-file-pattern

Conversation

@Malix-Labs

Copy link
Copy Markdown

Summary

Fixes the nufmt hook configuration so it can actually run under pre-commit.

Context

In b915811 (#699 by @asakura), the nufmt hook was introduced with types = [ "nushell" ];.

However, pre-commit validates file type tags against the identify tag registry. Because identify does not define a nushell tag, enabling nufmt currently causes pre-commit to crash during configuration validation:

An error has occurred: InvalidConfigError:
==> File .pre-commit-config.yaml
==> At Config()
==> At key: repos
==> At Repository(repo='local')
==> At key: hooks
==> At Hook(id='nufmt')
==> At key: types
==> At index 0
=====> Type tag 'nushell' is not recognized.  Try upgrading identify and pre-commit?

Solution

Following the convention of other hooks in this repository for file formats not tracked by identify (e.g. Elm, Dhall, OPAM, Typst), replace types = [ "nushell" ]; with:

files = "\\.nu$";

(Since types defaults to [ "file" ] in modules/hook.nix, this properly restricts nufmt to Nushell source files without triggering identify validation errors).

Verification

Tested with a consumer flake importing this modified git-hooks.nix with pre-commit.settings.hooks.nufmt.enable = true;. Pre-commit successfully invoked nufmt on .nu files and passed all checks.

Commit b915811 added the nufmt hook with types = [ "nushell" ];.
However, pre-commit (and its identify tag engine) does not recognize nushell as a valid type tag, causing pre-commit to fail with:

    An error has occurred: InvalidConfigError:
    ==> At key: types
    ===> Type tag 'nushell' is not recognized.

Following the convention of other hooks without an identify tag (e.g. Dhall, Elm, OPAM), use files = "\\.nu$"; instead.
@Malix-Labs

Copy link
Copy Markdown
Author

Alternatively: I opened pre-commit/identify#609, so if it is merged, we would just need to update our dependency to it to get support for nushell

@Malix-Labs

Malix-Labs commented Sep 6, 2026

Copy link
Copy Markdown
Author

Also I think some tests would be good for this repo maybe, such blatant bugs would be easily caught

Update: created #740 for it

@Malix-Labs Malix-Labs mentioned this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant