From 4730e07206c27c234cd773ce4eee47776d0a85be Mon Sep 17 00:00:00 2001 From: Veneficium <85629831+veneficium42@users.noreply.github.com> Date: Sun, 29 Dec 2024 23:12:17 +0100 Subject: [PATCH] flake: add treefmt for formatting --- flake.lock | 69 ++++++++++++++++++++++++----------------------------- flake.nix | 9 ++++++- treefmt.nix | 6 +++++ 3 files changed, 45 insertions(+), 39 deletions(-) create mode 100644 treefmt.nix diff --git a/flake.lock b/flake.lock index be54142..e15095a 100644 --- a/flake.lock +++ b/flake.lock @@ -253,7 +253,9 @@ "inputs": { "niri-stable": "niri-stable", "niri-unstable": "niri-unstable", - "nixpkgs": "nixpkgs", + "nixpkgs": [ + "nixpkgs" + ], "nixpkgs-stable": "nixpkgs-stable", "xwayland-satellite-stable": "xwayland-satellite-stable", "xwayland-satellite-unstable": "xwayland-satellite-unstable" @@ -309,7 +311,9 @@ "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs_2" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1734918633, @@ -329,13 +333,13 @@ "locked": { "lastModified": 1734649271, "narHash": "sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ=", - "owner": "NixOS", + "owner": "nixos", "repo": "nixpkgs", "rev": "d70bd19e0a38ad4790d3913bf08fcbfc9eeca507", "type": "github" }, "original": { - "owner": "NixOS", + "owner": "nixos", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" @@ -357,46 +361,15 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1713805509, - "narHash": "sha256-YgSEan4CcrjivCNO5ZNzhg7/8ViLkZ4CB/GrGBVSudo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "1e1dc66fe68972a76679644a5577828b6a7e8be4", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { - "locked": { - "lastModified": 1734649271, - "narHash": "sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "d70bd19e0a38ad4790d3913bf08fcbfc9eeca507", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { "arion": "arion", "home-manager": "home-manager", "niri": "niri", "nix-vscode-extensions": "nix-vscode-extensions", - "nixpkgs": "nixpkgs_3", - "stylix": "stylix" + "nixpkgs": "nixpkgs", + "stylix": "stylix", + "treefmt-nix": "treefmt-nix" } }, "stylix": { @@ -513,6 +486,26 @@ "type": "github" } }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1735135567, + "narHash": "sha256-8T3K5amndEavxnludPyfj3Z1IkcFdRpR23q+T0BVeZE=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "9e09d30a644c57257715902efbb3adc56c79cf28", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, "xwayland-satellite-stable": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 6831287..fa75a6a 100644 --- a/flake.nix +++ b/flake.nix @@ -17,8 +17,13 @@ }; niri.url = "github:sodiboo/niri-flake"; + niri.inputs.nixpkgs.follows = "nixpkgs"; nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions"; + nix-vscode-extensions.inputs.nixpkgs.follows = "nixpkgs"; + + treefmt-nix.url = "github:numtide/treefmt-nix"; + treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = @@ -30,6 +35,7 @@ stylix, niri, nix-vscode-extensions, + treefmt-nix, ... }: let @@ -84,6 +90,7 @@ ]; }; }; - formatter.x86_64-linux = inputs.nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; + formatter.x86_64-linux = + (treefmt-nix.lib.evalModule (pkgs [ ] "x86_64-linux") ./treefmt.nix).config.build.wrapper; }; } diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..722a5be --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + projectRootFile = "flake.nix"; + + programs.nixfmt.enable = true; +}