1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Hematite SearXNG Scaffolder
# Automates the creation of a local SearXNG environment for Windows + Docker.
$ErrorActionPreference = "Stop"
# 1. Target Directory (Desktop by default)
$desktop = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::Desktop)
$targetRoot = Join-Path $desktop "searxng-local"
$searxConfigDir = Join-Path $targetRoot "searxng"
Write-Host "Scaffolding SearXNG at: $targetRoot" -ForegroundColor Cyan
if (-not (Test-Path $targetRoot)) {
New-Item -ItemType Directory -Path $targetRoot | Out-Null
}
if (-not (Test-Path $searxConfigDir)) {
New-Item -ItemType Directory -Path $searxConfigDir | Out-Null
}
# 2. Generate Random Secret Key (64-char hex)
$bytes = [byte[]]::new(32)
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rng.GetBytes($bytes)
$secretKey = [System.BitConverter]::ToString($bytes).Replace("-", "").ToLower()
# 3. Create docker-compose.yaml
$composeContent = @"
services:
searxng:
container_name: searxng
image: docker.io/searxng/searxng:latest
restart: always
networks:
- searxng
ports:
- "8080:8080"
volumes:
- ./searxng:/etc/searxng:rw
- ./searxng/wikidata.py:/usr/local/searxng/searx/engines/wikidata.py:ro
environment:
- SEARXNG_BASE_URL=http://localhost:8080/
cap_drop:
- ALL
cap_add:
- CHOWN
- SETGID
- SETUID
logging:
driver: "json-file"
options:
max-size: "1m"
max-file: "1"
networks:
searxng:
ipam:
driver: default
"@
Set-Content -Path (Join-Path $targetRoot "docker-compose.yaml") -Value $composeContent -Encoding UTF8
# 4. Create settings.yml
$settingsContent = @"
use_default_settings: true
server:
secret_key: "$secretKey"
limiter: false
image_proxy: true
search:
safe_search: 0
autocomplete: ""
formats:
- html
- json
engines:
# Tier 1: Primary general-purpose
- name: google
engine: google
shortcut: g
use_official_api: false
- name: duckduckgo
engine: duckduckgo
shortcut: ddg
- name: bing
engine: bing
shortcut: b
# Tier 2: Privacy-first alternatives
- name: brave
engine: brave
shortcut: br
- name: qwant
engine: qwant
shortcut: qw
- name: startpage
engine: startpage
shortcut: sp
- name: mojeek
engine: mojeek
shortcut: mj
# Tier 3: Developer-focused
- name: wikipedia
engine: wikipedia
shortcut: wp
- name: github
engine: github
shortcut: gh
- name: stackoverflow
engine: stackexchange
shortcut: so
- name: npm
engine: npm
shortcut: npm
- name: crates.io
engine: crates
shortcut: crio
# Disabled due to upstream bug (KeyError: 'name')
# We use a volume-mount stub to definitively stop the crash.
- name: wikidata
engine: wikidata
disabled: true
ui:
static_use_hash: true
query_in_title: true
"@
Set-Content -Path (Join-Path $searxConfigDir "settings.yml") -Value $settingsContent -Encoding UTF8
# 5. Create start_searx.bat
$batContent = @"
@echo off
echo Starting SearXNG with 12-engine configuration...
docker compose up -d
echo.
echo SearXNG is now running on port 8080!
timeout /t 5
"@
Set-Content -Path (Join-Path $targetRoot "start_searx.bat") -Value $batContent -Encoding Ascii
# 6. Create Wikidata Stub (Definitive fix for upstream crash)
$stubContent = @"
# Stub to disable the crashing Wikidata engine
def init(engine_settings=None):
return True
def search(query, params):
return []
"@
Set-Content -Path (Join-Path $searxConfigDir "wikidata.py") -Value $stubContent -Encoding UTF8
Write-Host "`nSUCCESS: SearXNG environment scaffolded!" -ForegroundColor Green
Write-Host "Location: $targetRoot"
Write-Host "`nNext Steps:" -ForegroundColor White
Write-Host "1. Open a terminal in that folder: cd \"$targetRoot\""
Write-Host "2. Start the service: .\start_searx.bat"
Write-Host "3. Hematite will now auto-detect SearXNG on port 8080!"
Write-Host "`nNote: You can move this folder anywhere on your machine." -ForegroundColor Gray