{
  description = "tlater.net web server";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
    dream2nix.url = "github:nix-community/dream2nix";

    fenix = {
      url = "github:nix-community/fenix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    self,
    nixpkgs,
    dream2nix,
    fenix,
  }: let
    # At the moment, we only deploy to x86_64-linux. Update when we
    # care about another platform.
    system = "x86_64-linux";
    flakeOutputs = import ./nix/packages.nix {inherit nixpkgs dream2nix fenix system;};
  in {
    packages.${system} = {
      server = flakeOutputs.server.packages.${system}.default;
      templates = flakeOutputs.templates.packages.${system}.default;
    };

    apps.${system}.default = let
      inherit (self.packages.${system}) server templates;
      inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
    in {
      type = "app";
      program = builtins.toString (writeShellScript "tlaternet-webserver" ''
        ${server}/bin/tlaternet-webserver --template-directory ${templates}
      '');
    };

    nixosModules.default = import ./nix/module.nix {inherit self system;};

    devShells.${system} = {
      templates = flakeOutputs.templates.devShells.${system}.default.overrideAttrs (old: {
        buildInputs = with nixpkgs.legacyPackages.${system};
          [
            yj
          ]
          ++ old.buildInputs;
      });

      server = nixpkgs.legacyPackages.${system}.mkShell {
        packages = [
          (flakeOutputs.server.rust-toolchain.withComponents [
            "rustc"
            "cargo"
            "rustfmt"
            "rust-std"
            "rust-docs"
            "clippy"
            "rust-src"
            "rust-analysis"
          ])
          fenix.packages.${system}.rust-analyzer
        ];
      };
    };

    checks.${system} = import ./nix/checks {
      inherit self system;
      pkgs = nixpkgs.legacyPackages.${system};
    };
  };
}