-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed fermi configuration for deployment
- Loading branch information
Showing
6 changed files
with
173 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,15 @@ in { | |
type = lib.types.str; | ||
}; | ||
|
||
ip = mkOption { | ||
default = ""; | ||
type = lib.types.str; | ||
}; | ||
ipv6 = mkOption { | ||
default = ""; | ||
type = lib.types.str; | ||
}; | ||
|
||
root = mkOption { | ||
default = "/srv"; | ||
type = lib.types.str; | ||
|
@@ -34,26 +43,33 @@ in { | |
type = lib.types.str; | ||
}; | ||
|
||
acme-location-block = mkOption { | ||
default = { | ||
"^~ /.well-known/acme-challenge".extraConfig = '' | ||
location ^~ /.well-known/acme-challenge/ { | ||
default_type "text/plain"; | ||
root ${cfg.root}/acme; | ||
} | ||
''; | ||
}; | ||
readOnly = true; | ||
keys = mkOption { | ||
default = [ | ||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMmFgG1EuQDoJb8pQcxnhjqbncrpJGZ3iNon/gu0bXiE [email protected]" | ||
]; | ||
}; | ||
}; | ||
|
||
config = { | ||
sops.secrets = { | ||
porkbun_api_key = { | ||
inherit (cfg) group; | ||
owner = cfg.user; | ||
}; | ||
porkbun_secret_api_key = { | ||
inherit (cfg) group; | ||
owner = cfg.user; | ||
}; | ||
}; | ||
|
||
users = { | ||
users.${cfg.user} = { | ||
inherit (cfg) group; | ||
password = ""; | ||
shell = "/run/current-system/sw/bin/nologin"; | ||
shell = pkgs.bash; | ||
isSystemUser = true; | ||
home = cfg.root; | ||
openssh.authorizedKeys.keys = cfg.keys; | ||
}; | ||
|
||
groups.${cfg.group} = {}; | ||
|
@@ -64,33 +80,46 @@ in { | |
allowedUDPPorts = [80 443]; | ||
}; | ||
|
||
services.nginx = { | ||
inherit (cfg) user group; | ||
enable = true; | ||
enableReload = true; | ||
services = { | ||
nginx = { | ||
inherit (cfg) user group; | ||
enable = true; | ||
enableReload = true; | ||
|
||
additionalModules = with pkgs.nginxModules; [fancyindex]; | ||
additionalModules = with pkgs.nginxModules; [fancyindex]; | ||
|
||
appendHttpConfig = '' | ||
limit_req_zone $binary_remote_addr zone=put_request_by_addr:20m rate=100r/s; | ||
''; | ||
appendHttpConfig = '' | ||
limit_req_zone $binary_remote_addr zone=put_request_by_addr:20m rate=100r/s; | ||
''; | ||
}; | ||
|
||
openssh.settings.AllowUsers = [cfg.user]; | ||
}; | ||
|
||
systemd.tmpfiles.rules = [ | ||
"d ${cfg.root} 0775 ${cfg.user} ${cfg.group} -" | ||
"d ${cfg.root}/acme 0775 ${cfg.user} ${cfg.group} -" | ||
]; | ||
|
||
security.acme = { | ||
acceptTerms = true; | ||
|
||
defaults = { | ||
email = "[email protected]"; | ||
webroot = cfg.root + "/acme"; | ||
dnsProvider = "porkbun"; | ||
group = cfg.group; | ||
credentialFiles = { | ||
PORKBUN_SECRET_API_KEY_FILE = config.sops.secrets.porkbun_secret_api_key.path; | ||
PORKBUN_API_KEY_FILE = config.sops.secrets.porkbun_api_key.path; | ||
}; | ||
}; | ||
|
||
certs.${cfg.hostname} = { | ||
inherit (cfg) group; | ||
extraDomainNames = ["www.${cfg.hostname}"]; | ||
extraDomainNames = [ | ||
"www.${cfg.hostname}" | ||
"auth.${cfg.hostname}" | ||
"www.auth.${cfg.hostname}" | ||
]; | ||
}; | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
inherit (lib.options) mkOption mkEnableOption; | ||
wwwCfg = config.my.www; | ||
cfg = wwwCfg.searx; | ||
socket = "/run/uwsgi/app/searx/socket"; | ||
socket = "/run/uwsgi/searx.socket"; | ||
in { | ||
options.my.www.searx = { | ||
enable = mkEnableOption "searx"; | ||
|
@@ -35,9 +35,7 @@ in { | |
systemd.tmpfiles.rules = let | ||
inherit (config.services.searx.uwsgiConfig) immediate-uid immediate-gid; | ||
in [ | ||
"d /run/uwsgi 0775 ${immediate-uid} ${immediate-gid} -" | ||
"d /run/uwsgi/app 0775 ${immediate-uid} ${immediate-gid} -" | ||
"d /run/uwsgi/app/searx 0775 ${immediate-uid} ${immediate-gid} -" | ||
"d ${builtins.baseNameOf socket} 0775 ${immediate-uid} ${immediate-gid} -" | ||
]; | ||
|
||
environment.etc."nginx/uwsgi_params".text = '' | ||
|
@@ -63,22 +61,19 @@ in { | |
|
||
services = { | ||
nginx.virtualHosts."${cfg.subdomain}.${wwwCfg.hostname}" = { | ||
root = "${config.services.searx.package}/share"; | ||
serverName = "${cfg.subdomain}.${wwwCfg.hostname} www.${cfg.subdomain}.${wwwCfg.hostname}"; | ||
kTLS = true; | ||
forceSSL = true; | ||
useACMEHost = wwwCfg.hostname; | ||
|
||
locations = | ||
{ | ||
"/".extraConfig = '' | ||
include uwsgi_params; | ||
uwsgi_pass unix:${socket}; | ||
''; | ||
locations = { | ||
"/".extraConfig = '' | ||
include uwsgi_params; | ||
uwsgi_pass unix:${socket}; | ||
''; | ||
|
||
"/static/".alias = "${config.services.searx.package}/share/static"; | ||
} | ||
// wwwCfg.acme-location-block; | ||
"/static/".alias = "${config.services.searx.package}/share/static/"; | ||
}; | ||
}; | ||
|
||
redis.servers.searx.user = mkForce config.services.searx.uwsgiConfig.immediate-uid; | ||
|
@@ -96,12 +91,11 @@ in { | |
environmentFile = config.sops.templates."searx.env".path; | ||
|
||
settings = { | ||
use_default_settings = mkForce false; | ||
instance_name = "searx"; | ||
contact_url = "mailto:[email protected]"; | ||
server = { | ||
secret_key = "@SEARX_SECRET_KEY@"; | ||
base_url = "${cfg.subdomain}.${wwwCfg.hostname}"; | ||
base_url = "/"; | ||
image_proxy = true; | ||
}; | ||
}; | ||
|
Oops, something went wrong.