{
  inputs = {
    comfyui = {
      url = "github:comfyanonymous/ComfyUI";
      flake = false;
    };
  };

  nixConfig = {
    extra-substituters = ["https://nix-community.cachix.org" "https://cuda-maintainers.cachix.org"];
    extra-trusted-public-keys = [
      "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
      "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
    ];
  };

  outputs = {
    self,
    nixpkgs,
    comfyui,
  }: {
    homeManagerModules.comfyui = import ./module.nix;

    overlays.comfyui = final: _prev: {
      comfyui = let
        spandrel = final.callPackage ./spandrel.nix {};
      in
        final.callPackage ./default.nix {
          cudaSupport = true;
          inherit comfyui spandrel;
        };
    };

    packages.x86_64-linux = let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        config.allowUnfree = true;
        config.cudaSupport = true;
        inherit system;
      };
      spandrel = pkgs.callPackage ./spandrel.nix {};
    in {
      default = pkgs.callPackage ./default.nix {
        inherit comfyui spandrel;
      };
    };
  };
}
