Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 39 additions & 18 deletions nix/modules/home-manager/clawdbot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,39 @@ let
}
];
};
} // lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
# Disable memory slot on Linux - memory-core plugin not available for headless servers
# See: https://github.com/clawdbot/clawdbot/blob/main/docs/concepts/memory.md
plugins.slots.memory = "none";
};

mkTelegramConfig = inst: lib.optionalAttrs inst.providers.telegram.enable {
telegram = {
enabled = true;
tokenFile = inst.providers.telegram.botTokenFile;
allowFrom = inst.providers.telegram.allowFrom;
groups = inst.providers.telegram.groups;
channels = {
telegram = {
enabled = true;
tokenFile = inst.providers.telegram.botTokenFile;
allowFrom = inst.providers.telegram.allowFrom;
groups = inst.providers.telegram.groups;
};
};
};

mkRoutingConfig = inst: {
messages = {
queue = {
mode = inst.routing.queue.mode;
byProvider = inst.routing.queue.byProvider;
byChannel = inst.routing.queue.byProvider;
};
};
};

mkAuthConfig = inst: lib.optionalAttrs (inst.providers.anthropic.apiKeyFile != "") {
auth = {
profiles = {
"anthropic:default" = {
provider = "anthropic";
mode = "api_key";
};
};
};
};
Expand Down Expand Up @@ -729,9 +746,13 @@ let
pluginPackages = pluginPackagesFor name;
pluginEnvAll = pluginEnvAllFor name;
baseConfig = mkBaseConfig inst.workspaceDir inst;
mergedConfig = lib.recursiveUpdate
(lib.recursiveUpdate baseConfig (lib.recursiveUpdate (mkTelegramConfig inst) (mkRoutingConfig inst)))
inst.configOverrides;
mergedConfig = lib.foldl' lib.recursiveUpdate {} [
baseConfig
(mkTelegramConfig inst)
(mkRoutingConfig inst)
(mkAuthConfig inst)
inst.configOverrides
];
configJson = builtins.toJSON mergedConfig;
configFile = pkgs.writeText "clawdbot-${name}.json" configJson;
gatewayWrapper = pkgs.writeShellScriptBin "clawdbot-gateway-${name}" ''
Expand Down Expand Up @@ -996,13 +1017,13 @@ in {
firstParty = {
summarize.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable the summarize plugin (first-party).";
default = pkgs.stdenv.hostPlatform.isDarwin; # macOS-only: uses macOS-specific dependencies
description = "Enable the summarize plugin (first-party, macOS only).";
};
peekaboo.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable the peekaboo plugin (first-party).";
default = pkgs.stdenv.hostPlatform.isDarwin; # macOS-only: screenshot tool
description = "Enable the peekaboo plugin (first-party, macOS only).";
};
oracle.enable = lib.mkOption {
type = lib.types.bool;
Expand All @@ -1022,7 +1043,7 @@ in {
camsnap.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable the camsnap plugin (first-party).";
description = "Enable the camsnap plugin (first-party, macOS only).";
};
gogcli.enable = lib.mkOption {
type = lib.types.bool;
Expand All @@ -1042,7 +1063,7 @@ in {
imsg.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable the imsg plugin (first-party).";
description = "Enable the imsg plugin (first-party, macOS only).";
};
};

Expand Down Expand Up @@ -1176,13 +1197,13 @@ in {
);

home.activation.clawdbotDirs = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
/bin/mkdir -p ${lib.concatStringsSep " " (lib.concatMap (item: item.dirs) instanceConfigs)}
${lib.optionalString (pluginStateDirsAll != []) "/bin/mkdir -p ${lib.concatStringsSep " " pluginStateDirsAll}"}
run mkdir -p ${lib.concatStringsSep " " (lib.concatMap (item: item.dirs) instanceConfigs)}
${lib.optionalString (pluginStateDirsAll != []) "run mkdir -p ${lib.concatStringsSep " " pluginStateDirsAll}"}
'';

home.activation.clawdbotConfigFiles = lib.hm.dag.entryAfter [ "clawdbotDirs" ] ''
set -euo pipefail
${lib.concatStringsSep "\n" (map (item: "/bin/ln -sfn ${item.configFile} ${item.configPath}") instanceConfigs)}
${lib.concatStringsSep "\n" (map (item: "run ln -sfn ${item.configFile} ${item.configPath}") instanceConfigs)}
'';

home.activation.clawdbotPluginGuard = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
Expand Down
2 changes: 1 addition & 1 deletion nix/scripts/gateway-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e
mkdir -p "$out/lib/clawdbot" "$out/bin"

cp -r dist node_modules package.json ui "$out/lib/clawdbot/"
cp -r dist node_modules package.json ui extensions docs "$out/lib/clawdbot/"

if [ -z "${STDENV_SETUP:-}" ]; then
echo "STDENV_SETUP is not set" >&2
Expand Down