From 61ecf7858ae4982df17dc9a131fc4885d4ecd68f Mon Sep 17 00:00:00 2001 From: Akizon77 Date: Mon, 7 Jul 2025 23:49:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=AF=B9NixOS?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index f7b7a0e..f10aa1f 100644 --- a/install.sh +++ b/install.sh @@ -238,7 +238,28 @@ log_success "Komari-agent installed to ${GREEN}$komari_agent_path${NC}" # Detect init system and configure service log_step "Configuring system service..." -if command -v systemctl >/dev/null 2>&1; then + +# Check if running on NixOS +if [ -f /etc/NIXOS ]; then + log_warning "NixOS detected. System services must be configured declaratively." + log_info "Please add the following to your NixOS configuration:" + echo "" + echo -e "${CYAN}systemd.services.${service_name} = {${NC}" + echo -e "${CYAN} description = \"Komari Agent Service\";${NC}" + echo -e "${CYAN} after = [ \"network.target\" ];${NC}" + echo -e "${CYAN} wantedBy = [ \"multi-user.target\" ];${NC}" + echo -e "${CYAN} serviceConfig = {${NC}" + echo -e "${CYAN} Type = \"simple\";${NC}" + echo -e "${CYAN} ExecStart = \"${komari_agent_path} ${komari_args}\";${NC}" + echo -e "${CYAN} WorkingDirectory = \"${target_dir}\";${NC}" + echo -e "${CYAN} Restart = \"always\";${NC}" + echo -e "${CYAN} User = \"root\";${NC}" + echo -e "${CYAN} };${NC}" + echo -e "${CYAN}};${NC}" + echo "" + log_info "Then run: sudo nixos-rebuild switch" + log_warning "Service not started automatically on NixOS. Please rebuild your configuration." +elif command -v systemctl >/dev/null 2>&1; then # Systemd service configuration log_info "Using systemd for service management" service_file="/etc/systemd/system/${service_name}.service" @@ -337,7 +358,13 @@ fi echo "" echo -e "${WHITE}===========================================${NC}" -log_success "Komari-agent installation completed!" +if [ -f /etc/NIXOS ]; then + log_success "Komari-agent binary installed!" + log_warning "NixOS requires declarative service configuration." + log_info "Please add the service configuration to your NixOS config and rebuild." +else + log_success "Komari-agent installation completed!" +fi log_config "Service: ${GREEN}$service_name${NC}" log_config "Arguments: ${GREEN}$komari_args${NC}" echo -e "${WHITE}===========================================${NC}" \ No newline at end of file