diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8d75b139..e34c7e7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: cachix/install-nix-action@v31 - - run: nix fmt . + - run: cd tests && nix fmt .. -- --fail-on-change tests: needs: nixfmt runs-on: ubuntu-latest diff --git a/flake.lock b/flake.lock index 0477b1ca..8f2f2e35 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1748995760, - "narHash": "sha256-f6UIyqm6JZs45pG667YdHOFYgDt+gvxQvt32ZLBp1h4=", + "lastModified": 1751290770, + "narHash": "sha256-u4s8yKAqTzPGY3vTcDyAIet11uXaNCM//93/0O0NlbA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "26a54a5886c238b5df6f1e9ba0aa713434d73f06", + "rev": "0620a50e9a847851bf802c59a4202552ed79b821", "type": "github" }, "original": { @@ -16,44 +16,9 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1747958103, - "narHash": "sha256-qmmFCrfBwSHoWw7cVK4Aj+fns+c54EBP8cGqp/yK410=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "fe51d34885f7b5e3e7b59572796e1bcb427eccb1", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { - "nixpkgs": "nixpkgs", - "treefmt-nix": "treefmt-nix" - } - }, - "treefmt-nix": { - "inputs": { - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1748243702, - "narHash": "sha256-9YzfeN8CB6SzNPyPm2XjRRqSixDopTapaRsnTpXUEY8=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "1f3f7b784643d488ba4bf315638b2b0a4c5fb007", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index aed8651d..c5d599bb 100644 --- a/flake.nix +++ b/flake.nix @@ -1,34 +1,9 @@ { description = "nixos-hardware"; - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05-small"; - treefmt-nix.url = "github:numtide/treefmt-nix"; - }; - outputs = + { ... }: { - nixpkgs, - self, - treefmt-nix, - }: - let - systems = [ - "aarch64-darwin" - "aarch64-linux" - "x86_64-darwin" - "x86_64-linux" - ]; - forEachSystem = - function: nixpkgs.lib.genAttrs (systems) (system: function nixpkgs.legacyPackages.${system}); - - treefmtEval = forEachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix); - in - { - checks = forEachSystem (pkgs: { - formatting = treefmtEval.${pkgs.system}.config.build.check self; - }); - formatter = forEachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper); nixosModules = let diff --git a/tests/flake.lock b/tests/flake.lock index ba2dc9ab..bc9dc885 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -74,7 +74,28 @@ "flake-parts": "flake-parts", "nixos-hardware": "nixos-hardware", "nixos-stable": "nixos-stable", - "nixos-unstable-small": "nixos-unstable-small" + "nixos-unstable-small": "nixos-unstable-small", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixos-unstable-small" + ] + }, + "locked": { + "lastModified": 1750931469, + "narHash": "sha256-0IEdQB1nS+uViQw4k3VGUXntjkDp7aAlqcxdewb/hAc=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "ac8e6f32e11e9c7f153823abc3ab007f2a65d3e1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, diff --git a/tests/flake.nix b/tests/flake.nix index bf20ed3a..aa493971 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -8,11 +8,16 @@ nixos-hardware.url = "github:NixOS/nixos-hardware"; flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.inputs.nixpkgs-lib.follows = "nixos-unstable-small"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + treefmt-nix.inputs.nixpkgs.follows = "nixos-unstable-small"; }; outputs = inputs@{ flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + inputs.treefmt-nix.flakeModule + ]; systems = [ "aarch64-linux" "x86_64-linux" @@ -85,6 +90,24 @@ in { _module.args.pkgs = nixpkgsUnstable; + + treefmt = { + projectRootFile = "COPYING"; + programs = { + deadnix = { + enable = true; + no-lambda-pattern-names = true; + }; + nixfmt = { + enable = true; + package = pkgs.nixfmt-rfc-style; + }; + }; + settings = { + on-unmatched = "info"; + }; + }; + checks = checksForNixpkgs "nixos-unstable" nixpkgsUnstable // checksForNixpkgs "nixos-stable" nixpkgsStable; diff --git a/treefmt.nix b/treefmt.nix deleted file mode 100644 index 7039d8b5..00000000 --- a/treefmt.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ pkgs, ... }: -{ - projectRootFile = "flake.nix"; - - programs = { - deadnix = { - enable = true; - no-lambda-pattern-names = true; - }; - nixfmt = { - enable = true; - package = pkgs.nixfmt-rfc-style; - }; - }; - - settings = { - on-unmatched = "info"; - }; -}