1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

flake.nix: nixfmt -> treefmt

Instead of managing our own formatter file, we can leverage a tool
specifically tailored for formatting a repository and allowing
configuration to be passed to formatters.
This commit is contained in:
Austin Horstman 2025-04-07 10:29:36 -05:00
parent 7137c8ae4e
commit 74b681d665
2 changed files with 41 additions and 9 deletions

View file

@ -1,9 +1,16 @@
{
description = "Home Manager for Nix";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { self, nixpkgs, ... }:
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, treefmt-nix, ... }:
{
nixosModules = rec {
home-manager = ./nixos;
@ -39,13 +46,17 @@
lib = import ./lib { inherit (nixpkgs) lib; };
} // (let
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
treefmtEval = forAllSystems (
system:
treefmt-nix.lib.evalModule nixpkgs.legacyPackages.${system} {
# Formatting configuration
programs = {
nixfmt.enable = true;
};
});
in {
formatter = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in pkgs.linkFarm "format" [{
name = "bin/format";
path = ./format;
}]);
formatter = forAllSystems (system: treefmtEval.${system}.config.build.wrapper);
packages = forAllSystems (system:
let