treefmt/flake.nix
zimbatm 84677166df
introduce treefmt.withConfig
This is useful if you want to configure treefmt with nix, and precisely
pass all the commands from nixpkgs.

Co-authored-by: Sridhar Ratnakumar <srid@srid.ca>
2022-09-21 18:40:21 +02:00

40 lines
1.4 KiB
Nix

{
description = "treefmt";
# To update all inputs:
# $ nix flake update --recreate-lock-file
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
inputs.flake-parts.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, flake-parts }@inputs:
flake-parts.lib.mkFlake { inherit self; } {
systems = nixpkgs.lib.systems.flakeExposed;
perSystem = { system, pkgs, ... }:
let
packages = import ./. {
inherit system;
inputs = null;
nixpkgs = pkgs;
};
in
{
# This contains a mix of packages, modules, ...
legacyPackages = packages;
devShells.default = packages.devShell;
# In Nix 2.8 you can run `nix fmt` to format this whole repo.
#
# Because we load the treefmt.toml and don't define links to the
# packages in Nix, the formatter has to run inside of `nix develop`
# to have the various tools on the PATH.
#
# It also assumes that the project root has a flake.nix (override this by setting `projectRootFile`).
formatter = packages.treefmt.withConfig {
settings = nixpkgs.lib.importTOML ./treefmt.toml;
projectRootFile = "flake.nix";
};
};
};
}