🏡 index : ~doyle/aoc.git

author Jordan Doyle <jordan@doyle.la> 2023-12-08 18:14:34.0 +00:00:00
committer Jordan Doyle <jordan@doyle.la> 2023-12-08 18:14:34.0 +00:00:00
commit
fa9bd23e7a94ec60775c07ec20e830169a980e26 [patch]
tree
8c4a9960dd6bf7f70db5f733ac51e88f08fa45c7
parent
714b82f965f482df88397cd89a1055e5e1d08abb
download
fa9bd23e7a94ec60775c07ec20e830169a980e26.tar.gz

Add treefmt



Diff

 flake.lock  | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 flake.nix   | 17 +++++++++++++++++
 treefmt.nix | 12 ++++++++++++
 3 files changed, 104 insertions(+)

diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..d9262a1 100644
--- /dev/null
+++ a/flake.lock
@@ -1,0 +1,75 @@
{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1701693815,
        "narHash": "sha256-7BkrXykVWfkn6+c1EhFA3ko4MLi3gVG0p9G96PNnKTM=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "09ec6a0881e1a36c29d67497693a67a16f4da573",
        "type": "github"
      },

      "original": {
        "id": "nixpkgs",
        "type": "indirect"
      }

    },

    "nixpkgs_2": {
      "locked": {
        "lastModified": 1695644571,
        "narHash": "sha256-asS9dCCdlt1lPq0DLwkVBbVoEKuEuz+Zi3DG7pR/RxA=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "6500b4580c2a1f3d0f980d32d285739d8e156d92",
        "type": "github"
      },

      "original": {
        "owner": "nixos",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }

    },

    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs",
        "systems": "systems",
        "treefmt-nix": "treefmt-nix"
      }

    },

    "systems": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },

      "original": {
        "id": "systems",
        "type": "indirect"
      }

    },

    "treefmt-nix": {
      "inputs": {
        "nixpkgs": "nixpkgs_2"
      },

      "locked": {
        "lastModified": 1701958734,
        "narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=",
        "owner": "numtide",
        "repo": "treefmt-nix",
        "rev": "e8cea581dd2b7c9998c1e6662db2c1dc30e7fdb0",
        "type": "github"
      },

      "original": {
        "owner": "numtide",
        "repo": "treefmt-nix",
        "type": "github"
      }

    }

  },

  "root": "root",
  "version": 7
}

diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..84a6d1a 100644
--- /dev/null
+++ a/flake.nix
@@ -1,0 +1,17 @@
{
  inputs = {
    treefmt-nix.url = "github:numtide/treefmt-nix";
  };

  outputs = { self, nixpkgs, systems, treefmt-nix }:
    let
      eachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system});
      treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
    in
    {
      formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
      checks = eachSystem (pkgs: {
        formatting = treefmtEval.${pkgs.system}.config.build.check self;
      });
    };
}
diff --git a/treefmt.nix b/treefmt.nix
new file mode 100644
index 0000000..6e9a25e 100644
--- /dev/null
+++ a/treefmt.nix
@@ -1,0 +1,12 @@
{ pkgs, ... }:
{
  projectRootFile = "flake.nix";

  programs = {
    hlint.enable = true;
    ormolu.enable = true;
    nixpkgs-fmt.enable = true;
    statix.enable = true;
    rustfmt.enable = true;
  };
}