{
  description = "Website Environment";

  inputs = {
    flake-parts.url = "github:hercules-ci/flake-parts";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
    treefmt-nix.url = "github:numtide/treefmt-nix";
    mkElmDerivation.url = "github:jeslie0/mkElmDerivation";
  };

  outputs =
    inputs:
    inputs.flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [ inputs.treefmt-nix.flakeModule ];

      perSystem =
        { pkgs, lib, ... }:
        let
          hp = pkgs.haskellPackages;
          backend = hp.callCabal2nix "backend" ./backend { };
        in
        {
          devShells.default = hp.shellFor {
            nativeBuildInputs = builtins.attrValues {
              inherit (pkgs)
                nil
                stylish-haskell
                ghc
                vscode-langservers-extracted
                nixfmt-rfc-style
                ;
              inherit (hp)
                cabal-install
                cabal-gild
                haskell-language-server
                hlint
                fourmolu
                ;
              inherit (inputs.nixpkgs-stable.legacyPackages.${pkgs.system}.elmPackages)
                elm
                elm-format
                elm-land
                elm-language-server
                elm-review
                elm-test
                ;
            };
            packages = _: [ backend ];
          };

          packages =
            let
              pkgs' = pkgs.extend inputs.mkElmDerivation.overlays.mkElmDerivation;
            in
            {
              websiteBackend = backend;

              websiteFrontend = pkgs'.mkElmDerivation {
                name = "website";
                src = ./frontend;
                nativeBuildInputs = builtins.attrValues {
                  inherit (inputs.nixpkgs-stable.legacyPackages.${pkgs.system}.elmPackages)
                    elm
                    elm-land
                    ;
                };

                buildPhase = ''
                  ${lib.getExe pkgs'.elm-land} build
                '';

                installPhase = ''
                  mkdir -p "$out"
                  cp -r dist/* "$out/"
                '';
              };
            };

          treefmt = {
            programs = {
              cabal-fmt.enable = true;
              deadnix.enable = true;
              hlint.enable = true;
              nixfmt.enable = true;
              fourmolu.enable = true;
              statix.enable = true;
              typstyle.enable = true;
              yamlfmt.enable = true;
            };
            backendRootFile = "flake.nix";
          };
        };

      systems = [ "x86_64-linux" ];
    };
}
