dotfiles/modules/nixos/services/comfyui/default.nix

91 lines
2 KiB
Nix
Raw Permalink Normal View History

2025-07-18 14:57:37 -05:00
{
2025-07-19 19:06:11 -05:00
config,
lib,
pkgs,
2025-07-19 19:11:24 -05:00
flake,
2025-07-19 19:06:11 -05:00
...
}:
let
2025-07-19 19:11:24 -05:00
inherit (flake.config.people) user0;
2025-07-19 19:06:11 -05:00
cfg = config.services.comfyui;
in
{
imports = [ ];
options = {
services.comfyui = with lib; {
enable = mkEnableOption "ComfyUI service";
package = mkOption {
type = types.package;
2025-08-03 22:22:18 -05:00
default = pkgs.comfyuiPackages.comfyui.override {
2025-08-03 23:34:09 -05:00
extensions = with pkgs.comfyuiPackages.extensions; [
# Add desired extensions here
# Example extensions:
# acly-inpaint
# acly-tooling
# cubiq-ipadapter-plus
# fannovel16-controlnet-aux
];
2025-08-03 22:22:18 -05:00
commandLineArgs = [
"--preview-method"
"auto"
];
};
2025-07-19 19:06:11 -05:00
description = "The ComfyUI package to use";
};
port = mkOption {
type = types.port;
default = 8188;
description = "Port to listen on";
};
host = mkOption {
type = types.str;
default = "127.0.0.1";
description = "Host to bind to";
};
openFirewall = mkOption {
type = types.bool;
default = false;
description = "Open ports in the firewall";
};
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.port ];
};
2025-08-03 22:19:54 -05:00
systemd.services.comfyui = {
description = "ComfyUI Service";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${cfg.package}/bin/comfyui --port ${toString cfg.port} --listen ${cfg.host}";
Restart = "on-failure";
User = "comfyui";
Group = "comfyui";
WorkingDirectory = "/var/lib/comfyui";
2025-07-19 19:06:11 -05:00
};
2025-08-03 22:19:54 -05:00
};
2025-07-19 19:06:11 -05:00
users.users.comfyui = {
group = "comfyui";
isSystemUser = true;
home = "/var/lib/comfyui";
createHome = true;
2025-07-18 16:56:51 -05:00
};
2025-07-19 19:06:11 -05:00
users.groups.comfyui = { };
2025-07-18 16:56:51 -05:00
};
2025-07-18 14:57:37 -05:00
}