Code Monkey home page Code Monkey logo

treefmt-nix's Introduction

treefmt-nix — Fast and convenient multi-file formatting with Nix

treefmt combines file formatters for multiple programming languages so that you can format all your project files with a single command. With treefmt-nix you can specify treefmt build options, dependencies and config in one place, conveniently managed by Nix.

treefmt-nix automatically installs and configures the desired formatters as well as treefmt for you and integrates nicely into your Nix development environments. It comes with sane, pre-crafted formatter-configs maintained by the community; each config corresponds to a section that you would normally add to the treefmt config file treefmt.toml.

Take a look at the already supported formatters for Python, Rust, Go, Haskell and more.

Integration into Nix

Nix classic without flakes

To run treefmt-nix with nix-classic, import the repo using niv:

$ niv add numtide/treefmt-nix

Alternatively, you can download the source and run nix-build in the project root directory:

$ nix-build

The command will return the helper functions which will be later used to produce a derivation from the specified treefmt-nix configuration.

After you installed treefmt-nix, specify the formatter configuration. For instance, this one is for formatting terraform files:

# myfile.nix
{ system ? builtins.currentSystem }:
let
  nixpkgsSrc = builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/refs/heads/nixos-unstable.tar.gz";
  treefmt-nixSrc = builtins.fetchTarball "https://github.com/numtide/treefmt-nix/archive/refs/heads/master.tar.gz";
  nixpkgs = import nixpkgsSrc { inherit system; };
  treefmt-nix = import treefmt-nixSrc;
in
treefmt-nix.mkWrapper nixpkgs {
  # Used to find the project root
  projectRootFile = ".git/config";
  # Enable the terraform formatter
  programs.terraform.enable = true;
  # Override the default package
  programs.terraform.package = nixpkgs.terraform_1;
  # Override the default settings generated by the above option
  settings.formatter.terraform.excludes = [ "hello.tf" ];
}

It's a good practice to place the configuration file in the project root directory.

Next, execute this command:

$ nix-build myfile.nix

This command returns a derivation that contains a treefmt binary at ./result/bin/treefmt in your current directory. The file is actually a symlink to the artifact in /nix/store.

treefmt.toml in this case isn't generated: the binary is wrapped with the config.

Flakes

Running treefmt-nix with flakes isn't hard. The library is exposed as the lib attribute:

# flake.nix
{
  inputs.treefmt-nix.url = "github:numtide/treefmt-nix";

  outputs = { self, nixpkgs, systems, treefmt-nix }:
    let
      # Small tool to iterate over each systems
      eachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system});

      # Eval the treefmt modules from ./treefmt.nix
      treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
    in
    {
      # for `nix fmt`
      formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
      # for `nix flake check`
      checks = eachSystem (pkgs: {
        formatting = treefmtEval.${pkgs.system}.config.build.check self;
      });
    };
}

And also add the treefmt.nix file (or put the content inline if you prefer):

# treefmt.nix
{ pkgs, ... }:
{
  # Used to find the project root
  projectRootFile = "flake.nix";
  # Enable the terraform formatter
  programs.terraform.enable = true;
  # Override the default package
  programs.terraform.package = pkgs.terraform_1;
  # Override the default settings generated by the above option
  settings.formatter.terraform.excludes = [ "hello.tf" ];
}

This file is also the place to define all the treefmt parameters like includes, excludes and formatter options.

After specifying the flake, run nix fmt:

$ nix fmt

Nix-fmt is a tool to format all nix files in the project, but with the specified flake, it starts treefmt-nix and formats your project.

You can also run nix flake check (eg: in CI) to validate that the project's code is properly formatted.

Flake-parts

This flake exposes a flake-parts module as well. To use it:

  1. Add inputs.treefmt-nix.flakeModule to the imports list of your flake-parts call.

  2. Add treefmt = { .. } (containing the configuration above) to your perSystem.

  3. Add config.treefmt.build.wrapper to the nativeBuildInputs of your devShell. This will make the treefmt command available in the shell using the specified configuration.

    You can also use config.treefmt.build.programs to get access to the individual programs, which could be useful to provide them to your IDE or editor.

    For an example, see haskell-template's flake.nix.

See this page for a detailed walkthrough.

Configuration

While dealing with treefmt outside of nix, the formatter configuration is specified in a toml format. On the contrary, with nix, you write in with a nix syntax like this:

# Used to find the project root
projectRootFile = ".git/config";
# Enable the terraform formatter
programs.terraform.enable = true;
# Override the default package
programs.terraform.package = nixpkgs.terraform_1;
# Override the default settings generated by the above option
settings.formatter.terraform.excludes = [ "hello.tf" ];

Options:

  • Project root file is the git file of the project which you plan to format.
  • The option programs.terraform.enable enables the needed formatter. You can specify as many formatter as you want. For instance:
programs.terraform.enable = true;
programs.gofmt.enable = true;
  • The option programs.terraform.package allows you to use a particular build/version of the specified formatter.
  • By settingsettings.formatter.terraform.excludes you can mark the files which should be excluded from formatting. You can also specify other formatter options or includes this way.

For detailed description of the options, refer to the treefmt documentation.

Project structure

This repo contains a top-level default.nix that returns the library helper functions.

  • mkWrapper is the main function which wraps treefmt with the needed configuration.
  • mkConfigFile
  • evalModule
  • all-modules

Supported programs

treefmt-nix currently supports the following formatters:

  • actionlint
  • alejandra
  • asmfmt
  • beautysh
  • biome
  • black
  • buildifier
  • cabal-fmt
  • clang-format
  • cljfmt
  • csharpier
  • cue
  • d2
  • deadnix
  • deno
  • dhall
  • dos2unix
  • dprint
  • elm-format
  • erlfmt
  • fantomas
  • fnlfmt
  • formatjson5
  • fourmolu
  • fprettify
  • gdformat
  • gleam
  • gofmt
  • gofumpt
  • google-java-format
  • hclfmt
  • hlint
  • isort
  • jsonfmt
  • jsonnet-lint
  • jsonnetfmt
  • just
  • keep-sorted
  • ktfmt
  • ktlint
  • leptosfmt
  • mdformat
  • mdsh
  • mix-format
  • muon
  • mypy
  • nickel
  • nimpretty
  • nixfmt
  • nixfmt-rfc-style
  • nixpkgs-fmt
  • ocamlformat
  • opa
  • ormolu
  • packer
  • php-cs-fixer
  • prettier
  • protolint
  • purs-tidy
  • ruff
  • rufo
  • rustfmt
  • scalafmt
  • shellcheck
  • shfmt
  • statix
  • stylish-haskell
  • stylua
  • swift-format
  • taplo
  • templ
  • terraform
  • typstfmt
  • yamlfmt
  • zig
  • zprint

For non-Nix users, you can also find the generated examples in the ./examples folder.

Using a custom formatter

It is also possible to use custom formatters with treefmt-nix. For example, the following custom formatter formats JSON files using yq-go:

settings.formatter = {
  "yq-json" = {
    command = "${pkgs.bash}/bin/bash";
    options = [
      "-euc"
      ''
        for file in "$@"; do
          ${lib.getExe yq-go} -i --output-format=json $file
        done
      ''
      "--" # bash swallows the second argument when using -c
    ];
    includes = [ "*.json" ];
  };
};

Adding new formatters

PRs to add new formatters are welcome!

  • The formatter should conform to the formatter specifications.
  • This is not the place to debate formatting preferences. Please pick defaults that are standard in your community -- for instance, python is usually indented with 4 spaces, so don't add a python formatter with 2 spaces as the default.

In order to add a new formatter do the following things:

  1. Create a new entry in the ./programs/ folder.
  2. Consider adding yourself as the meta.maintainer (see below).
  3. Run ./examples.sh to update the ./examples folder.
  4. To test the program:
    1. Extend the project's ./treefmt.nix file (temporarily) to enable the new formatter and configure it in whatever manner is appropriate.
    2. Add a bunch of pertinent sources in this repo -- for instance, if the new formatter is meant to format *.foo files, add a number of *.foo files, some well-formatted (and therefore expected to be exempt from modification by treefmt) and some badly-formatted.
    3. Run nix fmt. Confirm that well-formatted files are unchanged and that badly-formatted files are flagged as such. Re-run nix fmt and confirm that no additional changes were made.
    4. Once this is good, revert those changes.
  5. Submit the PR!

Definition of a meta.maintainer

You can register your desire to help with a specific formatter by adding your GitHub handle to the module's meta.maintainers list.

That mostly means, for the given formatter:

  • You get precedence if any decisions need to be made.
  • Getting pinged if any issue is being found.

Commercial support

Looking for help or customization?

Get in touch with Numtide to get a quote. We make it easy for companies to work with Open Source projects: https://numtide.com/contact

License

All the code and documentation is licensed with the MIT license.

treefmt-nix's People

Contributors

anntnzrb avatar bors[bot] avatar brianmcgee avatar callumiddon avatar dependabot[bot] avatar folliehiyuki avatar gkze avatar haruki7049 avatar huwaireb avatar itstarsun avatar katexochen avatar kclejeune avatar marc136 avatar mic92 avatar nifoc avatar r-vdp avatar roberth avatar rtunreal avatar ruixi-rebirth avatar sellout avatar sg-qwt avatar shivaraj-bh avatar srid avatar terlar avatar teto avatar thomaslaich avatar tmuehlbacher avatar w4 avatar yousiki avatar zimbatm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

treefmt-nix's Issues

global ignore/exclude

Is your feature request related to a problem? Please describe.

I'm working with git submodules, and they currently feel incompatible with treefmt-nix.

Describe the solution you'd like

treefmt.config.settings.exclude = [ "dir1" "dir2" ]

Describe alternatives you've considered

settings.formatter = {
        prettier.excludes = [ "submoduleA/" ];
        black.excludes = [ "submoduleA/" ];
      };

this did not work.

Absolute path in `projectRootFile` breaks formatting

Describe the bug

Disclaimer: I'd like to report something that's probably not an important bug and an edge case for most projects, however, this worked pre < v2.0.0 and doesn't anymore hence it might be a good idea to put some note in the docs or a warning directly in the code.


Bug: Using absolute paths in projectRootFile seems to break passing arguments to some formatters, for example nixfmt, nixfmt-rfc-style

To Reproduce

Steps to reproduce the behavior:

  1. Simple flakeModule in the following format
    { config, inputs, ... }:
    {
      imports = with inputs; [ treefmt-nix.flakeModule ];
    
      perSystem =
        { pkgs, ... }:
        {
          treefmt = {
            package = pkgs.treefmt;
            flakeCheck = true;
            flakeFormatter = true;
            projectRootFile = config.flake-root + "/flake.nix";
    
            programs = {
              deadnix.enable = true; # Find and remove unused code in .nix source files
              statix.enable = true; # Lints and suggestions for the nix programming language
              nixfmt.enable = true; # An opinionated formatter for Nix
            };
          };
        };
    }
    where
      options.flake-root = lib.mkOption {
        type = lib.types.path;
        description = ''
          Provides `config.flake-root` with the path to the flake root.
        '';
        default = ../.;
      };
    NOTE: The same thing happens even with directly specifying projectRootFile = ../. + "/flake.nix";
  2. And running nix fmt produces errors like these
    ❯ nix fmt
    ...
    nixfmt error:
    nixfmt: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/age/secrets/secrets.nix: openFile: does not exist (No such file or directory)
    ....
    and also tries to format stuff that should be ignored, such as
    ❯ nix fmt
    ....
    WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.direnv/bin/nix-direnv-reload
    WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.direnv/flake-profile-9f4ae1dfa18f64f9620b50ba3609c21d070f3a5f.rc
    WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/config
    WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/hooks/commit-msg
    WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/hooks/pre-commit
    WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/index
    WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/objects/03/466bd59a39888b932526fb36ae2e42dfed6b2c
    WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/objects/0c/fe02053860d76afe18757e9d0804a340d3e4b6
    WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/objects/0f/866697204f521a6192754f6a5f11aa80f4508c
    ...
    

Expected behavior

Setting projectRootFile = "flake.nix"; fixes this and produces expected behaviour, however, since projectRootFile = config.flake-root + "/flake.nix"; worked in the previous versions, this can be confusing to some folk, especially when the error is part of pre-commit hooks or some CI workflow I initially assumed this was due to the nixfmt-rfc-style -> nixfmt renaming in nixpkgs and didn't suspect treefmt at first.

This is why adding a warning or a note in the documentation might be a good idea.

System information

❯ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.10.2, NixOS, 24.11 (Vicuna), 24.11.20240801.dirty`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.23.3`
 - nixpkgs: `/nix/store/920a6ivyd50598z8djw9x3mr33gys0j5-source`
cd $FLAKE && nix flake metadata --json | jq '.locks.nodes."treefmt-nix"'
{
  "inputs": {
    "nixpkgs": [
      "nixpkgs-wayland",
      "nix-eval-jobs",
      "nixpkgs"
    ]
  },
  "locked": {
    "lastModified": 1720930114,
    "narHash": "sha256-VZK73b5hG5bSeAn97TTcnPjXUXtV7j/AtS4KN8ggCS0=",
    "owner": "numtide",
    "repo": "treefmt-nix",
    "rev": "b92afa1501ac73f1d745526adc4f89b527595f14",
    "type": "github"
  },
  "original": {
    "owner": "numtide",
    "repo": "treefmt-nix",
    "type": "github"
  }
}

where $FLAKE points to my personal configuration in which I discovered this after running an update.

Additional context

Flake check not failing when there is unformatted code

Describe the bug

I have unformatted code in the sources, which gets formatted correctly with nix fmt, but nix flake check does not fail.

To Reproduce

Steps to reproduce the behavior:

  1. have unformatted code
  2. run nix flake check

Expected behavior

nix flake check should fail

System information

I'm using the (currently) most recent version of treefmt-nix (rev 4e92552) on x86_64-linux

Additional context

This is my first time using treefmt-nix, so it may very well be the case that I am missing something or my configuration is wrong, I'm not very experienced yet in using nix. But as far as I understood the flake example in the README should also automatically configure the flake check, correct? This is my current minimal configuration:

      formatter.x86_64-linux = treefmt-nix.lib.mkWrapper
        nixpkgs.legacyPackages.x86_64-linux
        {
          projectRootFile = "flake.nix";
          programs.nixpkgs-fmt.enable = true;
          programs.stylua.enable = true;
        };

It works for nix fmt, but not for nix flake check.

`./examples.sh` is not portable to macOS

❯ ./examples.sh                        
warning: Git tree '/Users/srid/code/treefmt-nix' is dirty
cp: illegal option -- -
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file ... target_directory

flake-parts module breaks nix flake show

Describe the bug

When imported, nix flake show throws an error like: error: The option `perSystem.x86_64-linux.treefmt' is used but not defined.
Running nix flake show again says error: 'checks.x86_64-linux' is not an attribute set

To Reproduce

This is a minimal flake.nix triggering the issue

{
  description = "Description for the project";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    treefmt-nix.url = "github:numtide/treefmt-nix";
  };

  outputs = inputs@{ flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [
        inputs.treefmt-nix.flakeModule
      ];
      systems = ["x86_64-linux"];
    };
}

Error is encountered by running nix flake show or also by running nix fmt

Expected behavior

If there's a mandatory option to set in order to not have errors, have it printed in the error message or documented in the flake-parts website

System information

These are the commits in the lockfile at the moment of writing as obtained with nix flake metadata

treefmt-nix: github:numtide/treefmt-nix/42045102f90cfd23ca44ae4ef8362180fefcd7fd
flake-parts: github:hercules-ci/flake-parts/006c75898cf814ef9497252b022e91c946ba8e17

Running on x86_64-linux

Expose each formatter as TOML config

Is your feature request related to a problem? Please describe.

The formatter snippets are currently only available to Nix users. It should be possible to re-export the data to TOML, so it's also valuable for the other users.

Describe the solution you'd like

Some Nix script that loads and enables each formatter module, captures the generated configuration TOML and then stores it somewhere. It should also clean the formatter command, so it doesn't point to the /nix/store entry. Just the basename is enough.

I'm not sure exactly where the generated TOML should end up in.

Describe alternatives you've considered

Additional context

dprint fails with "/nix/store/r4r6inyjds6ac9s3jjg398hi52v8i7ip-dprint/bin/dprint: line 3: exec: dprint: not found"

Describe the bug

I added dprint to my flake.nix:

programs.dprint = {
            enable = true;
            config = {
              includes = [ "**/*.json" ];
              plugins = [
                "https://plugins.dprint.dev/json-0.17.2.wasm"
              ];
            };
          };

Calling nix fmt then fails with /nix/store/r4r6inyjds6ac9s3jjg398hi52v8i7ip-dprint/bin/dprint: line 3: exec: dprint: not found

System information

This is on aarch64-darwin, but also occurs on other architectures.

my flake.lock entry is:

"treefmt-nix": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1684244577,
        "narHash": "sha256-nnpCF/a5d0l68g/n4mAP+YUL+TxlYmmTK3HNzEy409Y=",
        "owner": "numtide",
        "repo": "treefmt-nix",
        "rev": "c1b28acff9d302b0924ee0d67c4a42d20eb11b28",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "treefmt-nix",
        "type": "github"
      }
    },

And my input is:

treefmt-nix = {
      url = "github:numtide/treefmt-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

Format check fails but `nix fmt` brings no changes.

Describe the bug

Hi!

Format check fails. But running the formatter doesn't modify anything. It's all formatted but check fails.

To Reproduce

Steps to reproduce the behavior:

At this commit first run:

nix fmt

Observe 0 files changed output.

Then run:

nix build .\#checks.x86_64-linux.treefmt

The build fails.

Expected behavior

The build doesn't fail or the formatter formats.

System information

This flake. That is:

  • treefmt 0.6.0
  • nix 2.18.0
  • treefmt-nix rev 8cd95da6c30852adb2a06c4b6bdacfe8b64a0, used with nixpkgs:
    treefmt-nix = {
      url = "github:numtide/treefmt-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

is it possible to set default values for flags in the treefmt config file ?

Is your feature request related to a problem? Please describe.

I almost always want to run treefmt with

--allow-missing-formatter -u info

Describe the solution you'd like

Set the option values in the config file/via the flake module

Describe alternatives you've considered
wrap the executable with those options

Obviate leptosfmt wrapper

https://github.com/bram209/leptosfmt/releases/tag/0.1.13 is released with the two necessary changes that will allow us to finally get rid of this wrapper.

command = pkgs.writeShellApplication {
name = "leptosfmt-forall";
runtimeInputs = [
cfg.package
modify-unless-unchanged
];
text = ''
# leptosfmt doesn't take multiple arguments yet
# https://github.com/bram209/leptosfmt/issues/63
for file in "$@"; do
# Use the modify-unless-unchanged hack until this is implemented:
# https://github.com/bram209/leptosfmt/issues/64
modify-unless-unchanged leptosfmt "$file"
done
'';
};

  • Upstream 0.1.13 to nixpkgs
  • Use that in this module (should we still keep the wrapper for older versions, or require user to use newer nixpkgs?)

Per-formatter settings

What I'd like to achieve ultimately

srid/haskell-template#76

tldr; fourmolu (a Haskell formatter supported by treefmt) takes a configuration file called fourmolu.yaml. The aforementioned issue is about replacing this YAML file with Nix.

Purpose of this issue

Is this in scope for treefmt-nix? ie., can treefmt-nix itself expose these settings? As a result, the flake-module use would look like:

{
  treefmt.config = {
    package = pkgs.treefmt;

    programs.fourmolu.enable = true;
    settings.formatter.fourmolu = {
      options = [
        "--ghc-opt"
        "-XImportQualifiedPost"
      ];
      # Nix for fourmolu.yaml:
      settings = {
        indentation = 2;
        comma-style = "leading";
        record-brace-space = true;
      };
    };
  };

  devShells.default = pkgs.mkShell { buildInputs = [ config.treefmt.programs.fourmolu.wrapper ]; };
}

More general feature

The more general feature here is that treefmt-nix "nixifies" the configuration for individual formatters. Just like it can generate treefmt.toml (and a wrapper treefmt script), in the case of fourmolu it can also generate fourmolu.yaml (and a wrapper fourmolu script).

[flake-parts] Add a `devShell` option exposing all programs

When using haskell-flake, I manually have to pull in the programs into the devShell:

          devShell = {
            tools = hp: {
              treefmt = config.treefmt.build.wrapper;
            } // config.treefmt.build.programs;
          }

cf. https://github.com/srid/haskell-template/blob/fc263b19e4ef02710ffc61fc656aec6c1a873974/flake.nix#L31-L33


But we can do this in a cleaner way, using inputFrom of mkShell. See https://haskell.flake.page/devshell#composing-devshells

To that end, I'd like a config.treefmt.build.devShell option to be added, that I can then pass into inputsFrom thereby getting both the wrapper and the underlying programs in the devShell. Happy to open a PR if this is acceptable.

# Outputs
build = {

nix flake show fails

Describe the bug

I use https://github.com/oxalica/nil as a nix LSP server, which is quite practical.
Not sure if my setup or nil changed but recently nil has started freaking out whenever it sees an error in flakes (which lead me to find issues in my own flakes). That includes this repo:

nix flake show github:numtide/treefmt-nix/27107cf3dfdc3c809d2477954d92fc2cc68b4401
├───formatter
│   ├───aarch64-darwin omitted (use '--all-systems' to show)
│   ├───aarch64-linux omitted (use '--all-systems' to show)
│   ├───x86_64-darwin omitted (use '--all-systems' to show)
error:
       … while evaluating the attribute 'checks.x86_64-linux.wrapper'

         at /nix/store/qyyw6dd6lqlhz3cqap31d071cbyh34bf-source/lib/attrsets.nix:484:14:

          483|     value:
          484|     { inherit name value; };
             |              ^
          485|

       error: attribute 'wrapper' missing

       at /nix/store/gzq17ccnn7sbfl08c26hhy9c3vmxfbhv-source/flake.nix:23:9:

           22|       formatter = eachSystem (system:
           23|         self.checks.${system}.wrapper
             |         ^
           24|       );

To Reproduce

Steps to reproduce the behavior:
nix flake show github:numtide/treefmt-nix/27107cf3dfdc3c809d2477954d92fc2cc68b4401

Expected behavior

no error

System information

nixos-unstable

Additional context

Overriding Terraform package is incompatible with terraform-with-plugins

Describe the bug

When setting programs.terraform.package to the result of terraform-with-plugins the terraform binary cannot be found:

Failed to load formatter #terraform due to error: cannot find binary path

To Reproduce

Steps to reproduce the behaviour:

  1. Given the following expression:
let 
  tf = nixpkgs.terraform.withPlugins (p: [
    p.null
  ]);
in
{
  formatter.x86_64-linux = sources.treefmt-nix.lib.mkWrapper
    nixpkgs
    {
      programs.terraform = {
        enable = true;
        package = tf;
      };
    };
}

Expected behavior

Treefmt should find the Terraform binary.

System information

OS: Nixos unstable (5efc8ca954272c4376ac929f4c5ffefcc20551d5)

Versions:

  • Nix: 2.12.0
  • nixpkgs: 5efc8ca954272c4376ac929f4c5ffefcc20551d5
  • treefmt-nix: 6717065d6a432bc3f5b827007ad959e6032d5856

Additional context

@zimbatm diagnosed this issue as being due to the pname of the terraform-with-plugins result not being "terraform". Currently settings.formatter.terraform.command = lib.mkForce "${tf}/bin/terraform"; is a valid workaround.

remove old deprecation warning for ruff

Describe the bug

I keep seeing the warning programs.ruff.enable has been renamed to programs.ruff.check

But the thing is I am not even using ruff in my treefmt config.

To Reproduce

Not sure, whenever I am doing nixos-rebuild or home-manager switch I get it sometimes, but not when using treefmt-nix via nix fmt

Expected behavior

If I am not using it, it shouldn't warn me.

System information

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.44, NixOS, 24.11 (Vicuna), 24.11.20240806.8e27e75`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/store/whdnxrs6vh9wv72fvkp4622wsl36x6xx-source`

Additional context

Maybe just disable that in ruff.nix as a temporary fix. since it has been a while since the users were warned about it.

`ruff check` should probably add `--fix`

Describe the bug
Since the very useful #175, we can now check and format with Ruff

To Reproduce

  1. Mess up some Python files in a way that ruff check isn't happy about, e.g. unused import
  2. run nix fmt

Expected behavior
Anything that can be fixed should be fixed.

Actual behavior
There are errors printed, but no action taken, e.g.

    ...
    tests/test_auth.py:6:27: F401 [*] `unittest.mock.create_autospec` imported but unused
    tests/test_auth.py:7:32: F401 [*] `starlette.requests.Request` imported but unused
    Found 15 errors.
    [*] 15 fixable with the `--fix` option.

Attribute 'visible' is missing

Describe the bug

error: attribute 'visible' missing
       at /nix/store/sgfi7jgzrab7hhygl36y29bi3anf4s5b-source/module-options.nix:205:20:
          204|               k: v:
          205|                 if options.programs.${k}.enable.visible && v.enable then
             |                    ^
          206|                   { "${k}" = v.package; } else { }

To Reproduce

Steps to reproduce the behavior:

  1. Using flake-parts, treefmt-nix
  2. Update to the most recent nixos-unstable nixpkgs, and the most recent treefmt-nix
  3. Try to make a devShell using inputsFrom to include treefmt-nix:
inputsFrom = [
        config.pre-commit.devShell
        config.treefmt.build.devShell
      ];

Expected behavior

A devshell that contains treefmt and the various programs treefmt provides

System information

From my flake.lock:

"nixos-unstable": {
 648   │       "locked": {
 649   │         "lastModified": 1723175592,
 650   │         "narHash": "sha256-M0xJ3FbDUc4fRZ84dPGx5VvgFsOzds77KiBMW/mMTnI=",
 651   │         "owner": "NixOS",
 652   │         "repo": "nixpkgs",
 653   │         "rev": "5e0ca22929f3342b19569b21b2f3462f053e497b",
 654   │         "type": "github"
 655   │       },
 656   │       "original": {
 657   │         "owner": "NixOS",
 658   │         "ref": "nixos-unstable",
 659   │         "repo": "nixpkgs",
 660   │         "type": "github"
 661   │       }
 662   │     },

Support `dprint` custom formatter options

Is your feature request related to a problem? Please describe.
I am trying to see dprint file association for this plugin: https://github.com/g-plane/markup_fmt which requires markup config.
Error:

       error: The option `programs.dprint.settings.markup' does not exist. Definition values:
       - In `/nix/store/3gchkgvjabjq2b8jblmzwcczq68z9613-source/treefmt.nix':
           {
             associations = [
               ".html"
               ".svg"
               ".mustache"
           ...

https://dprint.dev/config/#associations

Describe the solution you'd like
A way to specify dprint extra config

Describe alternatives you've considered

🤔

Additional context

`error: attribute 'busybox' missing` when using latest nixpkgs

Describe the bug

treefmt-nix doesn't evaluate correctly when using the latest nixpkgs flake. Expect:

       error: attribute 'busybox' missing

       at /nix/store/w92n9zhbizs1l3vy1x9aj2j9wc6xscld-source/pkgs/stdenv/linux/bootstrap-tools/default.nix:6:13:

            5|
            6|   builder = bootstrapFiles.busybox;
             |             ^
            7|

To Reproduce

Steps to reproduce the behavior:

  1. The first commit in this PR: srid/haskell-template#96

Expected behavior

Build shouldn't break.

System information

Please see the PR. Error appears on both Github Linux builder and my M1 macOS machine.

Additional context

Trigger seems to be this commit: f6fb7a3

When I use its parent commit, the error goes away. Thus my workaround is to set flakeFormatter = false;.

Expose the config collection outside the module system

Is your feature request related to a problem? Please describe.

I have a use case that allows manipulating config data via a simplified divnix/data-merge, which is essentially a glorified recursive merge with semantics to deal with lists.

In order to be able to leverage purely this catalogue 's config data, without the integration complexity of the module system...

Describe the solution you'd like*

I want to export the raw config data no longer coupled with the module system as the choice of integration. Even if the module system adds definitive value on top, the raw collection maintained by the treefmt community has independent intrinsic value.

In practice, I may propose a ./data folder where the raw data is exposed and then imported into ./programs to conform to the current configuration interface. But also directly exported as data in the flake outputs.

Describe alternatives you've considered

Make a complicated wrapper, that is hard to maintain in order to reverse engineer the module system to get to extract the raw data.

Additional context

I've been starting to accumulate some in-tree presets in divnix/std out of lack of knowledge of a better alternative, like this repo.

It makes use of nix-community/nixago to write the file and the treefmt raw preset currently looks like this: https://github.com/divnix/std/blob/main/cells/presets/nixago/treefmt.nix

It is enriched with the packages information here.

Repeating the excellent curation & collection work of this repo in std is non-sense. I'd rather prefer to point further contributions here.

Here you can find an example useage of this simplified & compact data handling pattern. Maybe you may see how this is motivated by sticking as close to the raw data as possible avoiding any data abstractions.

I'll explain data merge a little further, since it might not be well known:

Data merge merges two data-structures (lhs & rhs): data-merge.merge lhs rhs. The difference with lib.recursiveUpdate is that a list isn't handles unless you decorate the rhs with a merge annotation. E.g. data-merge.merge lhs (data-merge.decorate rhs {a.b = data-merge.append;}). Here a.b on the left hand side is a list.

By using this technique, we can assemble the treefmt configuration root by keep on merging right into left until we end up with the final config.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

None detected


  • Check this box to trigger a request for Renovate to run again on this repository

error: attribute 'writeShellScriptBin' missing

Describe the bug

In my flake, I tried to add a package with this code

		   treefmt-with-config = treefmt-nix.lib.mkWrapper nixpkgs {
			 # Used to find the project root
			 projectRootFile = ".git/config";
			 # Enable the terraform formatter
			 # programs.terraform.enable = true;
			 # Override the default package
			 # programs.terraform.package = nixpkgs.terraform_1_0;
			 # Override the default settings generated by the above option
			 # settings.formatter.terraform.excludes = ["hello.tf"];
		   };

but I got

error: attribute 'writeShellScriptBin' missing

       at /nix/store/z1wfgivqn358jnab22rj0qhacg0qmmdp-source/module-options.nix:92:17:

           91|           let
           92|             x = pkgs.writeShellScriptBin "treefmt" ''
             |                 ^
           93|               find_up() {

version of treefmt -nix nix flake metadata
treefmt-nix: github:numtide/treefmt-nix/c117283f7482b99a89de0d6ae4b77318ad283294

Sidequestion: why do i need to pass nixpkgs to treefmt-nix.lib.mkWrapper

error: attribute 'getExe' missing when adding to buildInputs the wrapper

Describe the bug

I triy adding a wrapped treefmt to my shell input but on nix develop I get:

error: attribute 'getExe' missing

       at /nix/store/4aw9k94v81xq3mnqd2lrvhka3m4sb7ns-source/module-options.nix:15:9:

           14|       else
           15|         lib.getExe res;
             |         ^
           16|   };

To Reproduce

add to flake

  packages.x86_64-linux = {
          # this apparently returns a ...build.wrapper 
          treefmt = (treefmt-nix.lib.mkWrapper pkgs {
              # Used to find the project root
              projectRootFile = ".git/config";
              programs.nixpkgs-fmt.enable = true;
              programs.shellcheck.enable = true;
            });
     }
     
     devShells.x86_64-linux.default = pkgs.mkShell {
        buildInputs = with pkgs; [
          gnumake
          shellcheck
          self.packages.${system}.treefmt # REFERENCING packages defined before

          # dependencies of https://github.com/covertsh/ubuntu-preseed-iso-generator
          xorriso # to write the iso
          syslinux
        ];

Expected behavior

wrapped treefmt in dev shell

System information

└───treefmt-nix: github:numtide/treefmt-nix/70e03145e26c2f3199f4320ecd9fd343f1129c60
    └───nixpkgs: github:nixos/nixpkgs/0591d6b57bfeb55dfeec99a671843337bc2c3323

Additional context

NB: I have a side question: I use git worktrees a lot and thus projectRootFile = ".git/config"; fails to detect my worktree (.git becomes a file that contains a path to the main repo). Would projectRootFile = ".git" work on the main repo (since .git is a folder then ?).

`programs.shfmt.indent_size` breaks shfmt config

Passing any formatting option to shfmt causes it to ignore the EditorConfig-based formatting config (see “If any parser or printer flags are given to the tool, no EditorConfig files will be used” in the README.

treefmt-nix will always pass -i to shfmt, causing it to ignore the actual configuration. There is no option to “unset” programs.shfmt.indent_size.

I think indent_size should allow (and default to) null, only passing -i if explicitly requested.

nix fmt errors out with "warnings does not exist"

Describe the bug

$ nix fmt
warning: Git tree '/home/jkolb/ara/mrak-robot' is dirty
error:
       … while calling the 'head' builtin
         at /nix/store/16ik5rfzbjbl2kxpagqx5rp03hkd32qp-source/lib/attrsets.nix:522:11:
          521|         || pred here (elemAt values 1) (head values) then
          522|           head values
             |           ^
          523|         else

       … while calling the 'head' builtin
         at /nix/store/16ik5rfzbjbl2kxpagqx5rp03hkd32qp-source/lib/attrsets.nix:522:11:
          521|         || pred here (elemAt values 1) (head values) then
          522|           head values
             |           ^
          523|         else

       … while calling the 'head' builtin
         at /nix/store/16ik5rfzbjbl2kxpagqx5rp03hkd32qp-source/lib/attrsets.nix:522:11:
          521|         || pred here (elemAt values 1) (head values) then
          522|           head values
             |           ^
          523|         else

       … while calling the 'head' builtin
         at /nix/store/16ik5rfzbjbl2kxpagqx5rp03hkd32qp-source/lib/attrsets.nix:522:11:
          521|         || pred here (elemAt values 1) (head values) then
          522|           head values
             |           ^
          523|         else

       … while calling the 'head' builtin
         at /nix/store/16ik5rfzbjbl2kxpagqx5rp03hkd32qp-source/lib/attrsets.nix:522:11:
          521|         || pred here (elemAt values 1) (head values) then
          522|           head values
             |           ^
          523|         else

       … while evaluating the attribute 'config.build.wrapper'
         at /nix/store/16ik5rfzbjbl2kxpagqx5rp03hkd32qp-source/lib/modules.nix:363:9:
          362|         options = checked options;
          363|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          364|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: The option `warnings' does not exist. Definition values:
       - In `/nix/store/p3qlccgpbygl0qpjcw9j9b0dx3vpdxrn-source/programs/ruff.nix': [ ]

To Reproduce

Steps to reproduce the behavior:

  1. Add nixtree-fmt to your flake
  2. run nix fmt

Expected behavior

It should work

System information

$ nix --version
nix (Nix) 2.23.3

cat flake.lock

{
  "nodes": {
    "flake-utils": {
      "locked": {
        "lastModified": 1659877975,
        "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "nix-ros": {
      "inputs": {
        "flake-utils": [
          "flake-utils"
        ],
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1664303028,
        "narHash": "sha256-7UuUEIkPxqDMDrfmFJZ/gdM6nGFpUzBWe10ss41Kofk=",
        "owner": "lopsided98",
        "repo": "nix-ros-overlay",
        "rev": "139ab5d3fa3c8327c2cf493d8b6e45b39f9714dd",
        "type": "github"
      },
      "original": {
        "owner": "lopsided98",
        "repo": "nix-ros-overlay",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1672580127,
        "narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "0874168639713f547c05947c76124f78441ea46c",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-22.05",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "flake-utils": "flake-utils",
        "nix-ros": "nix-ros",
        "nixpkgs": "nixpkgs",
        "treefmt-nix": "treefmt-nix"
      }
    },
    "treefmt-nix": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1722330636,
        "narHash": "sha256-uru7JzOa33YlSRwf9sfXpJG+UAV+bnBEYMjrzKrQZFw=",
        "owner": "numtide",
        "repo": "treefmt-nix",
        "rev": "768acdb06968e53aa1ee8de207fd955335c754b7",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "treefmt-nix",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}

Removing inputs.nixpkgs.follows = "nixpkgs"; from my flake doesn't help.

Additional context

nixfmt always updates mtime

Describe the bug

Running nixfmt always sets the mtime to the current date even if the contents didn't change.

To Reproduce

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    
    flake-parts.url = "github:hercules-ci/flake-parts";
    flake-parts.inputs.nixpkgs.follows = "nixpkgs";
    
    treefmt-nix.url = "github:numtide/treefmt-nix";
    treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs@{ flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [
        inputs.treefmt-nix.flakeModule
      ];
      systems = ["x86_64-linux"];
      perSystem = { pkgs, ... }: {
        treefmt = {
          programs.nixfmt.enable = true;
          programs.nixfmt.package = pkgs.nixfmt;
        };
      };
    };
}

Add some nix files to the workspace and observe the mtime each time treefmt --no-cache is run.

Expected behavior

treefmt-nix should not support nixfmt since it changes mtime and thus doesn't comply with idempotence requirement of the formatter specification.

Additionally it would be nice to have a list on https://numtide.github.io/treefmt/formatters/ with known unsupported formatters and their reasons for not being supported.

System information

Inputs:
├───flake-parts: github:hercules-ci/flake-parts/8e8d955c22df93dbe24f19ea04f47a74adbdc5ec
│   └───nixpkgs-lib follows input 'nixpkgs'
├───nixpkgs: github:NixOS/nixpkgs/6cee3b5893090b0f5f0a06b4cf42ca4e60e5d222
└───treefmt-nix: github:numtide/treefmt-nix/f4ce7d8660f57fe94092cf113c1f550acf16be53
    └───nixpkgs follows input 'nixpkgs'

Ability to specify a custom formatter?

Its obviously nice UX, that treefmt-nix comes with a bunch of formatters set-up. But a thing that seems to be missing is being able to specify a custom formatter, one that has yet to find its way into treefmt-nix.

For example, I tried specifying treefmt to utilize typstfmt in the flake-parts module like this:

treefmt.programs.typstfmt = {
              enable = true;
              command = "${pkgs.typstfmt}/bin/typstfmt";
              options = [];
              excludes = [];
            };

This fails with a:

 error: The option `perSystem.aarch64-darwin.treefmt.programs.typstfmt' does not exist. Definition values:
       - In `/nix/store/fa7bnw9lipymb026q4inj7f27yxcmnwb-source/flake.nix, via option perSystem':
           {
             command = "/nix/store/h5hwc836gma2g0v8mbhx40932pirfqsx-typstfmt-unstable-2023-08-06/bin/typstfmt";
             enable = true;
             excludes = [ ];
             options = [ ];
           ...

Describe the solution you'd like

Ideally it would just work :)

Naming consistency in Nix module options

Is your feature request related to a problem? Please describe.

No. Upon revising the codebase, I first noticed some naming inconsistencies in the shfmt.nix file in comparison to others. This became more apparent when I compared it to other files like ruff.nix and prettier.nix. The inconsistencies involve the use of different naming conventions such as camelCase, snake_case, and kebab-case for module options. While this might seem like a minor issue, it could potentially lead to confusion or errors in the future.

Describe the solution you'd like

There should be a standard naming convention adopted for module options, especially for newer contributions. This standardization will help maintain consistency across the codebase and make it easier for developers to understand and contribute.

Describe alternatives you've considered

N/A

Additional context

There would be a significant amount of module renaming involved, so I'm curious how we would approach this process. How can we implement these changes efficiently and ensure a smooth transition without disrupting the current functionality?

Looking forward to thoughts and suggestions.

Greetings.

Add a spellchecker

Is your feature request related to a problem? Please describe.

Cspell or another spellchecker would be a valuable addition.

yamlfmt always updates mtime

Describe the bug

Running yamlfmt always sets the mtime to the current date even if the contents didn't change.

To Reproduce

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    
    flake-parts.url = "github:hercules-ci/flake-parts";
    flake-parts.inputs.nixpkgs.follows = "nixpkgs";
    
    treefmt-nix.url = "github:numtide/treefmt-nix";
    treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs@{ flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [
        inputs.treefmt-nix.flakeModule
      ];
      systems = ["x86_64-linux"];
      perSystem = { pkgs, ... }: {
        treefmt = {
          programs.yamlfmt.enable = true;
          programs.yamlfmt.package = pkgs.yamlfmt;
        };
      };
    };
}

Add some yaml files to the workspace and observe the mtime each time treefmt --no-cache is run.

Expected behavior

treefmt-nix should not support yamlfmt since it changes mtime and thus doesn't comply with idempotence requirement of the formatter specification.

Additionally it would be nice to have a list on https://numtide.github.io/treefmt/formatters/ with known unsupported formatters and their reasons for not being supported.

System information

Inputs:
├───flake-parts: github:hercules-ci/flake-parts/8e8d955c22df93dbe24f19ea04f47a74adbdc5ec
│   └───nixpkgs-lib follows input 'nixpkgs'
├───nixpkgs: github:NixOS/nixpkgs/6cee3b5893090b0f5f0a06b4cf42ca4e60e5d222
└───treefmt-nix: github:numtide/treefmt-nix/f4ce7d8660f57fe94092cf113c1f550acf16be53
    └───nixpkgs follows input 'nixpkgs'

Simplify integration with flakes/access to inputs in "treefmt.nix"

Is your feature request related to a problem? Please describe.

It would be nice / easier / cleaner if the integration would not require to define custom-functions. It was a hassle to adjust the treefmtEval function to pass-through inputs to be able to use a package from input, maybe this can be adjusted that all arguments like on imports/modules can be used automatically:

      treefmtEval = eachSystem (pkgs:
        treefmt-nix.lib.evalModule pkgs (import ./treefmt.nix {
          inherit nixfmt;
          system = pkgs.system;
        }));

Describe the solution you'd like

Maybe they can be provided by treefmt-nix.lib. instead?

Describe alternatives you've considered
see above

Additional context

Add dprint formatter

I use dprint for TS/JS/JSON/Markdown. It’s really fast and configurable.

Btw. dprint also supports running other formatters via exec, or pure wasm plugins, so there seems to be a bit of overlap between treefmt and dprint. Maybe there is a possibility for collaboration as it’s also written in rust.

API feedback

I tried using this as a flake-parts module. Relevant PRs,

Why is build an option?

In the first PR, you'll notice the following code:

              let mod = inputs.treefmt-nix.lib.evalModule pkgs { projectRootFile = "flake.nix"; };
              in builtins.removeAttrs mod.options [
                "_module"
                # TODO: Why is this an option if the user can't set it?
                "build"
              ];

This is the only way I could get access to the combined options (to pass to flake-parts module as is), but I was forced to hack around by removing the _module attribute, as well as build option. If I leave the build option around, the consumer of my flake-parts module is asked to explicitly set build.wrapper and friends (which doesn't make sense of course).

Why does the build option even exist if the user is not supposed to set them?

Also note that I'm forced to pass projectRootFile = "flake.nix";, so I'd think we may want to export the "final" options set in lib so consumers of this flake do not have to do all of the above. I'm not yet too familiar with the module system to come up with a cleaner approach as first attempt.

Accumulate formatter packages

This piece of snippet in the second PR is used to accumulate all formatter packages, along with the wrapper itself so that they can be put in the dev shell. This enables non-treefmt-aware editors to directly invoke the formatters. I imagine this can be upstreamed somehow here?

              treefmtConfig = (inputs.treefmt-nix.lib.evalModule pkgs config.treefmt).config;
              treefmtTools = {
                treefmt = treefmtConfig.build.wrapper;
              } // builtins.mapAttrs (_: v: v.package) treefmtConfig.programs;

programs and settings duality is unnecessary and problematic

I don't understand why this module provides two top-levels for configuring treefmt -- programs and settings. They even have overlapping options, ie.: programs.foo.package and programs.foo.command. I find that it is impossible to use both. For example, if you comment the multiline comment in the second PR it will lead to:

error: The option `perSystem.aarch64-darwin.treefmt.settings.formatter.ormolu.command' is used but not defined.
(use '--show-trace' to show detailed location information)

image

As an user, I'd expect something more straightforward like the following:

  settings.formatter.ormolu = {
    command = pkgs.haskellPackages.fourmolu;
    options = [
      "--ghc-opt"
      "-XImportQualifiedPost"
    ];
  };

We don't even need the enable flag.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.