Skip to content

Commit ecf209d

Browse files
aster-voidclaude
andcommitted
feat: add llama-cpp service, lsp-ai/llm-ls, and hypridle
- llama-cpp: add NixOS service with Vulkan support - auto-download Qwen2.5-Coder-7B-Instruct via fetchurl - configurable via my.profiles.development.llama-cpp.enable - helix: configure lsp-ai and llm-ls for local llama-cpp backend - hypridle: lock screen at 5min, screen off at 15min 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 19a082b commit ecf209d

File tree

7 files changed

+115
-6
lines changed

7 files changed

+115
-6
lines changed

home-manager/global/dev.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999

100100
# General LSPs
101101
lsp-ai
102+
llm-ls
102103
helix-gpt
103104
])
104105
# mcp servers

home-manager/global/services/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
imports = [
3+
./hypridle.nix
34
./syncthing.nix
45
];
56

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
services.hypridle = {
3+
enable = true;
4+
settings = {
5+
general = {
6+
lock_cmd = "pidof hyprlock || hyprlock";
7+
before_sleep_cmd = "loginctl lock-session";
8+
after_sleep_cmd = "hyprctl dispatch dpms on";
9+
};
10+
11+
listener = [
12+
# 5分 (300秒) でロック
13+
{
14+
timeout = 300;
15+
on-timeout = "loginctl lock-session";
16+
}
17+
# 15分 (900秒) で画面オフ
18+
{
19+
timeout = 900;
20+
on-timeout = "hyprctl dispatch dpms off";
21+
on-resume = "hyprctl dispatch dpms on";
22+
}
23+
];
24+
};
25+
};
26+
}

nixos/profiles/default.nix

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@
1515
type = lib.types.bool;
1616
default = false;
1717
};
18-
development .enable = lib.mkOption {
19-
type = lib.types.bool;
20-
default = true;
18+
development = {
19+
enable = lib.mkOption {
20+
type = lib.types.bool;
21+
default = true;
22+
};
23+
llama-cpp.enable = lib.mkOption {
24+
type = lib.types.bool;
25+
default = true;
26+
description = "Enable llama-cpp server with Vulkan support";
27+
};
2128
};
2229
};
2330
};

nixos/profiles/development/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
imports = [
33
./virtualization.nix
44
./packages.nix
5+
./llama-cpp.nix
56
];
67
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
lib,
3+
pkgs,
4+
config,
5+
...
6+
}: let
7+
cfg = config.my.profiles.development;
8+
llamaVulkan = pkgs.llama-cpp.override {vulkanSupport = true;};
9+
10+
# Qwen2.5-Coder-7B-Instruct Q4_K_M (4.68 GB)
11+
# https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct-GGUF
12+
model = pkgs.fetchurl {
13+
url = "https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct-GGUF/resolve/main/qwen2.5-coder-7b-instruct-q4_k_m.gguf";
14+
hash = "sha256-UJKH94y01M9rOENzRzO5FLLBWOQ+Iqf0v16WOACJTTw=";
15+
};
16+
in {
17+
config = lib.mkIf (cfg.enable && cfg.llama-cpp.enable) {
18+
services.llama-cpp = {
19+
enable = true;
20+
package = llamaVulkan;
21+
host = "127.0.0.1";
22+
port = 11434;
23+
model = "${model}";
24+
openFirewall = false;
25+
extraFlags = [
26+
"--ctx-size"
27+
"4096"
28+
"--threads"
29+
"12"
30+
"--batch-size"
31+
"256"
32+
"--ubatch-size"
33+
"32"
34+
"--n-gpu-layers"
35+
"22"
36+
"--flash-attn"
37+
"--cont-batching"
38+
"--temp"
39+
"0.15"
40+
"--top-p"
41+
"0.9"
42+
"--top-k"
43+
"40"
44+
"--repeat-penalty"
45+
"1.05"
46+
];
47+
};
48+
49+
hardware.graphics.enable = true;
50+
};
51+
}

stow/.config/helix/languages.toml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,34 @@ deno = { command = "deno", args = ["lsp"] }
1010
lsp-ai.command = "lsp-ai"
1111
helix-gpt.command = "helix-gpt"
1212

13+
# lsp-ai: ローカル llama-cpp バックエンド
1314
[language-server.lsp-ai.config.models.model1]
1415
type = "open_ai"
15-
chat_endpoint = "https://api.groq.com/openai/v1/chat/completions"
16-
model = "llama3-70b-8192"
16+
chat_endpoint = "http://127.0.0.1:11434/v1/chat/completions"
17+
model = "qwen2.5-coder-7b-instruct-q4_k_m"
1718
max_requests_per_second = 1
18-
auth_token_env_var_name = "GROQ_API_KEY"
19+
20+
# llm-ls: ローカル llama-cpp バックエンド (コード補完用)
21+
[language-server.llm-ls]
22+
command = "llm-ls"
23+
24+
[language-server.llm-ls.config]
25+
backend = "llama_cpp"
26+
url = "http://127.0.0.1:11434"
27+
model = "qwen2.5-coder-7b-instruct-q4_k_m"
28+
context_window = 4096
29+
tls_skip_verify_insecure = false
30+
31+
[language-server.llm-ls.config.fim]
32+
enabled = true
33+
prefix = "<|fim_prefix|>"
34+
middle = "<|fim_middle|>"
35+
suffix = "<|fim_suffix|>"
36+
37+
[language-server.llm-ls.config.request_body]
38+
max_tokens = 128
39+
temperature = 0.15
40+
top_p = 0.9
1941

2042
[[language]]
2143
name = "nix"

0 commit comments

Comments
 (0)