changed formatting for ollama.nix to wrap all of configurations in its enable option

This commit is contained in:
Leyla Becker 2025-05-25 13:49:03 -05:00
parent 393f468be2
commit 089fbb8717

View file

@ -7,7 +7,8 @@
services.ollama.exposePort = lib.mkEnableOption "should we expose ollama on tailscale";
};
config = lib.mkMerge [
config = lib.mkIf config.services.ollama.enable (
lib.mkMerge [
{
services.ollama = {
# TODO: these should match whats set in the users file
@ -15,7 +16,17 @@
user = "ollama";
};
}
(lib.mkIf config.host.impermanence.enable (lib.mkIf config.services.ollama.enable {
(lib.mkIf config.services.ollama.exposePort (let
ports = [
config.services.ollama.port
];
in {
networking.firewall.interfaces.${config.services.tailscale.interfaceName} = {
allowedTCPPorts = ports;
allowedUDPPorts = ports;
};
}))
(lib.mkIf config.host.impermanence.enable {
environment.persistence."/persist/system/root" = {
enable = true;
hideMounts = true;
@ -27,15 +38,7 @@
}
];
};
networking.firewall.interfaces.${config.services.tailscale.interfaceName} = let
ports = [
config.services.ollama.port
];
in
lib.mkIf config.services.ollama.exposePort {
allowedTCPPorts = ports;
allowedUDPPorts = ports;
};
}))
];
})
]
);
}