Compare commits

..

1 commit
main ... dev

Author SHA1 Message Date
Dmitry Voronin 540aae3e58 WIP Chat: Add Mattermost container. 2024-10-21 14:32:24 +03:00
14 changed files with 87 additions and 219 deletions

View file

@ -7,6 +7,8 @@ help:
android:
nix-on-droid switch --flake $(flake)
cp ~/.termux/_font.ttf ~/.termux/font.ttf
cp ~/.termux/_colors.properties ~/.termux/colors.properties
cp ~/.Wallpaper /sdcard/Download/Wallpaper.jpg
cp ~/.Wallpaper /sdcard/Download/Wallpaper.png

View file

@ -1,8 +1,8 @@
{ pkgs, lib, ... }:
with lib;
let
url = "https://i.imgur.com/UpyYtT3.jpeg";
sha256 = "1dilvn5ls34d5855d1h6k12x9mbdhawd91dl9z5v91ndpbjhip5r";
url = "https://i.imgur.com/9l6Ywcm.jpeg";
sha256 = "1fncihr63niq6l2llgbhhid24a11vr3q091yya497xld3mldfdan";
forceContrastText = false;
in
{

View file

@ -2,12 +2,10 @@
container,
lib,
config,
pkgs,
...
}:
let
cfg = config.container.module.chat;
db = config.container.module.postgres;
in
{
options = {
@ -18,7 +16,7 @@ in
type = lib.types.str;
};
port = lib.mkOption {
default = 8065;
default = 80;
type = lib.types.int;
};
domain = lib.mkOption {
@ -38,43 +36,21 @@ in
containers.chat = container.mkContainer cfg {
bindMounts = {
"/var/lib/mattermost" = {
hostPath = "${cfg.storage}/data";
isReadOnly = false;
};
# "/var/lib/changedetection-io" = {
# hostPath = "${cfg.storage}/data";
# isReadOnly = false;
# };
};
config =
{ ... }:
container.mkContainerConfig cfg {
services.mattermost = {
enable = true;
listenAddress = ":${toString cfg.port}";
localDatabaseCreate = false;
mutableConfig = false;
package = pkgs.mattermost;
siteName = "Chat";
siteUrl = "https://${cfg.domain}";
statePath = "/var/lib/mattermost";
plugins =
let
calls =
let
version = "1.2.0";
in
pkgs.fetchurl {
url = "https://github.com/mattermost/mattermost-plugin-calls/releases/download/v${version}/mattermost-plugin-calls-v${version}.tar.gz";
hash = "sha256-yQGBpBPgXxC+Pm6dHlbwlNEdvn6wg9neSpNNTC4YYAA=";
};
in
[ calls ];
extraConfig = {
SqlSettings = {
DataSource = "postgres://mattermost:any@${db.address}:${toString db.port}/mattermost?sslmode=disable&connect_timeout=10";
DriverName = "postgres";
};
};
};
# services.changedetection-io = {
# enable = true;
# baseURL = cfg.domain;
# behindProxy = true;
# listenAddress = cfg.address;
# };
};
};
};

View file

@ -3,109 +3,100 @@
pkgs,
lib,
config,
util,
...
}:
}@args:
with lib;
let
cfg = config.container.module.dns;
in
{
options = {
container.module.dns = {
enable = lib.mkEnableOption "the DNS server.";
address = lib.mkOption {
enable = mkEnableOption "Dns server.";
address = mkOption {
default = "10.1.0.6";
type = lib.types.str;
type = types.str;
};
port = lib.mkOption {
port = mkOption {
default = 53;
type = lib.types.int;
type = types.int;
};
};
};
config = lib.mkIf cfg.enable {
config = mkIf cfg.enable {
containers.dns = container.mkContainer cfg {
config =
{ ... }:
container.mkContainerConfig cfg {
environment.systemPackages = [ pkgs.cloudflared ];
# systemd.services.cloudflared = {
# description = "Cloudflare DoH server.";
# enable = true;
# wantedBy = [ "multi-user.target" ];
# serviceConfig = {
# Type = "simple";
# ExecStart = "${lib.getExe pkgs.cloudflared} proxy-dns --port 5054";
# };
# };
systemd.services.cloudflared = {
description = "Cloudflare DoH server.";
enable = true;
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${getExe pkgs.cloudflared} proxy-dns --port 5054";
};
};
services.blocky = {
enable = true;
# SRC: https://0xerr0r.github.io/blocky/main/configuration/
settings = {
bootstrapDns = "tcp+udp:1.1.1.1";
connectIPVersion = "v4";
upstreams.groups = {
default = [ "https://dns.quad9.net/dns-query" ];
};
caching = {
maxItemsCount = 100000;
maxTime = "30m";
minTime = "5m";
prefetchExpires = "2h";
prefetchMaxItemsCount = 100000;
prefetchThreshold = 5;
prefetching = true;
upstream = {
default = [
"0.0.0.0:5054"
"0.0.0.0:5054"
];
};
blocking = {
blockTTL = "1m";
blockType = "zeroIP";
loading = {
refreshPeriod = "1h";
strategy = "blocking";
downloads = {
timeout = "5m";
attempts = 3;
cooldown = "10s";
};
};
# SRC: https://oisd.nl
# SRC: https://v.firebog.net
denylists = {
blackLists = {
suspicious = [
"https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
"https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts.txt"
"https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" # https://github.com/StevenBlack/hosts
"https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts"
"https://v.firebog.net/hosts/static/w3kbl.txt"
];
ads = [
"https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
"https://raw.githubusercontent.com/bigdargon/hostsVN/master/hosts"
"https://easylist-downloads.adblockplus.org/bitblock.txt"
"https://adaway.org/hosts.txt"
"https://v.firebog.net/hosts/AdguardDNS.txt"
"https://v.firebog.net/hosts/Admiral.txt"
"https://raw.githubusercontent.com/anudeepND/blacklist/master/adservers.txt"
"https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt"
"https://v.firebog.net/hosts/Easylist.txt"
"https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
"https://raw.githubusercontent.com/FadeMind/hosts.extras/master/UncheckyAds/hosts"
"https://raw.githubusercontent.com/bigdargon/hostsVN/master/hosts"
"https://github.com/easylist/ruadlist/blob/master/advblock/adservers.txt"
];
tracking = [
"https://hostfiles.frogeye.fr/firstparty-trackers-hosts.txt"
"https://v.firebog.net/hosts/Easyprivacy.txt"
"https://v.firebog.net/hosts/Prigent-Ads.txt"
"https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.2o7Net/hosts"
"https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
"https://hostfiles.frogeye.fr/firstparty-trackers-hosts.txt"
];
malicious = [
"https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-malware.txt"
"https://raw.githubusercontent.com/DandelionSprout/adfilt/master/Alternate%20versions%20Anti-Malware%20List/AntiMalwareHosts.txt"
"https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt"
"https://phishing.army/download/phishing_army_blocklist_extended.txt"
"https://raw.githubusercontent.com/AssoEchap/stalkerware-indicators/master/generated/hosts"
"https://raw.githubusercontent.com/Spam404/lists/master/main-blacklist.txt"
"https://urlhaus.abuse.ch/downloads/hostfile/"
"https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt"
"https://v.firebog.net/hosts/Prigent-Crypto.txt"
"https://v.firebog.net/hosts/Prigent-Malware.txt"
];
other = [
"https://big.oisd.nl/domainswild"
"https://zerodot1.gitlab.io/CoinBlockerLists/hosts_browser"
"https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Risk/hosts"
"https://bitbucket.org/ethanr/dns-blacklists/raw/8575c9f96e5b4a1308f2f12394abd86d0927a4a0/bad_lists/Mandiant_APT1_Report_Appendix_D.txt"
"https://phishing.army/download/phishing_army_blocklist_extended.txt"
"https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-malware.txt"
"https://v.firebog.net/hosts/RPiList-Malware.txt"
"https://v.firebog.net/hosts/RPiList-Phishing.txt"
"https://raw.githubusercontent.com/Spam404/lists/master/main-blacklist.txt"
"https://raw.githubusercontent.com/AssoEchap/stalkerware-indicators/master/generated/hosts"
"https://urlhaus.abuse.ch/downloads/hostfile/"
];
other = [ "https://zerodot1.gitlab.io/CoinBlockerLists/hosts_browser" ];
};
# allowlists = {
# whiteLists = {
# other = [
# "/.*.vk.com/"
# ];
@ -123,18 +114,20 @@ in
customDNS = {
mapping =
let
block = host: { ${host} = "0.0.0.0"; };
block = "0.0.0.0";
in
{
# All subdomains to current host.
# ${config.container.domain} = config.container.host;
"voronind.com" = "10.0.0.1";
}
// block "gosuslugi.ru"
// block "rutube.ru"
// block "vk.com";
# Blocklist.
"gosuslugi.ru" = block;
"rutube.ru" = block;
"vk.com" = block;
};
};
ports.dns = cfg.port;
port = cfg.port;
# httpPort = "80";
};
};

View file

@ -48,7 +48,6 @@ in
configurations = with config.container.module; {
forgejo = git;
invidious = yt;
mattermost = chat;
nextcloud = cloud;
onlyoffice = office;
paperless = paper;

View file

@ -1,28 +0,0 @@
{ config, container, ... }:
let
cfg = config.container.module.chat;
name = "chat";
in
{
${cfg.domain} = container.mkServer {
extraConfig = ''
listen 443 ssl;
set ''$${name} ${cfg.address}:${toString cfg.port};
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;
}
ssl_certificate /etc/letsencrypt/live/${config.container.domain}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/${config.container.domain}/privkey.pem;
include /etc/letsencrypt/conf/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem;
'';
};
}

View file

@ -27,19 +27,17 @@ in
};
config = mkIf cfg.enable {
environment.packages = package.core;
time.timeZone = const.timeZone;
terminal = {
inherit (android) font colors;
};
environment.packages = package.core;
home-manager.config = stylix // {
imports = [ inputs.stylix.homeManagerModules.stylix ];
home = {
file = import ./config args;
sessionVariables = import ./variable args;
stateVersion = const.droidStateVersion;
sessionVariables = import ./variable args;
file = (import ./config args) // {
".termux/_font.ttf".source = android.font;
".termux/_colors.properties".text = android.colors;
};
};
programs = import ./program args;
};

View file

@ -6,9 +6,8 @@
}/share/fonts/truetype/NerdFonts/TerminessNerdFontMono-Regular.ttf $out
'';
colors = with config.style.color; {
background = "#${bg.dark}";
cursor = "#${fg.light}";
foreground = "#${fg.light}";
};
colors = ''
background=#${config.style.color.bg.dark}
foreground=#${config.style.color.fg.light}
'';
}

View file

@ -1,8 +1,7 @@
{ pkgs, ... }:
let
apps = [
"gimp"
"gimp-*"
"*|gnu-image-manipulation-program"
"steam-proton"
];

View file

@ -45,11 +45,5 @@
move scratchpad
scratchpad show
}
# JamesDsp.
for_window [title="JamesDSP for Linux"] {
move scratchpad
scratchpad show
}
'';
}

View file

@ -73,24 +73,5 @@
_iterate_targets process ''${targets[@]}
}
# Find user keys using keyservers.
# Usage: gpg_find <EMAIL>
function gpg_find() {
local email="''${1}"
if [[ "''${email}" = "" ]]; then
help gpg_find
return 2
fi
gpg --locate-keys "''${email}" \
|| gpg --locate-keys --auto-key-locate hkps://keys.openpgp.org "''${email}"
}
# Update keys.
function gpg_refresh() {
gpg --refresh-keys
}
'';
}

View file

@ -8,11 +8,6 @@ in
gpg = {
enable = true;
inherit (secret.crypto) publicKeys;
mutableKeys = true;
mutableTrust = true;
settings = {
keyserver = "hkps://keys.openpgp.org";
};
};
firefox = import ./firefox args;

View file

@ -150,59 +150,20 @@ in
installation_mode = "blocked";
};
} // extensions;
# NOTE: `firefox-esr` edition is required to change search engines.
# NOTE: `firefox-esr` edition is required to change default search engine.
SearchEngines = {
Default = "Searx";
PreventInstalls = true;
Add = [
{
Alias = "s";
Description = "SearX";
Description = "Searx Search";
IconURL = "https://search.voronind.com/favicon.ico";
Method = "POST";
Name = "Searx";
PostData = "q={searchTerms}";
# SuggestURLTemplate = "https://search.voronind.com/autocomplete?q={searchTerms}";
URLTemplate = "https://search.voronind.com/search?q={searchTerms}";
URLTemplate = "https://search.voronind.com/search?q=%{searchTerms}";
}
{
Alias = "ru";
Description = "RuTracker";
IconURL = "https://rutracker.org/favicon.ico";
Method = "GET";
Name = "RuTracker";
URLTemplate = "https://rutracker.org/forum/tracker.php?nm={searchTerms}";
}
{
Alias = "re";
Description = "Reddit";
IconURL = "https://www.reddit.com/favicon.ico";
Method = "GET";
Name = "Reddit";
URLTemplate = "https://www.reddit.com/search/?q={searchTerms}";
}
{
Alias = "no";
Description = "NixOS Option";
IconURL = "https://search.nixos.org/favicon.ico";
Method = "GET";
Name = "NixOS Option";
URLTemplate = "https://search.nixos.org/options?query={searchTerms}";
}
{
Alias = "np";
Description = "NixOS Package";
IconURL = "https://search.nixos.org/favicon.ico";
Method = "GET";
Name = "NixOS Package";
URLTemplate = "https://search.nixos.org/packages?query={searchTerms}";
}
];
Remove = [
"Bing"
"DuckDuckGo"
"Google"
"Wikipedia (en)"
];
};
};

View file

@ -7,7 +7,6 @@
module = {
# ISSUE: hdd.enable = true;
change.enable = true;
chat.enable = true;
cloud.enable = true;
ddns.enable = true;
dns.enable = true;