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:
Harald Hoyer 2026-02-03 15:54:01 +01:00
parent bc6091f63f
commit 8404f0998b

View file

@ -5,25 +5,16 @@ with lib;
let let
cfg = config.services.nextcloud-claude-bot; cfg = config.services.nextcloud-claude-bot;
botScript = pkgs.python3Packages.buildPythonApplication { pythonEnv = pkgs.python3.withPackages (ps: with ps; [
pname = "nextcloud-claude-bot";
version = "0.1.0";
format = "other";
propagatedBuildInputs = with pkgs.python3Packages; [
fastapi fastapi
uvicorn uvicorn
httpx httpx
]; ]);
dontUnpack = true; botModule = pkgs.runCommand "nextcloud-claude-bot-module" {} ''
mkdir -p $out
installPhase = '' cp ${./bot.py} $out/nextcloud_claude_bot.py
mkdir -p $out/bin
cp ${./bot.py} $out/bin/nextcloud-claude-bot
chmod +x $out/bin/nextcloud-claude-bot
''; '';
};
in { in {
options.services.nextcloud-claude-bot = { options.services.nextcloud-claude-bot = {
@ -100,11 +91,12 @@ in {
MAX_TOKENS = toString cfg.maxTokens; MAX_TOKENS = toString cfg.maxTokens;
TIMEOUT = toString cfg.timeout; TIMEOUT = toString cfg.timeout;
SYSTEM_PROMPT = cfg.systemPrompt or ""; SYSTEM_PROMPT = cfg.systemPrompt or "";
PYTHONPATH = botModule;
}; };
serviceConfig = { serviceConfig = {
Type = "simple"; 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"; Restart = "always";
RestartSec = 5; RestartSec = 5;