DEVELOPMENT ENVIRONMENT

~liljamo/felu

50e36dd241412b3ddbeae7b540c0f92e56e9357b — Jonni Liljamo 8 months ago 7dcda54
feat(flake): add pre commit hooks
3 files changed, 204 insertions(+), 29 deletions(-)

M .gitignore
M flake.lock
M flake.nix
M .gitignore => .gitignore +1 -0
@@ 1,2 1,3 @@
.pre-commit-config.yaml
tmp/
internal/components/*_templ.txt

M flake.lock => flake.lock +163 -4
@@ 1,10 1,62 @@
{
  "nodes": {
    "flake-compat": {
      "flake": false,
      "locked": {
        "lastModified": 1696426674,
        "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
        "owner": "edolstra",
        "repo": "flake-compat",
        "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
        "type": "github"
      },
      "original": {
        "owner": "edolstra",
        "repo": "flake-compat",
        "type": "github"
      }
    },
    "flake-utils": {
      "inputs": {
        "systems": "systems"
      },
      "locked": {
        "lastModified": 1709126324,
        "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "d465f4819400de7c8d874d50b982301f28a84605",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "flake-utils_2": {
      "inputs": {
        "systems": "systems_2"
      },
      "locked": {
        "lastModified": 1701680307,
        "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "flake-utils_3": {
      "inputs": {
        "systems": "systems_3"
      },
      "locked": {
        "lastModified": 1694529238,
        "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
        "owner": "numtide",


@@ 18,7 70,7 @@
        "type": "github"
      }
    },
    "flake-utils_2": {
    "flake-utils_4": {
      "locked": {
        "lastModified": 1667395993,
        "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",


@@ 36,6 88,27 @@
    "gitignore": {
      "inputs": {
        "nixpkgs": [
          "pre-commit-hooks",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1703887061,
        "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=",
        "owner": "hercules-ci",
        "repo": "gitignore.nix",
        "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5",
        "type": "github"
      },
      "original": {
        "owner": "hercules-ci",
        "repo": "gitignore.nix",
        "type": "github"
      }
    },
    "gitignore_2": {
      "inputs": {
        "nixpkgs": [
          "templ",
          "nixpkgs"
        ]


@@ 56,7 129,7 @@
    },
    "gomod2nix": {
      "inputs": {
        "flake-utils": "flake-utils",
        "flake-utils": "flake-utils_3",
        "nixpkgs": [
          "templ",
          "nixpkgs"


@@ 92,9 165,65 @@
        "type": "github"
      }
    },
    "nixpkgs-stable": {
      "locked": {
        "lastModified": 1704874635,
        "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-23.11",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs_2": {
      "locked": {
        "lastModified": 1704842529,
        "narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixpkgs-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "pre-commit-hooks": {
      "inputs": {
        "flake-compat": "flake-compat",
        "flake-utils": "flake-utils_2",
        "gitignore": "gitignore",
        "nixpkgs": "nixpkgs_2",
        "nixpkgs-stable": "nixpkgs-stable"
      },
      "locked": {
        "lastModified": 1708018599,
        "narHash": "sha256-M+Ng6+SePmA8g06CmUZWi1AjG2tFBX9WCXElBHEKnyM=",
        "owner": "cachix",
        "repo": "pre-commit-hooks.nix",
        "rev": "5df5a70ad7575f6601d91f0efec95dd9bc619431",
        "type": "github"
      },
      "original": {
        "owner": "cachix",
        "repo": "pre-commit-hooks.nix",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "flake-utils": "flake-utils",
        "nixpkgs": "nixpkgs",
        "pre-commit-hooks": "pre-commit-hooks",
        "templ": "templ"
      }
    },


@@ 113,9 242,39 @@
        "type": "github"
      }
    },
    "systems_2": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default",
        "type": "github"
      }
    },
    "systems_3": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default",
        "type": "github"
      }
    },
    "templ": {
      "inputs": {
        "gitignore": "gitignore",
        "gitignore": "gitignore_2",
        "gomod2nix": "gomod2nix",
        "nixpkgs": [
          "nixpkgs"


@@ 139,7 298,7 @@
    },
    "xc": {
      "inputs": {
        "flake-utils": "flake-utils_2",
        "flake-utils": "flake-utils_4",
        "nixpkgs": [
          "templ",
          "nixpkgs"

M flake.nix => flake.nix +40 -25
@@ 1,39 1,54 @@
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";

    pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";

    templ = {
      url = "github:a-h/templ?ref=tags/v0.2.598";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = inputs@{ self, nixpkgs, templ }:
  let
    allSystems = [
      "x86_64-linux"
    ];
  outputs = inputs @ {
    self,
    nixpkgs,
    flake-utils,
    pre-commit-hooks,
    templ,
  }:
    flake-utils.lib.eachSystem ["x86_64-linux"] (
      system: let
        pkgs = nixpkgs.legacyPackages.${system};
        templ-pkg = templ.packages.${system}.default;
      in {
        checks = {
          pre-commit-check = pre-commit-hooks.lib.${system}.run {
            src = ./.;
            hooks = {
              gofmt.enable = true;
              govet.enable = true;
              revive.enable = true;
            };
          };
        };

    forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
      pkgs = import nixpkgs { inherit system; };
      templ-pkg = inputs.templ.packages.${system}.default;
    });
  in
  {
    devShells = forAllSystems ({ pkgs, templ-pkg }: {
      default = pkgs.mkShell {
        buildInputs = [
          pkgs.go
          pkgs.gopls
        devShells.default = pkgs.mkShell {
          inherit (self.checks.${system}.pre-commit-check) shellHook;
          buildInputs = [
            pkgs.go
            pkgs.gopls

          # sqlite web inspector for developing
          pkgs.sqlite-web
            # sqlite web inspector for developing
            pkgs.sqlite-web

          pkgs.tailwindcss
          pkgs.tailwindcss-language-server
            pkgs.tailwindcss
            pkgs.tailwindcss-language-server

          templ-pkg
        ];
      };
    });
  };
            templ-pkg
          ];
        };
      }
    );
}