diff --git a/flake.lock b/flake.lock index a0e1495..991f934 100644 --- a/flake.lock +++ b/flake.lock @@ -549,6 +549,22 @@ "type": "github" } }, + "nixpkgs_4": { + "locked": { + "lastModified": 1726871744, + "narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nur": { "locked": { "lastModified": 1729855863, @@ -608,7 +624,8 @@ "nixpkgs-unstable": "nixpkgs-unstable", "nur": "nur", "sops-nix": "sops-nix", - "stylix": "stylix" + "stylix": "stylix", + "treefmt-nix": "treefmt-nix" } }, "rust-overlay": { @@ -721,6 +738,24 @@ "repo": "default", "type": "github" } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1729613947, + "narHash": "sha256-XGOvuIPW1XRfPgHtGYXd5MAmJzZtOuwlfKDgxX5KT3s=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "aac86347fb5063960eccb19493e0cadcdb4205ca", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 9116e86..be07216 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,7 @@ nur.url = "github:nix-community/NUR"; nixos-hardware.url = "github:NixOS/nixos-hardware/master"; stylix.url = "github:pizzapim/stylix/release-24.05"; + treefmt-nix.url = "github:numtide/treefmt-nix"; nix-index-database = { url = "github:nix-community/nix-index-database"; @@ -52,6 +53,23 @@ , ... }@inputs: let + supportedSystems = [ + "x86_64-linux" + "i686-linux" + "aarch64-linux" + ]; + forAllSystems' = nixpkgs.lib.genAttrs; + forAllSystems = forAllSystems' supportedSystems; + pkgsForSystem = + system: + import nixpkgs { + inherit system; + }; + + treefmtEval = forAllSystems ( + system: inputs.treefmt-nix.lib.evalModule (pkgsForSystem system) ./treefmt.nix + ); + mkNixosSystem = {extraModule, nixpkgs' ? nixpkgs, useDefaultConfiguration ? true}: nixpkgs'.lib.nixosSystem rec { system = "x86_64-linux"; @@ -66,6 +84,8 @@ }; in { + formatter = forAllSystems (system: (treefmtEval.${system}.config.build.wrapper)); + nixosConfigurations = { x260 = mkNixosSystem { extraModule = ({ pkgs, lib, ... }: { imports = [ inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x260 ]; diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..8729799 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,5 @@ +{ ... }: +{ + projectRootFile = "flake.nix"; + programs.alejandra.enable = true; +}