feat(access): a llama

This commit is contained in:
arcnmx 2024-09-12 15:25:05 -07:00
parent e3b6048e32
commit 7bf1ce71de
14 changed files with 323 additions and 6 deletions

View file

@ -60,6 +60,7 @@ let
(mkIf (cfg.id != null) (mkAlmostOptionDefault (access.systemForServiceId cfg.id).name))
(mkOptionDefault (mapNullable (serviceName: (access.systemForService serviceName).name) cfg.name))
];
network = mkIf (port.listen == "tail") (mkAlmostOptionDefault "tail");
};
conf = {
enable = lib.warnIf (!port.enable) "${cfg.system}.exports.services.${cfg.name}.ports.${cfg.port} isn't enabled" (

View file

@ -5,7 +5,7 @@
gensokyo-zone,
...
}: let
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
inherit (gensokyo-zone.lib) mkAlmostOptionDefault bindToAddress;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkBefore mkAfter mkOptionDefault mkDefault;
inherit (lib.attrsets) mapAttrsToList;
@ -296,10 +296,7 @@ in {
upstreams' = let
localVouch = let
inherit (vouch-proxy.settings.vouch) listen port;
host =
if listen == "0.0.0.0" || listen == "[::]"
then "localhost"
else listen;
host = bindToAddress {localhost = "localhost";} listen;
in {
# TODO: accessService.exportedId = "login";
enable = mkAlmostOptionDefault vouch-proxy.enable;

View file

@ -0,0 +1,30 @@
{
lib,
gensokyo-zone,
...
}: let
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
inherit (lib.modules) mkIf;
in {
config.exports.services.ollama = {config, ...}: {
displayName = mkAlmostOptionDefault "Ollama";
id = mkAlmostOptionDefault "ollama";
nixos = {
serviceAttr = "ollama";
assertions = mkIf config.enable [
(nixosConfig: {
assertion = config.ports.default.port == nixosConfig.services.ollama.port;
message = "port mismatch";
})
];
};
defaults.port.listen = mkAlmostOptionDefault "lan";
ports = {
default = {
port = mkAlmostOptionDefault 11434;
protocol = "http";
status.enable = mkAlmostOptionDefault true;
};
};
};
}

View file

@ -38,7 +38,7 @@
else config.name;
};
listen = mkOption {
type = enum ["wan" "lan" "int" "localhost"];
type = enum ["wan" "lan" "int" "tail" "localhost"];
};
protocol = mkOption {
type = nullOr (enum ["http" "https"]);