diff --git a/flake.lock b/flake.lock index 04de1b7..40ba650 100644 --- a/flake.lock +++ b/flake.lock @@ -307,6 +307,7 @@ "nixos-unstable": "nixos-unstable", "nixpkgs": "nixpkgs_2", "nur": "nur", + "treefmt-nix": "treefmt-nix", "utils": "utils" } }, @@ -365,6 +366,26 @@ "type": "github" } }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1710278050, + "narHash": "sha256-Oc6BP7soXqb8itlHI8UKkdf3V9GeJpa1S39SR5+HJys=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "35791f76524086ab4b785a33e4abbedfda64bd22", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, "utils": { "inputs": { "systems": "systems_2" diff --git a/flake.nix b/flake.nix index 0a3a150..3f1d182 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,10 @@ # deliberately do _not_ follow the nixpkgs input here, because paranoia and test coverage }; utils.url = "github:numtide/flake-utils"; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nur.url = "github:nix-community/NUR"; # TODO: possible make this a flake as well @@ -25,7 +29,7 @@ }; outputs = - { self, nixpkgs, nur, lanzaboote, utils, home-manager, ... }@inputs: + { self, nixpkgs, nur, lanzaboote, utils, home-manager, treefmt-nix, ... }@inputs: let # FIXME: allow different systems systems = utils.lib.system; @@ -71,6 +75,10 @@ inherit inputs system; }; }; + treefmtConf = {pkgs, ...}:{ + projectRootFile = "flake.nix"; + programs.nixfmt-rfc-style.enable = true; + }; in { overlays.default = import ./packages; @@ -85,11 +93,19 @@ inherit system; overlays = nixpkgs.lib.attrValues self.overlays; }; + nixpkgs_unstable = import inputs.nixos-unstable { + inherit system; + overlays = nixpkgs.lib.attrValues self.overlays; + }; pkgs = inputs.nixpkgs.legacyPackages.${system}; + pkgs_unstable = inputs.nixos-unstable.legacyPackages.${system}; + treefmtEval = treefmt-nix.lib.evalModule pkgs_unstable treefmtConf; in { devShells.default = pkgs.mkShell { buildInputs = []; }; + formatter = treefmtEval.config.build.wrapper; + checks.formatting = treefmtEval.config.build.check self; # expose nixpkgs with overlay; TODO: figure out role of config #legacyPackages = nixpkgs; });