mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-16 14:01:08 +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:
parent
7137c8ae4e
commit
74b681d665
2 changed files with 41 additions and 9 deletions
23
flake.lock
generated
23
flake.lock
generated
|
|
@ -18,7 +18,28 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs",
|
||||||
|
"treefmt-nix": "treefmt-nix"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"treefmt-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1743748085,
|
||||||
|
"narHash": "sha256-uhjnlaVTWo5iD3LXics1rp9gaKgDRQj6660+gbUU3cE=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "815e4121d6a5d504c0f96e5be2dd7f871e4fd99d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
27
flake.nix
27
flake.nix
|
|
@ -1,9 +1,16 @@
|
||||||
{
|
{
|
||||||
description = "Home Manager for Nix";
|
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 {
|
nixosModules = rec {
|
||||||
home-manager = ./nixos;
|
home-manager = ./nixos;
|
||||||
|
|
@ -39,13 +46,17 @@
|
||||||
lib = import ./lib { inherit (nixpkgs) lib; };
|
lib = import ./lib { inherit (nixpkgs) lib; };
|
||||||
} // (let
|
} // (let
|
||||||
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
|
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 {
|
in {
|
||||||
formatter = forAllSystems (system:
|
formatter = forAllSystems (system: treefmtEval.${system}.config.build.wrapper);
|
||||||
let pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
in pkgs.linkFarm "format" [{
|
|
||||||
name = "bin/format";
|
|
||||||
path = ./format;
|
|
||||||
}]);
|
|
||||||
|
|
||||||
packages = forAllSystems (system:
|
packages = forAllSystems (system:
|
||||||
let
|
let
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue