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

@ -4,26 +4,17 @@ 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"; fastapi
version = "0.1.0"; uvicorn
format = "other"; httpx
]);
propagatedBuildInputs = with pkgs.python3Packages; [
fastapi botModule = pkgs.runCommand "nextcloud-claude-bot-module" {} ''
uvicorn mkdir -p $out
httpx cp ${./bot.py} $out/nextcloud_claude_bot.py
]; '';
dontUnpack = true;
installPhase = ''
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;