My Nix Configuration

add hedgedoc service

Changed files
+105
hosts
marvin
+9
hosts/marvin/networking.nix
···
enable = true;
};
wireless.enable = false;
+
+
# Enable NAT for containers
+
nat = {
+
enable = true;
+
internalInterfaces = ["ve-+"];
+
externalInterface = "wlp41s0";
+
# Lazy IPv6 connectivity for the container
+
enableIPv6 = true;
+
};
wireguard = {
enable = true;
interfaces = {
+96
hosts/marvin/services/hedgedoc.nix
···
+
{
+
services.hedgedoc = {
+
enable = true;
+
settings = {
+
domain = "pad.pyrox.dev";
+
port = 6922;
+
# Use HTTPS for links, but unencrypted between server and Caddy.
+
protocolUseSSL = true;
+
useSSL = false;
+
urlAddPort = false;
+
hsts.enable = true;
+
+
# Database settings
+
db = {
+
dialect = "postgres";
+
database = "hedgedoc";
+
host = "192.168.100.10";
+
};
+
+
# Web security settings
+
csp = {
+
enable = true;
+
addDefaults = true;
+
addDisqus = false;
+
addGoogleAnalytics = false;
+
upgradeInsecureRequests = true;
+
allowFraming = false;
+
allowPDFEmbed = false;
+
};
+
+
# Disable Libravatar
+
allowGravatar = false;
+
+
# Anonymous user perms
+
allowAnonymous = false;
+
allowAnonymousEdits = false;
+
+
# Disable email signin
+
email = false;
+
allowEmailRegister = false;
+
+
# Require auth to use FreeURL
+
requireFreeURLAuthentication = true;
+
+
# OAuth2 Login with PyroServ Auth
+
oauth2 = {
+
baseURL = "https://auth.pyrox.dev";
+
userProfileURL = "https://auth.pyrox.dev/application/o/userinfo/";
+
userProfileUsernameAttr = "preferred_username";
+
userProfileDisplayNameAttr = "name";
+
userProfileEmailAttr = "email";
+
providerName = "PyroServ Auth";
+
rolesClaim = "groups";
+
accessRole = "users";
+
tokenURL = "https://auth.pyrox.dev/application/o/token/";
+
authorizationURL = "https://auth.pyrox.dev/application/o/authorize/";
+
clientID = "01610eacdee22b4c353195f6515682faefe22f0e";
+
clientSecret = "";
+
};
+
};
+
};
+
containers.hedgedoc-postgres = {
+
autoStart = true;
+
privateNetwork = true;
+
hostAddress = "192.168.100.10";
+
localAddress = "192.168.100.11";
+
hostAddress6 = "fc00::1";
+
localAddress6 = "fc00::2";
+
+
# Persistant DB storage
+
bindMounts.data.hostPath = "/var/lib/hedgedoc/db";
+
bindMounts.data.mountPoint = "/var/lib/postgresql/15";
+
bindMounts.data.isReadOnly = false;
+
+
# Actual config for the container.
+
config = { config, pkgs, ... }: {
+
system.stateVersion = "23.05";
+
services.postgresql = {
+
enable = true;
+
package = pkgs.postgesql_15;
+
ensureUsers = [{
+
name = "hedgedoc";
+
ensurePermissions = {
+
"DATABASE hedgedoc" = "ALL PRIVILEGES";
+
};
+
}];
+
ensureDatabases = ["hedgedoc"];
+
};
+
networking.firewall = {
+
enable = true;
+
allowedTCPPorts = [ 5432 ];
+
allowedUDPPorts = [ 5432 ];
+
};
+
};
+
};
+
}