feat: added comfy ui

This commit is contained in:
Nick 2025-07-18 20:53:49 -05:00
parent c4f55dd01d
commit 848426d5ec
3 changed files with 40 additions and 136 deletions

View file

@ -62,7 +62,7 @@
url = "gitlab:InvraNet/zen-flake"; url = "gitlab:InvraNet/zen-flake";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nix-comfyui.url = "github:dyscorv/nix-comfyui"; nixified-ai.url = "github:matthewcroughan/nixified-ai";
}; };
outputs = outputs =
inputs: inputs:
@ -129,6 +129,7 @@
# inputs.ngipkgs.nixosModules."services.peertube" # inputs.ngipkgs.nixosModules."services.peertube"
# inputs.ngipkgs.nixosModules.default # inputs.ngipkgs.nixosModules.default
inputs.sops-nix.nixosModules.sops inputs.sops-nix.nixosModules.sops
inputs.nixified-ai.nixosModules.comfyui
]; ];
}; };
templates = { templates = {

View file

@ -1,90 +1,55 @@
{ {
config, config,
lib,
pkgs, pkgs,
flake, flake,
... ...
}: }:
let let
inherit (flake.config.machines.devices) ceres;
inherit (flake.config.services.instances) comfyui web;
inherit (flake.config.people) user0; inherit (flake.config.people) user0;
cfg = config.services.comfyui; service = comfyui;
localhost = web.localhost.address1;
in in
{ {
imports = [ ]; nixpkgs.overlays = [
flake.inputs.nix-comfyui.overlays.default
options = {
services.comfyui = with lib; {
enable = mkEnableOption "ComfyUI service";
package = mkOption {
type = types.package;
default = pkgs.comfyuiPackages.comfyui.override {
extensions = with pkgs.comfyuiPackages.extensions; [
# Add desired extensions here
# Example extensions:
# acly-inpaint
# acly-tooling
# cubiq-ipadapter-plus
# fannovel16-controlnet-aux
]; ];
commandLineArgs = [
"--preview-method" services.comfyui = {
"auto" enable = true;
package = pkgs.comfyui-nvidia;
host = localhost;
models = builtins.attrValues pkgs.nixified-ai.models;
customNodes = with comfyui.pkgs; [
comfyui-gguf
comfyui-impact-pack
]; ];
}; };
description = "The ComfyUI package to use"; fileSystems."/var/lib/${service.name}" = {
device = service.paths.path0;
fsType = "none";
options = [
"bind"
];
depends = [
ceres.storage0.mount
];
}; };
port = mkOption { systemd.tmpfiles.rules = [
type = types.port; "Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
default = 8188; ];
description = "Port to listen on";
};
host = mkOption { users.users.${service.name}.extraGroups = [
type = types.str; "users"
default = "127.0.0.1"; ];
description = "Host to bind to";
};
openFirewall = mkOption { networking = {
type = types.bool; firewall = {
default = false; allowedTCPPorts = [
description = "Open ports in the firewall"; service.ports.port0
];
}; };
}; };
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.port ];
};
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";
};
};
users.users.comfyui = {
group = "comfyui";
isSystemUser = true;
home = "/var/lib/comfyui";
createHome = true;
};
users.groups.comfyui = { };
};
} }

View file

@ -1,62 +0,0 @@
{
config,
pkgs,
flake,
...
}:
let
inherit (flake.config.machines.devices) ceres;
inherit (flake.config.services.instances) comfyui web;
inherit (flake.config.people) user0;
service = comfyui;
localhost = web.localhost.address1;
in
{
nixpkgs.overlays = [
flake.inputs.nix-comfyui.overlays.default
];
services.comfyui = {
enable = true;
openFirewall = true;
host = localhost;
package = pkgs.comfyuiPackages.comfyui.override {
extensions = with pkgs.comfyuiPackages.extensions; [
acly-inpaint
acly-tooling
cubiq-ipadapter-plus
fannovel16-controlnet-aux
];
commandLineArgs = [
"--preview-method"
"auto"
];
};
};
fileSystems."/var/lib/${service.name}" = {
device = service.paths.path0;
fsType = "none";
options = [
"bind"
];
depends = [
ceres.storage0.mount
];
};
systemd.tmpfiles.rules = [
"Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
];
users.users.${service.name}.extraGroups = [
"users"
];
networking = {
firewall = {
allowedTCPPorts = [
service.ports.port0
];
};
};
}