diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..4c9bbd01 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,12 @@ +# This file contains commits that should be ignored by git blame +# See https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-file +# and https://github.com/NixOS/nixpkgs/blob/master/.git-blame-ignore-revs for more info + +# To enable this in your local repository, run: +# git config blame.ignoreRevsFile .git-blame-ignore-revs + +# For rebasing PRs, commits marked with !autorebase will be automatically +# reapplied by the auto-rebase script + +# nixfmt-rfc-style formatting +51e51e601448705c0d2f92ef90ec7b680123077c #!autorebase cd tests && nix fmt .. \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1a7c3f7e..4f58d888 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,10 +4,18 @@ on: push: branches: - master + merge_group: jobs: - tests: + nixfmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: cachix/install-nix-action@v31 - - run: nix run ./tests#run . + - run: cd tests && nix fmt .. -- --fail-on-change + tests: + needs: nixfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v31 + - run: nix run ./tests#run . \ No newline at end of file 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/scripts/update-tests-hash b/scripts/update-tests-hash new file mode 100755 index 00000000..f2508b9a --- /dev/null +++ b/scripts/update-tests-hash @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Helper script to update the tests flake hash +set -euo pipefail + +# Go to the root of the repository +cd "$(dirname "$0")/.." + +echo "Updating tests.narHash..." >&2 + +# Update the flake lock file +nix --extra-experimental-features 'flakes nix-command' flake lock ./tests + +# Generate the hash +nix --extra-experimental-features 'flakes nix-command' hash path ./tests > ./tests.narHash + +echo "Hash updated successfully: $(cat tests.narHash)" \ No newline at end of file diff --git a/tests/flake.lock b/tests/flake.lock index ba2dc9ab..4363c6d1 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -37,16 +37,16 @@ }, "nixos-stable": { "locked": { - "lastModified": 1746957726, - "narHash": "sha256-k9ut1LSfHCr0AW82ttEQzXVCqmyWVA5+SHJkS5ID/Jo=", - "ref": "nixos-24.11", - "rev": "a39ed32a651fdee6842ec930761e31d1f242cb94", + "lastModified": 1751211869, + "narHash": "sha256-1Cu92i1KSPbhPCKxoiVG5qnoRiKTgR5CcGSRyLpOd7Y=", + "ref": "nixos-25.05", + "rev": "b43c397f6c213918d6cfe6e3550abfe79b5d1c51", "shallow": true, "type": "git", "url": "https://github.com/NixOS/nixpkgs" }, "original": { - "ref": "nixos-24.11", + "ref": "nixos-25.05", "shallow": true, "type": "git", "url": "https://github.com/NixOS/nixpkgs" @@ -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..443bfbd7 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -3,16 +3,21 @@ inputs = { nixos-unstable-small.url = "git+https://github.com/NixOS/nixpkgs?shallow=1&ref=nixos-unstable-small"; - nixos-stable.url = "git+https://github.com/NixOS/nixpkgs?shallow=1&ref=nixos-24.11"; + nixos-stable.url = "git+https://github.com/NixOS/nixpkgs?shallow=1&ref=nixos-25.05"; # override in the test 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,25 @@ in { _module.args.pkgs = nixpkgsUnstable; + + treefmt = { + flakeCheck = pkgs.hostPlatform.system != "riscv64-linux"; + 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"; - }; -}