diff options
| author | Jakub Stachurski <j.stachurski@student.utwente.nl> | 2025-12-22 22:57:24 +0100 |
|---|---|---|
| committer | Jakub Stachurski <j.stachurski@student.utwente.nl> | 2025-12-22 22:57:24 +0100 |
| commit | ee7b1d28e41a5ef25686ae1efc58b862e282813a (patch) | |
| tree | ab3c5e18d68d8aa3e5122f8a1ceadef308e0f16a | |
| parent | 725f0caeb0051bb8b2eaf20cd51ef1297dcfe122 (diff) | |
Enable formatting using treefmt
| -rw-r--r-- | flake.nix | 31 | ||||
| -rw-r--r-- | modules/treefmt.nix | 6 |
2 files changed, 35 insertions, 2 deletions
@@ -19,13 +19,40 @@ url = "github:Wilkuu-2/tatuin/flake"; inputs.nixpkgs.follows = "nixpkgs"; }; + + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = - { self, nixpkgs, nixpkgs-stable, ... }@inputs: + { self, nixpkgs, nixpkgs-stable, treefmt-nix, ... }@inputs: let + lib = nixpkgs.lib; + systems = [ + "x86_64-linux" + "aarch64-linux" + ]; + forAllSystems = f: (lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system })); + treefmtEval = forAllSystems (pkgs: treefmt-nix.lib.evalModule pkgs ./modules/treefmt.nix); + in { # packages."x86_64-linux".full-iso = self.nixosConfigurations.full-iso.config.system.build.isoImage; - formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-tree; + packages = ( + forAllSystems (pkgs: { + + }) + ); + # for `nix fmt` + formatter = ( + forAllSystems (pkgs: treefmtEval.${pkgs.stdenv.hostPlatform.system}.config.build.wrapper) + ); + # for `nix flake check` + checks = ( + forAllSystems (pkgs: { + formatting = treefmtEval.${pkgs.system}.config.build.check self; + }) + ); nixosConfigurations = { apocalypse = nixpkgs.lib.nixosSystem { diff --git a/modules/treefmt.nix b/modules/treefmt.nix new file mode 100644 index 0000000..ab36cdb --- /dev/null +++ b/modules/treefmt.nix @@ -0,0 +1,6 @@ +{pkgs, ...}: { + # Used to find the project root + projectRootFile = "flake.nix"; + programs.nixfmt.enable = true; + programs.deadnix.enable = true; +} |
