From 8404f0998b0c961c9b5094d610ffce7fcde13121 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 3 Feb 2026 15:54:01 +0100 Subject: [PATCH] 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. --- .../mx/nextcloud-claude-bot/module.nix | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/systems/x86_64-linux/mx/nextcloud-claude-bot/module.nix b/systems/x86_64-linux/mx/nextcloud-claude-bot/module.nix index 2cf2495..7b2cda0 100644 --- a/systems/x86_64-linux/mx/nextcloud-claude-bot/module.nix +++ b/systems/x86_64-linux/mx/nextcloud-claude-bot/module.nix @@ -4,26 +4,17 @@ 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; [ - 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 - ''; - }; + + pythonEnv = pkgs.python3.withPackages (ps: with ps; [ + fastapi + uvicorn + httpx + ]); + + 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;