{
  description = "Flake for building the MacGregor House website";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    utils.url = "github:numtide/flake-utils";
    mkElmDerivation.url = "github:jeslie0/mkElmDerivation";
    pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
  };

  outputs =
    {
      self,
      nixpkgs,
      utils,
      mkElmDerivation,
      pre-commit-hooks,
    }:
    utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = import nixpkgs {
          overlays = [ mkElmDerivation.overlays.mkElmDerivation ];
          inherit system;
        };
      in
      {
        devShells.default =
          with pkgs;
          mkShell {
            inherit (self.checks.${system}.pre-commit-check) shellHook;

            buildInputs = self.checks.${system}.pre-commit-check.enabledPackages ++ [
              elmPackages.elm
              elmPackages.elm-review
              elmPackages.elm-json
              entr
            ];
          };

        packages = {
          default = pkgs.mkElmDerivation {
            name = "macgregor";
            src = ./.;
            elmJson = ./elm.json;
            nativeBuildInputs = [ pkgs.elmPackages.elm ];
            buildPhase = ''
              elm make src/Main.elm --output Main.js --optimize
            '';
            installPhase = ''
              mkdir -p $out/dist/elm
              cp Main.js $out/dist/elm
              sed 's/..compiled\/Main.js/\/elm\/Main.js/' src/index.html > $out/dist/index.html
              cp -r assets $out/dist/assets
            '';
          };
        };

        checks = {
          pre-commit-check = pre-commit-hooks.lib.${system}.run {
            src = ./.;
            hooks = {
              nixfmt-rfc-style.enable = true;
              elm-format.enable = true;
              check-yaml.enable = true;
              yamlfmt.enable = true;
              yamllint.enable = true;
              check-json.enable = true;
              pretty-format-json.enable = true;
              deadnix.enable = true;
              flake-checker.enable = true;
              nil.enable = true;
              statix.enable = true;
              markdownlint.enable = true;
              typos.enable = true;
              check-merge-conflicts.enable = true;
              commitizen.enable = true;
              forbid-new-submodules.enable = true;
              check-case-conflicts.enable = true;
              check-executables-have-shebangs.enable = true;
              check-shebang-scripts-are-executable.enable = true;
              check-symlinks.enable = true;
              check-vcs-permalinks.enable = true;
              end-of-file-fixer.enable = true;
              mixed-line-endings.enable = true;
              tagref.enable = true;
              trim-trailing-whitespace.enable = true;
              trufflehog.enable = true;
              detect-private-keys.enable = true;
            };
          };
        };

        formatter = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style;
      }
    );
}
