chore: update service modules and remove deprecated systemd services
This commit is contained in:
@@ -1,31 +1,45 @@
|
|||||||
systemd.services.init-ollama-model = {
|
{ pkgs, ... }: {
|
||||||
description = "Initialize nemotron 3 with extra context in Ollama Docker";
|
systemd.services.init-ollama-model = {
|
||||||
after = [ "docker-ollama.service" ]; # Ensure it runs after your ollama container
|
description = "Initialize LLM models with extra context in Ollama Docker";
|
||||||
wantedBy = [ "multi-user.target" ];
|
after = [ "docker-ollama.service" ];
|
||||||
script = ''
|
wantedBy = [ "multi-user.target" ];
|
||||||
# Wait for Ollama
|
script = ''
|
||||||
while ! ${pkgs.curl}/bin/curl -s http://localhost:11434/api/tags > /dev/null; do
|
# Wait for Ollama
|
||||||
sleep 2
|
while ! ${pkgs.curl}/bin/curl -s http://localhost:11434/api/tags > /dev/null; do
|
||||||
done
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
# Check if the model already exists in the persistent volume
|
create_model_if_missing() {
|
||||||
if ! ${pkgs.docker}/bin/docker exec ollama ollama list | grep -q "nemotron-3-nano:30b-128k"; then
|
local model_name=$1
|
||||||
echo "nemotron-3-nano:30b-128k not found, creating..."
|
local base_model=$2
|
||||||
|
if ! ${pkgs.docker}/bin/docker exec ollama ollama list | grep -q "$model_name"; then
|
||||||
|
echo "$model_name not found, creating from $base_model..."
|
||||||
|
${pkgs.docker}/bin/docker exec ollama sh -c "cat <<EOF > /root/.ollama/$model_name.modelfile
|
||||||
|
FROM $base_model
|
||||||
|
PARAMETER num_ctx 131072
|
||||||
|
PARAMETER num_predict 4096
|
||||||
|
PARAMETER num_keep 1024
|
||||||
|
PARAMETER repeat_penalty 1.1
|
||||||
|
PARAMETER top_k 40
|
||||||
|
PARAMETER stop \"[INST]\"
|
||||||
|
PARAMETER stop \"[/INST]\"
|
||||||
|
PARAMETER stop \"</s>\"
|
||||||
|
EOF"
|
||||||
|
${pkgs.docker}/bin/docker exec ollama ollama create "$model_name" -f "/root/.ollama/$model_name.modelfile"
|
||||||
|
else
|
||||||
|
echo "$model_name already exists, skipping."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
${pkgs.docker}/bin/docker exec ollama sh -c 'cat <<EOF > /root/.ollama/nemotron-3-nano:30b-128k.modelfile
|
# Create Nemotron
|
||||||
FROM nemotron-3-nano:30b
|
create_model_if_missing "nemotron-3-nano:30b-128k" "nemotron-3-nano:30b"
|
||||||
PARAMETER num_ctx 131072
|
|
||||||
PARAMETER num_predict 4096
|
|
||||||
PARAMETER repeat_penalty 1.1
|
|
||||||
EOF'
|
|
||||||
|
|
||||||
${pkgs.docker}/bin/docker exec ollama ollama create nemotron-3-nano:30b-128k -f /root/.ollama/nemotron-3-nano:30b-128k.modelfile
|
# Create Devstral
|
||||||
else
|
create_model_if_missing "devstral-small-2:24b-128k" "devstral-small-2:24b"
|
||||||
echo "nemotron-3-nano:30b-128k already exists, skipping creation."
|
'';
|
||||||
fi
|
serviceConfig = {
|
||||||
'';
|
Type = "oneshot";
|
||||||
serviceConfig = {
|
RemainAfterExit = true;
|
||||||
Type = "oneshot";
|
};
|
||||||
RemainAfterExit = true;
|
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -18,45 +18,113 @@ in {
|
|||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
programs.nix-ld.enable = true;
|
programs.nix-ld.enable = true;
|
||||||
|
|
||||||
|
# We inject the Context7 MCP requirement directly into your nix-generated config
|
||||||
environment.etc."opencode/opencode.json".text = builtins.toJSON {
|
environment.etc."opencode/opencode.json".text = builtins.toJSON {
|
||||||
"$schema" = "https://opencode.ai/config.json";
|
"$schema" = "https://opencode.ai/config.json";
|
||||||
|
"model" = "devstral-2-small-llama_cpp";
|
||||||
|
|
||||||
"model" = "ollama/nemotron-3-nano:30b";
|
# Added the MCP section required by GSD
|
||||||
|
"mcp" = {
|
||||||
|
"context7" = {
|
||||||
|
"type" = "remote";
|
||||||
|
"url" = "https://mcp.context7.com/mcp";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
"provider" = {
|
"provider" = {
|
||||||
|
"llamacpp" = {
|
||||||
|
"name" = "Llama.cpp (Local MI50)";
|
||||||
|
"npm" = "@ai-sdk/openai-compatible";
|
||||||
|
"options" = {
|
||||||
|
"baseURL" = "http://localhost:8300/v1";
|
||||||
|
"apiKey" = "not-needed";
|
||||||
|
};
|
||||||
|
"models" = {
|
||||||
|
"devstral-2-small-llama_cpp" = {
|
||||||
|
"name" = "Devstral 2 small 24B Q8 (llama.cpp)";
|
||||||
|
"tools" = true;
|
||||||
|
"reasoning" = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
"ollama" = {
|
"ollama" = {
|
||||||
"name" = "Ollama (Local)";
|
"name" = "Ollama (Local)";
|
||||||
"npm" = "@ai-sdk/openai-compatible";
|
"npm" = "@ai-sdk/openai-compatible";
|
||||||
"options" = {
|
"options" = {
|
||||||
"baseURL" = cfg.ollamaUrl;
|
"baseURL" = cfg.ollamaUrl;
|
||||||
|
"headers" = { "Content-Type" = "application/json"; };
|
||||||
};
|
};
|
||||||
"models" = {
|
"models" = {
|
||||||
# The exact model ID as seen in 'ollama list'
|
"devstral-small-2:24b-128k" = {
|
||||||
"nemotron-3-nano:30b" = {
|
"name" = "Mistral Devstral Small 2 (Ollama)";
|
||||||
"name" = "NVIDIA Nemotron 3 Nano (30B)";
|
"tools" = true;
|
||||||
|
"reasoning" = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# This service runs the GSD installer directly from the source
|
||||||
|
systemd.services.opencode-gsd-install = {
|
||||||
|
description = "Install Get Shit Done OpenCode Components";
|
||||||
|
after = [ "network-online.target" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
path = with pkgs; [
|
||||||
|
nodejs
|
||||||
|
git
|
||||||
|
coreutils
|
||||||
|
bash
|
||||||
|
];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "gortium";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
Environment = [
|
||||||
|
"HOME=/home/gortium"
|
||||||
|
"SHELL=${pkgs.bash}/bin/bash"
|
||||||
|
"PATH=${lib.makeBinPath [ pkgs.nodejs pkgs.git pkgs.bash pkgs.coreutils ]}"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
# Check if the GSD directory exists
|
||||||
|
if [ ! -d "/home/gortium/.config/opencode/gsd" ]; then
|
||||||
|
echo "GSD not found. Installing..."
|
||||||
|
${pkgs.nodejs}/bin/npx -y github:dbachelder/get-shit-done-opencode --global --force
|
||||||
|
else
|
||||||
|
echo "GSD already installed. Skipping auto-reinstall."
|
||||||
|
echo "To force update, run: sudo systemctl restart opencode-gsd-install.service"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
systemd.services.opencode = {
|
systemd.services.opencode = {
|
||||||
description = "OpenCode AI Coding Agent Server";
|
description = "OpenCode AI Coding Agent Server";
|
||||||
after = [ "network.target" "ai_stack.service" ];
|
after = [ "network.target" "ai_stack.service" "opencode-gsd-install.service" ];
|
||||||
requires = [ "ai_stack.service" ];
|
requires = [ "ai_stack.service" "opencode-gsd-install.service" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
|
path = with pkgs; [
|
||||||
|
bash
|
||||||
|
coreutils
|
||||||
|
nodejs
|
||||||
|
git
|
||||||
|
nix
|
||||||
|
ripgrep
|
||||||
|
fd
|
||||||
|
];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
User = "gortium";
|
User = "gortium";
|
||||||
|
WorkingDirectory = "/home/gortium/infra";
|
||||||
ExecStart = "${pkgs.nodejs}/bin/npx -y opencode-ai serve --hostname 0.0.0.0 --port ${toString cfg.port}";
|
ExecStart = "${pkgs.nodejs}/bin/npx -y opencode-ai serve --hostname 0.0.0.0 --port ${toString cfg.port}";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
# Loads your ANTHROPIC_API_KEY etc from your single Agenix file
|
|
||||||
# EnvironmentFile = config.age.secrets.opencode-secrets.path;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
OLLAMA_BASE_URL = "http://127.0.0.1:11434";
|
OLLAMA_BASE_URL = "http://127.0.0.1:11434";
|
||||||
|
# Important: GSD looks at ~/.config/opencode, so we ensure the server sees our /etc config
|
||||||
OPENCODE_CONFIG = "/etc/opencode/opencode.json";
|
OPENCODE_CONFIG = "/etc/opencode/opencode.json";
|
||||||
HOME = "/home/gortium";
|
HOME = "/home/gortium";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
{
|
{ config, lib, pkgs, ... }:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.services.podman;
|
cfg = config.services.podman;
|
||||||
in {
|
in {
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
{ pkgs, lib, config, self, keys, paths, ... }: {
|
|
||||||
imports =
|
|
||||||
[
|
|
||||||
./network.nix
|
|
||||||
./passwordmanager.nix
|
|
||||||
./versioncontrol.nix
|
|
||||||
./fancontrol.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
virtualisation.docker = {
|
|
||||||
enable = true;
|
|
||||||
daemon.settings = {
|
|
||||||
"dns" = [ "1.1.1.1" "8.8.8.8" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.services.systemd-fancon;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.services.systemd-fancon = {
|
|
||||||
enable = mkEnableOption "systemd-fancon service for fan control";
|
|
||||||
config = mkOption {
|
|
||||||
type = types.lines;
|
|
||||||
default = "";
|
|
||||||
description = "Configuration for systemd-fancon.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
systemd-fancon
|
|
||||||
lm_sensors
|
|
||||||
];
|
|
||||||
|
|
||||||
boot.kernelModules = [ "amdgpu" ];
|
|
||||||
|
|
||||||
systemd.services.systemd-fancon = {
|
|
||||||
description = "systemd-fancon service";
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
after = [ "network-online.target" ];
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStart = "${pkgs.systemd-fancon}/bin/systemd-fancon -c ${cfg.configFile}";
|
|
||||||
Restart = "on-failure";
|
|
||||||
};
|
|
||||||
configFile = pkgs.writeText "systemd-fancon.conf" cfg.config;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
{ config, pkgs, self, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
network_compose_dir = builtins.path {
|
|
||||||
name = "network_compose_dir";
|
|
||||||
path = self + "/assets/compose/network";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
|
||||||
|
|
||||||
systemd.services.network_stack = {
|
|
||||||
description = "Traefik + DDNS updater via Docker Compose";
|
|
||||||
after = [ "network-online.target" "docker.service" ];
|
|
||||||
wants = [ "network-online.target" "docker.service" ];
|
|
||||||
serviceConfig = {
|
|
||||||
WorkingDirectory = "${network_compose_dir}";
|
|
||||||
|
|
||||||
EnvironmentFile = config.age.secrets.containers_env.path;
|
|
||||||
|
|
||||||
# Stop left over container by the same name
|
|
||||||
ExecStartPre = "${pkgs.bash}/bin/bash -c '${pkgs.docker-compose}/bin/docker-compose down || true'";
|
|
||||||
|
|
||||||
# Start the services using Docker Compose
|
|
||||||
ExecStart = "${pkgs.docker-compose}/bin/docker-compose up -d";
|
|
||||||
|
|
||||||
# Stop and remove containers on shutdown
|
|
||||||
ExecStop = "${pkgs.docker-compose}/bin/docker-compose down";
|
|
||||||
|
|
||||||
RemainAfterExit = true;
|
|
||||||
TimeoutStartSec = 0;
|
|
||||||
};
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
{ config, pkgs, self, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
passwordmanager_compose_dir = builtins.path {
|
|
||||||
name = "passwordmanager_compose_dir";
|
|
||||||
path = self + "/assets/compose/passwordmanager";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
systemd.services.passwordmanager_stack = {
|
|
||||||
description = "Bitwarden via Docker Compose";
|
|
||||||
after = [ "network-online.target" "docker.service" ];
|
|
||||||
wants = [ "network-online.target" "docker.service" ];
|
|
||||||
serviceConfig = {
|
|
||||||
WorkingDirectory = "${passwordmanager_compose_dir}";
|
|
||||||
|
|
||||||
# Stop left over container by the same name
|
|
||||||
ExecStartPre = "${pkgs.bash}/bin/bash -c '${pkgs.docker-compose}/bin/docker-compose down || true'";
|
|
||||||
|
|
||||||
# Start the services using Docker Compose
|
|
||||||
ExecStart = "${pkgs.docker-compose}/bin/docker-compose up -d";
|
|
||||||
|
|
||||||
# Stop and remove containers on shutdown
|
|
||||||
ExecStop = "${pkgs.docker-compose}/bin/docker-compose down";
|
|
||||||
|
|
||||||
RemainAfterExit = true;
|
|
||||||
TimeoutStartSec = 0;
|
|
||||||
};
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
{ config, pkgs, self, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
versioncontrol_compose_dir = builtins.path {
|
|
||||||
name = "versioncontrol_compose_dir";
|
|
||||||
path = self + "/assets/compose/versioncontrol";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
networking.firewall.allowedTCPPorts = [ 2222 ];
|
|
||||||
|
|
||||||
systemd.services.versioncontrol_stack = {
|
|
||||||
description = "Gitea via Docker Compose";
|
|
||||||
after = [ "network-online.target" "docker.service" ];
|
|
||||||
wants = [ "network-online.target" "docker.service" ];
|
|
||||||
serviceConfig = {
|
|
||||||
WorkingDirectory = "${versioncontrol_compose_dir}";
|
|
||||||
|
|
||||||
# Stop left over container by the same name
|
|
||||||
ExecStartPre = "${pkgs.bash}/bin/bash -c '${pkgs.docker-compose}/bin/docker-compose down || true'";
|
|
||||||
|
|
||||||
# Start the services using Docker Compose
|
|
||||||
ExecStart = "${pkgs.docker-compose}/bin/docker-compose up -d";
|
|
||||||
|
|
||||||
# Stop and remove containers on shutdown
|
|
||||||
ExecStop = "${pkgs.docker-compose}/bin/docker-compose down";
|
|
||||||
|
|
||||||
RemainAfterExit = true;
|
|
||||||
TimeoutStartSec = 0;
|
|
||||||
};
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user