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
cfg = config.services.nextcloud-claude-bot;
botScript = pkgs.python3Packages.buildPythonApplication {
pname = "nextcloud-claude-bot";
version = "0.1.0";
format = "other";
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
fastapi
uvicorn
httpx
]);
propagatedBuildInputs = with pkgs.python3Packages; [
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;