Compare commits

..

No commits in common. "9f40a68eb49922694ce01f17a297dd021b093ac6" and "e856c0dfb1b96d90a406e08d5ca2197ddfe9a954" have entirely different histories.

15 changed files with 240 additions and 242 deletions

View file

@ -15,12 +15,13 @@
}; };
outputs = { outputs = {
self,
nixpkgs, nixpkgs,
nixos-mailserver, nixos-mailserver,
agenix, agenix,
... ...
}: let }: let
inherit (nixpkgs) lib; lib = nixpkgs.lib;
in { in {
nixosConfigurations = { nixosConfigurations = {
distrust = lib.nixosSystem { distrust = lib.nixosSystem {

View file

@ -1,12 +1,13 @@
let let
user = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHxah5pnxmk+P7HtwRsryDoAHZsDs5RcGP9IPCNg1KFe cardno:16_179_196"; user = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHxah5pnxmk+P7HtwRsryDoAHZsDs5RcGP9IPCNg1KFe cardno:16_179_196";
users = [user]; users = [ user ];
system = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMKxw1fDsIUUh3vWCD90LDgDMAG/NSVRg7QamUbknz5A root@distrust"; system = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMKxw1fDsIUUh3vWCD90LDgDMAG/NSVRg7QamUbknz5A root@distrust";
systems = [system]; systems = [ system ];
all = users ++ systems; all = users ++ systems;
in { in
{
"bind_pw".publicKeys = all; "bind_pw".publicKeys = all;
"nextcloud-admin-pass".publicKeys = all; "nextcloud-admin-pass".publicKeys = all;
"vaultwarden.env".publicKeys = all; "vaultwarden.env".publicKeys = all;

View file

@ -8,45 +8,43 @@
onionUrl = "http://n5j5sq55iem2hzbgvkba5vwd5gx5qj2pkb7nxyginbtmnkah74rtulad.onion"; onionUrl = "http://n5j5sq55iem2hzbgvkba5vwd5gx5qj2pkb7nxyginbtmnkah74rtulad.onion";
inherit ((pkgs.formats.elixirConf {}).lib) mkAtom; inherit ((pkgs.formats.elixirConf {}).lib) mkAtom;
in { in {
services = { services.akkoma = {
akkoma = { enable = true;
enable = true; config = {
config = { ":pleroma" = {
":pleroma" = { ":instance" = {
":instance" = { name = "social.distrust.network";
name = "social.distrust.network"; description = "Akkoma instance for distrust.network users";
description = "Akkoma instance for distrust.network users"; email = "root@distrust.network";
email = "root@distrust.network"; registration_open = false;
registration_open = false;
};
":ldap" = {
enabled = true;
host = "localhost";
port = 3890;
ssl = false;
tls = false;
base = "ou=people,dc=distrust,dc=network";
uid = "uid";
};
"Pleroma.Upload".base_url = "https://social.distrust.network/media/";
"Pleroma.Web.Endpoint" = {
url.host = "social.distrust.network";
http = {
ip = "0.0.0.0";
port = fediPort;
};
};
"Pleroma.Web.Auth.Authenticator" = mkAtom "Pleroma.Web.Auth.LDAPAuthenticator";
}; };
":ldap" = {
enabled = true;
host = "localhost";
port = 3890;
ssl = false;
tls = false;
base = "ou=people,dc=distrust,dc=network";
uid = "uid";
};
"Pleroma.Upload".base_url = "https://social.distrust.network/media/";
"Pleroma.Web.Endpoint" = {
url.host = "social.distrust.network";
http = {
ip = "0.0.0.0";
port = fediPort;
};
};
"Pleroma.Web.Auth.Authenticator" = mkAtom "Pleroma.Web.Auth.LDAPAuthenticator";
}; };
}; };
caddy.virtualHosts."http://social.distrust.network ${onionUrl}".extraConfig = ''
reverse_proxy localhost:${toString fediPort}
'';
tor.relay.onionServices."akkoma".map = [
80
];
}; };
services.caddy.virtualHosts."http://social.distrust.network ${onionUrl}".extraConfig = ''
reverse_proxy localhost:${toString fediPort}
'';
services.tor.relay.onionServices."akkoma".map = [
80
];
} }

View file

@ -9,6 +9,6 @@
''; '';
}; };
networking.firewall.allowedTCPPorts = [1080]; networking.firewall.allowedTCPPorts = [ 1080 ];
networking.firewall.allowedUDPPorts = [1080]; networking.firewall.allowedUDPPorts = [ 1080 ];
} }

View file

@ -7,8 +7,7 @@
./akkoma.nix ./akkoma.nix
./prosody.nix ./prosody.nix
./lldap.nix ./lldap.nix
# Dante not working right now, possibly misconfigured. ./dante.nix
#./dante.nix
./vaultwarden.nix ./vaultwarden.nix
./mailserver.nix ./mailserver.nix
]; ];

View file

@ -2,24 +2,22 @@ let
forgejoPort = 8082; forgejoPort = 8082;
onionUrl = "http://cr27k6asjs7skvjxs6smhqfam3wlvmft2f3iins44k6p6rmmfyolobqd.onion"; onionUrl = "http://cr27k6asjs7skvjxs6smhqfam3wlvmft2f3iins44k6p6rmmfyolobqd.onion";
in { in {
services = { services.forgejo = {
forgejo = { enable = true;
enable = true; lfs.enable = false;
lfs.enable = false; settings.server = {
settings.server = { DOMAIN = "git.distrust.network";
DOMAIN = "git.distrust.network"; HTTP_PORT = forgejoPort;
HTTP_PORT = forgejoPort; ROOT_URL = "https://git.distrust.network/";
ROOT_URL = "https://git.distrust.network/"; SSH_PORT = 292;
SSH_PORT = 292;
};
}; };
caddy.virtualHosts."https://git.distrust.network ${onionUrl}".extraConfig = ''
reverse_proxy localhost:${toString forgejoPort}
'';
tor.relay.onionServices."forgejo".map = [
80
];
}; };
services.caddy.virtualHosts."https://git.distrust.network ${onionUrl}".extraConfig = ''
reverse_proxy localhost:${toString forgejoPort}
'';
services.tor.relay.onionServices."forgejo".map = [
80
];
} }

View file

@ -1,15 +1,16 @@
{config, ...}: { { config, ... }:
{
mailserver = { mailserver = {
enable = true; enable = true;
fqdn = "distrust.network"; fqdn = "distrust.network";
domains = ["distrust.network"]; domains = [ "distrust.network" ];
certificateScheme = "acme"; certificateScheme = "acme";
ldap = { ldap = {
enable = true; enable = true;
bind.dn = "cn=bind,ou=people,dc=distrust,dc=network"; bind.dn = "cn=bind,ou=people,dc=distrust,dc=network";
bind.passwordFile = config.age.secrets."bind_pw".path; bind.passwordFile = config.age.secrets."bind_pw".path;
searchBase = "ou=people,dc=distrust,dc=network"; searchBase = "ou=people,dc=distrust,dc=network";
uris = ["ldap://localhost:3890"]; uris = [ "ldap://localhost:3890" ];
}; };
}; };
} }

View file

@ -8,97 +8,96 @@
in { in {
age.secrets."nextcloud-admin-pass".file = ../secrets/nextcloud-admin-pass; age.secrets."nextcloud-admin-pass".file = ../secrets/nextcloud-admin-pass;
users.groups.nextcloud.members = ["nextcloud" "caddy"]; services.nextcloud = {
services = { enable = true;
nextcloud = { hostName = "cloud.distrust.network";
enable = true; settings = {
hostName = "cloud.distrust.network"; trusted_domains = ["znfdxs4e3rqvzxtkksiidomupgm2x44wtrzyxtpomczto3xg5qxpcbqd.onion"];
settings = { trusted_proxies = ["127.0.0.1"];
trusted_domains = ["znfdxs4e3rqvzxtkksiidomupgm2x44wtrzyxtpomczto3xg5qxpcbqd.onion"]; maintenance_window_start = 1;
trusted_proxies = ["127.0.0.1"];
maintenance_window_start = 1;
};
config = {
adminpassFile = config.age.secrets."nextcloud-admin-pass".path;
dbtype = "pgsql";
};
package = pkgs.nextcloud32;
https = false;
configureRedis = true;
caching.redis = true;
database.createLocally = true;
phpOptions = {
"opcache.interned_strings_buffer" = 64;
};
}; };
config = {
nginx.enable = lib.mkForce false; adminpassFile = config.age.secrets."nextcloud-admin-pass".path;
phpfpm.pools.nextcloud.settings = { dbtype = "pgsql";
"listen.owner" = "caddy";
"listen.group" = "caddy";
}; };
caddy.virtualHosts."https://cloud.distrust.network ${onionUrl}".extraConfig = '' package = pkgs.nextcloud32;
# encode zstd gzip https = true;
configureRedis = true;
root * ${config.services.nginx.virtualHosts."cloud.distrust.network".root} caching.redis = true;
database.createLocally = true;
redir /.well-known/carddav /remote.php/dav 301
redir /.well-known/caldav /remote.php/dav 301
redir /.well-known/* /index.php{uri} 301
redir /remote/* /remote.php{uri} 301
header {
Strict-Transport-Security max-age=31536000
Permissions-Policy interest-cohort=()
X-Content-Type-Options nosniff
X-Frame-Options SAMEORIGIN
Referrer-Policy no-referrer
X-XSS-Protection "1; mode=block"
X-Permitted-Cross-Domain-Policies none
X-Robots-Tag "noindex, nofollow"
-X-Powered-By
Host {host}
X-Real-IP {remote_host}
X-Forwarded-For {remote_host}
X-Forwarded-Proto {scheme}
X-Forwarded-Host {host}
}
php_fastcgi unix/${config.services.phpfpm.pools.nextcloud.socket} {
root ${config.services.nginx.virtualHosts."cloud.distrust.network".root}
env front_controller_active true
env modHeadersAvailable true
}
@forbidden {
path /build/* /tests/* /config/* /lib/* /3rdparty/* /templates/* /data/*
path /.* /autotest* /occ* /issue* /indie* /db_* /console*
not path /.well-known/*
}
error @forbidden 404
@immutable {
path *.css *.js *.mjs *.svg *.gif *.png *.jpg *.ico *.wasm *.tflite
query v=*
}
header @immutable Cache-Control "max-age=15778463, immutable"
@static {
path *.css *.js *.mjs *.svg *.gif *.png *.jpg *.ico *.wasm *.tflite
not query v=*
}
header @static Cache-Control "max-age=15778463"
@woff2 path *.woff2
header @woff2 Cache-Control "max-age=604800"
file_server
'';
tor.relay.onionServices."nextcloud".map = [
80
];
}; };
users.groups.nextcloud.members = [ "nextcloud" "caddy" ];
services.nginx.enable = lib.mkForce false;
services.phpfpm.pools.nextcloud.settings = {
"listen.owner" = "caddy";
"listen.group" = "caddy";
};
services.caddy.virtualHosts."https://cloud.distrust.network ${onionUrl}".extraConfig = ''
# encode zstd gzip
root * ${config.services.nginx.virtualHosts."cloud.distrust.network".root}
redir /.well-known/carddav /remote.php/dav 301
redir /.well-known/caldav /remote.php/dav 301
redir /.well-known/* /index.php{uri} 301
redir /remote/* /remote.php{uri} 301
header {
Strict-Transport-Security max-age=31536000
Permissions-Policy interest-cohort=()
X-Content-Type-Options nosniff
X-Frame-Options SAMEORIGIN
Referrer-Policy no-referrer
X-XSS-Protection "1; mode=block"
X-Permitted-Cross-Domain-Policies none
X-Robots-Tag "noindex, nofollow"
-X-Powered-By
Host {host}
X-Real-IP {remote_host}
X-Forwarded-For {remote_host}
X-Forwarded-Proto {scheme}
X-Forwarded-Host {host}
}
php_fastcgi unix/${config.services.phpfpm.pools.nextcloud.socket} {
root ${config.services.nginx.virtualHosts."cloud.distrust.network".root}
env front_controller_active true
env modHeadersAvailable true
}
@forbidden {
path /build/* /tests/* /config/* /lib/* /3rdparty/* /templates/* /data/*
path /.* /autotest* /occ* /issue* /indie* /db_* /console*
not path /.well-known/*
}
error @forbidden 404
@immutable {
path *.css *.js *.mjs *.svg *.gif *.png *.jpg *.ico *.wasm *.tflite
query v=*
}
header @immutable Cache-Control "max-age=15778463, immutable"
@static {
path *.css *.js *.mjs *.svg *.gif *.png *.jpg *.ico *.wasm *.tflite
not query v=*
}
header @static Cache-Control "max-age=15778463"
@woff2 path *.woff2
header @woff2 Cache-Control "max-age=604800"
file_server
'';
services.nextcloud.phpOptions = {
"opcache.interned_strings_buffer" = 64;
};
services.tor.relay.onionServices."nextcloud".map = [
80
];
} }

View file

@ -1,50 +1,36 @@
{ {
pkgs, pkgs,
lib,
config, config,
... ...
}: { }: {
age.secrets."bind_pw".file = ../secrets/bind_pw; age.secrets."bind_pw".file = ../secrets/bind_pw;
services = { services.prosody = {
prosody = { package = pkgs.prosody.override {
package = pkgs.prosody.override { withExtraLuaPackages = pkgs: with pkgs.luaPackages; [lualdap];
withExtraLuaPackages = pkgs: with pkgs.luaPackages; [lualdap]; };
}; enable = true;
enable = true; admins = ["root@distrust.network"];
admins = ["root@distrust.network"]; ssl.cert = "/var/lib/acme/distrust.network/fullchain.pem";
ssl.key = "/var/lib/acme/distrust.network/key.pem";
virtualHosts."distrust.network" = {
enabled = true;
domain = "distrust.network";
ssl.cert = "/var/lib/acme/distrust.network/fullchain.pem"; ssl.cert = "/var/lib/acme/distrust.network/fullchain.pem";
ssl.key = "/var/lib/acme/distrust.network/key.pem"; ssl.key = "/var/lib/acme/distrust.network/key.pem";
virtualHosts."distrust.network" = {
enabled = true;
domain = "distrust.network";
ssl.cert = "/var/lib/acme/distrust.network/fullchain.pem";
ssl.key = "/var/lib/acme/distrust.network/key.pem";
};
muc = [{domain = "conference.distrust.network";}];
httpFileShare = {
domain = "upload.distrust.network";
path = "/var/lib/prosody";
};
extraConfig = ''
authentication = "ldap"
ldap_base = "ou=people,dc=distrust,dc=network"
ldap_server = "localhost:3890"
ldap_rootdn = "uid=bind,ou=people,dc=distrust,dc=network"
ldap_password = "${builtins.readFile config.age.secrets."bind_pw".path}"
'';
}; };
caddy.virtualHosts."distrust.network".extraConfig = '' muc = [{domain = "conference.distrust.network";}];
handle /.well-known/* { httpFileShare = {
root * /var/lib/acme/ domain = "upload.distrust.network";
file_server path = "/var/lib/prosody";
} };
''; extraConfig = ''
authentication = "ldap"
caddy.virtualHosts."conference.distrust.network upload.distrust.network".extraConfig = '' ldap_base = "ou=people,dc=distrust,dc=network"
handle /.well-known/* { ldap_server = "localhost:3890"
root * /var/lib/acme/ ldap_rootdn = "uid=bind,ou=people,dc=distrust,dc=network"
file_server ldap_password = "${builtins.readFile config.age.secrets."bind_pw".path}"
}
''; '';
}; };
@ -77,4 +63,18 @@
# after = [ "acme-order-renew-chat.distrust.network.service" ]; # after = [ "acme-order-renew-chat.distrust.network.service" ];
serviceConfig.SupplementaryGroups = ["acme"]; serviceConfig.SupplementaryGroups = ["acme"];
}; };
services.caddy.virtualHosts."distrust.network".extraConfig = ''
handle /.well-known/* {
root * /var/lib/acme/
file_server
}
'';
services.caddy.virtualHosts."conference.distrust.network upload.distrust.network".extraConfig = ''
handle /.well-known/* {
root * /var/lib/acme/
file_server
}
'';
} }

View file

@ -1,4 +1,9 @@
let {
pkgs,
lib,
...
}: let
sitePort = 8080;
onionUrl = "http://nzmkihvxjazbb3fgu7drbklpt6ibg4suff4glxpadhrd4pf5wd2od5yd.onion"; onionUrl = "http://nzmkihvxjazbb3fgu7drbklpt6ibg4suff4glxpadhrd4pf5wd2od5yd.onion";
in { in {
services.caddy.virtualHosts = { services.caddy.virtualHosts = {

View file

@ -1,25 +1,25 @@
{config, ...}: let { config, ... }:
let
vaultPort = 8222; vaultPort = 8222;
onionUrl = "http://gfoqwlo4nmhcywzzyhfanhkf7hz64lkjayngfyrpbd7ohaucu3q4znqd.onion"; onionUrl = "http://gfoqwlo4nmhcywzzyhfanhkf7hz64lkjayngfyrpbd7ohaucu3q4znqd.onion";
in { in
{
age.secrets."vaultwarden.env".file = ../secrets/vaultwarden.env; age.secrets."vaultwarden.env".file = ../secrets/vaultwarden.env;
services = { services.vaultwarden = {
vaultwarden = { enable = true;
enable = true; config = {
config = { DOMAIN = "https://vault.distrust.network";
DOMAIN = "https://vault.distrust.network"; ROCKET_PORT = vaultPort;
ROCKET_PORT = vaultPort;
};
environmentFile = config.age.secrets."vaultwarden.env".path;
}; };
environmentFile = config.age.secrets."vaultwarden.env".path;
caddy.virtualHosts."https://vault.distrust.network ${onionUrl}".extraConfig = ''
reverse_proxy localhost:${toString vaultPort}
'';
tor.relay.onionServices."vaultwarden".map = [
80
];
}; };
services.caddy.virtualHosts."https://vault.distrust.network ${onionUrl}".extraConfig = ''
reverse_proxy localhost:${toString vaultPort}
'';
services.tor.relay.onionServices."vaultwarden".map = [
80
];
} }

View file

@ -55,7 +55,7 @@
<li>Vaultwarden <small><a href="http://gfoqwlo4nmhcywzzyhfanhkf7hz64lkjayngfyrpbd7ohaucu3q4znqd.onion/">[tor]</a> <a href="https://vault.distrust.network">[clearnet]</a> <a title="Once you have logged in for the first time, check your inbox.">[hover]</a></small></li> <li>Vaultwarden <small><a href="http://gfoqwlo4nmhcywzzyhfanhkf7hz64lkjayngfyrpbd7ohaucu3q4znqd.onion/">[tor]</a> <a href="https://vault.distrust.network">[clearnet]</a> <a title="Once you have logged in for the first time, check your inbox.">[hover]</a></small></li>
</ul> </ul>
<p>All services have a strict no-logs and no-metrics policy. Where it is difficult to configure this in a service, logs are directly piped and/or symlinked to <code>/dev/null</code>.</p> <p>All services have a strict no-logs and no-metrics policy. Where it is difficult to configure this in a service, logs are directly piped and/or symlinked to <code>/dev/null</code>.</p>
<p>The server runs a hardened NixOS config, and is updated when appropriate for any security/hardening tweaks. This NixOS config is auditable and freely accessible over <a href="http://cr27k6asjs7skvjxs6smhqfam3wlvmft2f3iins44k6p6rmmfyolobqd.onion/root/flake">TOR</a> and <a href="https://git.distrust.network/root/flake">clearnet</a>.</p> <p>The server runs a hardened NixOS config, and is updated when appropriate for any security/hardening tweaks.</p>
<p>If you are interested, <a href="mailto:root@distrust.network?subject=ACCOUNT%20REQUEST&body=Replace%20this%20email%20body%20with%20your%20desired%20username.">email me</a> with your desired username.</p> <p>If you are interested, <a href="mailto:root@distrust.network?subject=ACCOUNT%20REQUEST&body=Replace%20this%20email%20body%20with%20your%20desired%20username.">email me</a> with your desired username.</p>
<hr> <hr>
<a href="mailto:root@distrust.network?subject=INQUIRY">Contact</a><a href="/privacy-policy.html" class="privacy-policy">Privacy Policy</a> <a href="mailto:root@distrust.network?subject=INQUIRY">Contact</a><a href="/privacy-policy.html" class="privacy-policy">Privacy Policy</a>

View file

@ -1,10 +1,11 @@
{pkgs, ...}: let {pkgs, ...}:
updateScript = pkgs.writeShellScriptBin "rebuild" '' let updateScript = pkgs.writeShellScriptBin "rebuild" ''
#!/bin/sh #!/bin/sh
nixos-rebuild switch --flake /etc/nixos#distrust --impure nixos-rebuild switch --flake /etc/nixos#distrust --impure
''; '';
in { in
environment.systemPackages = with pkgs; [vim btop git alejandra statix deadnix] ++ [updateScript]; {
environment.systemPackages = with pkgs; [vim btop git alejandra statix deadnix] ++ [ updateScript ];
nix.settings.experimental-features = ["nix-command" "flakes"]; nix.settings.experimental-features = ["nix-command" "flakes"];
@ -12,18 +13,16 @@ in {
zramSwap.enable = true; zramSwap.enable = true;
networking.hostName = "distrust"; networking.hostName = "distrust";
services = { services.openssh = {
openssh = { enable = true;
enable = true; settings.PermitRootLogin = "yes";
settings.PermitRootLogin = "yes"; ports = [292];
ports = [292]; };
}; services.fail2ban.enable = true;
fail2ban.enable = true; services.endlessh = {
endlessh = { enable = true;
enable = true; port = 22;
port = 22; openFirewall = true;
openFirewall = true;
};
}; };
users.users.root.openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHxah5pnxmk=P7HtwRsryDoAHZsDs5RcGP9IPCNg1KFe cardno;16-179-196"]; users.users.root.openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHxah5pnxmk=P7HtwRsryDoAHZsDs5RcGP9IPCNg1KFe cardno;16-179-196"];

View file

@ -3,5 +3,6 @@
./configuration.nix ./configuration.nix
./hardware-configuration.nix ./hardware-configuration.nix
./networking.nix ./networking.nix
<nixpkgs/nixos/modules/profiles/hardened.nix>
]; ];
} }

View file

@ -1,12 +1,8 @@
{modulesPath, ...}: { {modulesPath, ...}: {
imports = [(modulesPath + "/profiles/qemu-guest.nix")]; imports = [(modulesPath + "/profiles/qemu-guest.nix")];
boot = { boot.loader.grub.device = "/dev/sda";
loader.grub.device = "/dev/sda"; boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi"];
initrd = { boot.initrd.kernelModules = ["nvme"];
availableKernelModules = ["ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi"];
kernelModules = ["nvme"];
};
};
fileSystems."/" = { fileSystems."/" = {
device = "/dev/sda1"; device = "/dev/sda1";
fsType = "ext4"; fsType = "ext4";