-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathada.nix
70 lines (53 loc) · 1.71 KB
/
ada.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{ config, lib, options, pkgs, ... }:
{ options.services.ada = {
enable = lib.mkEnableOption "ada";
chat-model = lib.mkOption {
type = lib.types.str;
};
embedding-model = lib.mkOption {
type = lib.types.str;
};
openAIKeyFile = lib.mkOption {
type = lib.types.path;
};
slackKeyFile = lib.mkOption {
type = lib.types.path;
};
slackSigningSecretFile = lib.mkOption {
type = lib.types.path;
};
getDXKeyFile = lib.mkOption {
type = lib.types.path;
};
store = lib.mkOption {
type = lib.types.path;
};
port = lib.mkOption {
type = lib.types.nullOr lib.types.port;
default = null;
};
debug = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
};
};
config = {
nixpkgs.overlays = [ (import ./overlay.nix) ];
systemd.services.ada = lib.mkIf config.services.ada.enable {
wantedBy = [ "multi-user.target" ];
path = [ pkgs.ada ];
script =
let
adaOptions = {
inherit (config.services.ada) chat-model embedding-model store;
};
queryOptions = {
inherit (config.services.ada) port debug;
};
in
''
ada --openai-key "$(< ${lib.escapeShellArg config.services.ada.openAIKeyFile})" ${lib.cli.toGNUCommandLineShell { } adaOptions} query ${lib.cli.toGNUCommandLineShell { } queryOptions} --slack-api-key "$(< ${lib.escapeShellArg config.services.ada.slackKeyFile})" --slack-signing-secret "$(< ${lib.escapeShellArg config.services.ada.slackSigningSecretFile})" --getdx-api-key "$(< ${lib.escapeShellArg config.services.ada.getDXKeyFile})"
'';
};
};
}