tools: allow toolchain overrides
What: add tool list overrides + excludes in tooling and module defaults. Why: let downstream drop overlapping tools to avoid buildEnv collisions. Tests: not run (packaging change)
This commit is contained in:
parent
165700076d
commit
7f07d9e844
16
README.md
16
README.md
@ -593,6 +593,22 @@ in {
|
||||
|
||||
Plugins are keyed by their declared `name`. If two plugins declare the same name, the **last entry wins** (use this to override a prod plugin with a local dev one).
|
||||
|
||||
### Tool overrides (avoid collisions)
|
||||
|
||||
Drop built-in tools that you already install elsewhere:
|
||||
|
||||
```nix
|
||||
programs.clawdbot.excludeTools = [ "git" "jq" "ripgrep" ];
|
||||
```
|
||||
|
||||
Or provide a custom list:
|
||||
|
||||
```nix
|
||||
programs.clawdbot.toolNames = [ "nodejs_22" "pnpm_10" "summarize" ];
|
||||
```
|
||||
|
||||
If you override `programs.clawdbot.package`, use `pkgs.clawdbotPackages.withTools { ... }.clawdbot` to apply these lists.
|
||||
|
||||
---
|
||||
|
||||
## Packaging & Updates
|
||||
|
||||
@ -3,7 +3,17 @@
|
||||
let
|
||||
cfg = config.programs.clawdbot;
|
||||
homeDir = config.home.homeDirectory;
|
||||
appPackage = if cfg.appPackage != null then cfg.appPackage else cfg.package;
|
||||
toolOverrides = {
|
||||
toolNamesOverride = cfg.toolNames;
|
||||
excludeToolNames = cfg.excludeTools;
|
||||
};
|
||||
toolOverridesEnabled = cfg.toolNames != null || cfg.excludeTools != [];
|
||||
toolSets = import ../../tools/extended.nix ({ inherit pkgs; } // toolOverrides);
|
||||
defaultPackage =
|
||||
if toolOverridesEnabled && cfg.package == pkgs.clawdbot
|
||||
then (pkgs.clawdbotPackages.withTools toolOverrides).clawdbot
|
||||
else cfg.package;
|
||||
appPackage = if cfg.appPackage != null then cfg.appPackage else defaultPackage;
|
||||
generatedConfigOptions = import ../../generated/clawdbot-config-options.nix { lib = lib; };
|
||||
|
||||
mkBaseConfig = workspaceDir: inst: {
|
||||
@ -75,7 +85,7 @@ let
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = cfg.package;
|
||||
default = defaultPackage;
|
||||
description = "Clawdbot batteries-included package.";
|
||||
};
|
||||
|
||||
@ -445,8 +455,7 @@ let
|
||||
toolsReport =
|
||||
if documentsEnabled then
|
||||
let
|
||||
toolNames =
|
||||
(import ../../tools/extended.nix { inherit pkgs; }).toolNames or [];
|
||||
toolNames = toolSets.toolNames or [];
|
||||
renderPkgName = pkg:
|
||||
if pkg ? pname then pkg.pname else lib.getName pkg;
|
||||
renderPlugin = plugin:
|
||||
@ -866,6 +875,18 @@ in {
|
||||
description = "Clawdbot batteries-included package.";
|
||||
};
|
||||
|
||||
toolNames = lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.listOf lib.types.str);
|
||||
default = null;
|
||||
description = "Override the built-in toolchain names (see nix/tools/extended.nix).";
|
||||
};
|
||||
|
||||
excludeTools = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [];
|
||||
description = "Tool names to remove from the built-in toolchain.";
|
||||
};
|
||||
|
||||
appPackage = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.package;
|
||||
default = null;
|
||||
|
||||
@ -1,30 +1,47 @@
|
||||
{ pkgs
|
||||
, sourceInfo ? import ../sources/clawdbot-source.nix
|
||||
, steipetePkgs ? {}
|
||||
, toolNamesOverride ? null
|
||||
, excludeToolNames ? []
|
||||
}:
|
||||
let
|
||||
isDarwin = pkgs.stdenv.hostPlatform.isDarwin;
|
||||
toolSets = import ../tools/extended.nix {
|
||||
pkgs = pkgs;
|
||||
steipetePkgs = steipetePkgs;
|
||||
};
|
||||
clawdbotGateway = pkgs.callPackage ./clawdbot-gateway.nix {
|
||||
inherit sourceInfo;
|
||||
pnpmDepsHash = sourceInfo.pnpmDepsHash or null;
|
||||
};
|
||||
clawdbotApp = if isDarwin then pkgs.callPackage ./clawdbot-app.nix { } else null;
|
||||
clawdbotTools = pkgs.buildEnv {
|
||||
name = "clawdbot-tools";
|
||||
paths = toolSets.tools;
|
||||
pathsToLink = [ "/bin" ];
|
||||
};
|
||||
clawdbotBundle = pkgs.callPackage ./clawdbot-batteries.nix {
|
||||
clawdbot-gateway = clawdbotGateway;
|
||||
clawdbot-app = clawdbotApp;
|
||||
extendedTools = toolSets.tools;
|
||||
};
|
||||
in {
|
||||
clawdbot-gateway = clawdbotGateway;
|
||||
clawdbot = clawdbotBundle;
|
||||
clawdbot-tools = clawdbotTools;
|
||||
} // (if isDarwin then { clawdbot-app = clawdbotApp; } else {})
|
||||
|
||||
mkToolSets = { toolNamesOverride ? null, excludeToolNames ? [] }:
|
||||
import ../tools/extended.nix {
|
||||
pkgs = pkgs;
|
||||
steipetePkgs = steipetePkgs;
|
||||
inherit toolNamesOverride excludeToolNames;
|
||||
};
|
||||
|
||||
mkPackageSet = { toolNamesOverride ? null, excludeToolNames ? [] }:
|
||||
let
|
||||
toolSets = mkToolSets { inherit toolNamesOverride excludeToolNames; };
|
||||
clawdbotTools = pkgs.buildEnv {
|
||||
name = "clawdbot-tools";
|
||||
paths = toolSets.tools;
|
||||
pathsToLink = [ "/bin" ];
|
||||
};
|
||||
clawdbotBundle = pkgs.callPackage ./clawdbot-batteries.nix {
|
||||
clawdbot-gateway = clawdbotGateway;
|
||||
clawdbot-app = clawdbotApp;
|
||||
extendedTools = toolSets.tools;
|
||||
};
|
||||
in {
|
||||
clawdbot-gateway = clawdbotGateway;
|
||||
clawdbot = clawdbotBundle;
|
||||
clawdbot-tools = clawdbotTools;
|
||||
toolNames = toolSets.toolNames;
|
||||
} // (if isDarwin then { clawdbot-app = clawdbotApp; } else {});
|
||||
|
||||
packageSet = mkPackageSet { inherit toolNamesOverride excludeToolNames; };
|
||||
in
|
||||
packageSet // {
|
||||
withTools = { toolNamesOverride ? null, excludeToolNames ? [] }:
|
||||
mkPackageSet { inherit toolNamesOverride excludeToolNames; };
|
||||
}
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
{ pkgs, steipetePkgs ? {} }:
|
||||
{ pkgs
|
||||
, steipetePkgs ? {}
|
||||
, toolNamesOverride ? null
|
||||
, excludeToolNames ? []
|
||||
}:
|
||||
let
|
||||
lib = pkgs.lib;
|
||||
safe = list: builtins.filter (p: p != null) list;
|
||||
@ -47,7 +51,8 @@ let
|
||||
"qmd"
|
||||
"nano-pdf"
|
||||
];
|
||||
toolNames = baseNames ++ extraNames;
|
||||
toolNamesBase = if toolNamesOverride != null then toolNamesOverride else baseNames ++ extraNames;
|
||||
toolNames = builtins.filter (name: !builtins.elem name excludeToolNames) toolNamesBase;
|
||||
|
||||
in {
|
||||
tools = ensure toolNames;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user