refactor(architect/llm.nix): simplify and clean up configuration
- Removed unused frontend domain, port, and listen address variables - Centralized `ollamaHost` and `ollamaPort` usage - Cleaned up commented-out sections for future reference or removal - Ensured consistent placement of `acceleration` in the `services.ollama` block
This commit is contained in:
		
							parent
							
								
									47495b845a
								
							
						
					
					
						commit
						2b17b0b463
					
				@ -1,11 +1,9 @@
 | 
				
			|||||||
{ pkgs, ... }:
 | 
					{ pkgs, ... }:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let
 | 
					let
 | 
				
			||||||
  frontendDomain = "pino.giugl.io";
 | 
					 | 
				
			||||||
  backendDomain = "ollama.giugl.io";
 | 
					  backendDomain = "ollama.giugl.io";
 | 
				
			||||||
  frontendPort = 3030;
 | 
					  ollamaHost = "127.0.0.1";
 | 
				
			||||||
  ollamaPort = 11434;
 | 
					  ollamaPort = 11434;
 | 
				
			||||||
  listenAddress = "127.0.0.1:${toString ollamaPort}";
 | 
					 | 
				
			||||||
  ollamaPkg = pkgs.unstablePkgs.ollama;
 | 
					  ollamaPkg = pkgs.unstablePkgs.ollama;
 | 
				
			||||||
in
 | 
					in
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -14,37 +12,23 @@ in
 | 
				
			|||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  services.ollama = {
 | 
					  services.ollama = {
 | 
				
			||||||
    inherit listenAddress;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    enable = true;
 | 
					    enable = true;
 | 
				
			||||||
    acceleration = "cuda";
 | 
					
 | 
				
			||||||
    package = ollamaPkg;
 | 
					    package = ollamaPkg;
 | 
				
			||||||
 | 
					    host = ollamaHost;
 | 
				
			||||||
 | 
					    port = ollamaPort;
 | 
				
			||||||
 | 
					    acceleration = "cuda";
 | 
				
			||||||
    environmentVariables = {
 | 
					    environmentVariables = {
 | 
				
			||||||
      # OLLAMA_ORIGINS = "10.0.0.0/24";
 | 
					 | 
				
			||||||
      OLLAMA_FLASH_ATTENTION = "1";
 | 
					      OLLAMA_FLASH_ATTENTION = "1";
 | 
				
			||||||
      OLLAMA_NUM_PARALLEL = "2";
 | 
					      OLLAMA_NUM_PARALLEL = "2";
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # architect.vhost.${frontendDomain} = {
 | 
					 | 
				
			||||||
  #   dnsInterfaces = [ "tailscale" "lan" ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  #   locations."/" = {
 | 
					 | 
				
			||||||
  #     host = "127.0.0.1";
 | 
					 | 
				
			||||||
  #     port = frontendPort;
 | 
					 | 
				
			||||||
  #     allowLan = true;
 | 
					 | 
				
			||||||
  #     allowWAN = true;
 | 
					 | 
				
			||||||
  #     extraConfig = ''
 | 
					 | 
				
			||||||
  #       proxy_read_timeout 600s;
 | 
					 | 
				
			||||||
  #     '';
 | 
					 | 
				
			||||||
  #   };
 | 
					 | 
				
			||||||
  # };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  architect.vhost.${backendDomain} = {
 | 
					  architect.vhost.${backendDomain} = {
 | 
				
			||||||
    dnsInterfaces = [ "tailscale" "lan" ];
 | 
					    dnsInterfaces = [ "tailscale" "lan" ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    locations."/" = {
 | 
					    locations."/" = {
 | 
				
			||||||
      host = "127.0.0.1";
 | 
					      host = ollamaHost;
 | 
				
			||||||
      port = ollamaPort;
 | 
					      port = ollamaPort;
 | 
				
			||||||
      allowLan = true;
 | 
					      allowLan = true;
 | 
				
			||||||
      allowWAN = true;
 | 
					      allowWAN = true;
 | 
				
			||||||
@ -56,28 +40,4 @@ in
 | 
				
			|||||||
      '';
 | 
					      '';
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					 | 
				
			||||||
  # virtualisation.oci-containers = {
 | 
					 | 
				
			||||||
  #   containers = {
 | 
					 | 
				
			||||||
  #     ollama-webui = {
 | 
					 | 
				
			||||||
  #       image = "ghcr.io/open-webui/open-webui:main";
 | 
					 | 
				
			||||||
  #       autoStart = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  #       ports = [
 | 
					 | 
				
			||||||
  #         "127.0.0.1:${toString frontendPort}:8080"
 | 
					 | 
				
			||||||
  #       ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  #       environment = {
 | 
					 | 
				
			||||||
  #         OLLAMA_BASE_URL = "https://${backendDomain}";
 | 
					 | 
				
			||||||
  #       };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  #       extraOptions = [
 | 
					 | 
				
			||||||
  #         "--pull=always"
 | 
					 | 
				
			||||||
  #       ];
 | 
					 | 
				
			||||||
  #       volumes = [
 | 
					 | 
				
			||||||
  #         "/var/lib/ollama-webui:/app/backend/data"
 | 
					 | 
				
			||||||
  #       ];
 | 
					 | 
				
			||||||
  #     };
 | 
					 | 
				
			||||||
  #   };
 | 
					 | 
				
			||||||
  # };
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user