This repository has been archived on 2024-07-08. You can view files and clone it, but cannot push or open issues or pull requests.
nix-config-tn/nixos/modules/nixos/containers/whoogle/default.nix
Truxnell 49621dec0e
feat: postgres, calibre, radicale, z2m (#133)
* hax

* hax

* shell monitoring

* hax radicale!

* hacking

* haxor

* hax

* hack

* feat: refactor paths etc for impermance

* fix: restic

* hax

* more hax

* feat: migrate z2m

* fix: websockets i guess

* cleanup

* hacks

* hax

* feat: miniflux + postgres

* feat: add calibre

* feat: calibre-web

* Auto lint/format

---------

Co-authored-by: Truxnell <9149206+truxnell@users.noreply.github.com>
Co-authored-by: truxnell <truxnell@users.noreply.github.com>
2024-05-05 16:05:59 +10:00

86 lines
2.4 KiB
Nix

{ lib
, config
, pkgs
, ...
}:
with lib;
let
app = "whoogle";
image = "ghcr.io/benbusby/whoogle-search:0.8.4@sha256:93977c3aec8a039df94745a6e960d1b590a897e451b874c90ce484fbdbc3630f";
user = "927"; #string
group = "927"; #string
port = 5000; #int
cfg = config.mySystem.services.${app};
appFolder = "/var/lib/${app}";
# persistentFolder = "${config.mySystem.persistentFolder}/var/lib/${appFolder}";
in
{
options.mySystem.services.${app} =
{
enable = mkEnableOption "${app}";
addToHomepage = mkEnableOption "Add ${app} to homepage" // { default = true; };
};
config = mkIf cfg.enable {
virtualisation.oci-containers.containers.${app} = {
image = "${image}";
user = "${user}:${group}";
ports = [ (builtins.toString port) ]; # expose port
environment = {
TZ = "${config.time.timeZone}";
WHOOGLE_ALT_TW = "nitter.${config.networking.domain}";
WHOOGLE_ALT_YT = "invidious.${config.networking.domain}";
WHOOGLE_ALT_IG = "imginn.com";
WHOOGLE_ALT_RD = "redlib.${config.networking.domain}";
WHOOGLE_ALT_MD = "scribe.${config.networking.domain}";
WHOOGLE_ALT_TL = "";
WHOOGLE_ALT_IMG = "bibliogram.art";
WHOOGLE_ALT_IMDB = "";
WHOOGLE_ALT_WIKI = "";
WHOOGLE_ALT_QUORA = "";
WHOOGLE_CONFIG_ALTS = "1";
WHOOGLE_CONFIG_THEME = "system";
WHOOGLE_CONFIG_URL = "https://search.${config.networking.domain}";
WHOOGLE_CONFIG_GET_ONLY = "1";
WHOOGLE_CONFIG_COUNTRY = "AU";
WHOOGLE_CONFIG_VIEW_IMAGE = "1";
WHOOGLE_CONFIG_DISABLE = "1";
};
};
services.nginx.virtualHosts."${app}.${config.networking.domain}" = {
useACMEHost = config.networking.domain;
forceSSL = true;
locations."^~ /" = {
proxyPass = "http://${app}:${builtins.toString port}";
extraConfig = "resolver 10.88.0.1;";
};
};
mySystem.services.homepage.home = mkIf cfg.addToHomepage [
{
Whoogle = {
icon = "whooglesearch.png";
href = "https://${app}.${config.mySystem.domain}";
description = "Google frontend";
container = "${app}";
};
}
];
mySystem.services.gatus.monitors = [{
name = app;
group = "services";
url = "https://${app}.${config.mySystem.domain}";
interval = "1m";
conditions = [ "[CONNECTED] == true" "[STATUS] == 200" "[RESPONSE_TIME] < 50" ];
}];
};
}