refactor(nix): simplify Nextcloud Claude Bot packaging
- Replaced `buildPythonApplication` with `python3.withPackages` for a cleaner and more concise implementation. - Adjusted service configuration to use the updated packaging structure, ensuring compatibility with the new setup. - Simplifies the NixOS module by reducing redundancy and improving maintainability.
This commit is contained in:
parent
bc6091f63f
commit
8404f0998b
1 changed files with 14 additions and 22 deletions
|
|
@ -5,25 +5,16 @@ with lib;
|
|||
let
|
||||
cfg = config.services.nextcloud-claude-bot;
|
||||
|
||||
botScript = pkgs.python3Packages.buildPythonApplication {
|
||||
pname = "nextcloud-claude-bot";
|
||||
version = "0.1.0";
|
||||
format = "other";
|
||||
|
||||
propagatedBuildInputs = with pkgs.python3Packages; [
|
||||
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
|
||||
fastapi
|
||||
uvicorn
|
||||
httpx
|
||||
];
|
||||
]);
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp ${./bot.py} $out/bin/nextcloud-claude-bot
|
||||
chmod +x $out/bin/nextcloud-claude-bot
|
||||
botModule = pkgs.runCommand "nextcloud-claude-bot-module" {} ''
|
||||
mkdir -p $out
|
||||
cp ${./bot.py} $out/nextcloud_claude_bot.py
|
||||
'';
|
||||
};
|
||||
|
||||
in {
|
||||
options.services.nextcloud-claude-bot = {
|
||||
|
|
@ -100,11 +91,12 @@ in {
|
|||
MAX_TOKENS = toString cfg.maxTokens;
|
||||
TIMEOUT = toString cfg.timeout;
|
||||
SYSTEM_PROMPT = cfg.systemPrompt or "";
|
||||
PYTHONPATH = botModule;
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.python3Packages.uvicorn}/bin/uvicorn nextcloud_claude_bot:app --host ${cfg.host} --port ${toString cfg.port}";
|
||||
ExecStart = "${pythonEnv}/bin/uvicorn nextcloud_claude_bot:app --host ${cfg.host} --port ${toString cfg.port}";
|
||||
Restart = "always";
|
||||
RestartSec = 5;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue