2022-05-15 01:24:06 +02:00
|
|
|
|
# Edit this configuration file to define what should be installed on
|
|
|
|
|
# your system. Help is available in the configuration.nix(5) man page
|
|
|
|
|
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
|
|
|
|
|
2023-04-14 22:28:06 +02:00
|
|
|
|
{ lib, config, pkgs, ... }:
|
2022-05-15 01:24:06 +02:00
|
|
|
|
let
|
|
|
|
|
db_name = "hedgedoc";
|
|
|
|
|
db_user = "hedgedoc";
|
2023-05-04 15:14:36 +02:00
|
|
|
|
inherit (config.meta.exposes.md) port;
|
2022-05-15 01:24:06 +02:00
|
|
|
|
vs = config.vault-secrets.secrets;
|
2023-09-25 11:56:02 +02:00
|
|
|
|
in
|
|
|
|
|
{
|
2022-05-15 01:24:06 +02:00
|
|
|
|
imports = [ ];
|
|
|
|
|
|
|
|
|
|
# This value determines the NixOS release from which the default
|
|
|
|
|
# settings for stateful data, like file locations and database versions
|
|
|
|
|
# on your system were taken. It‘s perfectly fine and recommended to leave
|
|
|
|
|
# this value at the release version of the first install of this system.
|
|
|
|
|
# Before changing this value read the documentation for this option
|
|
|
|
|
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
|
|
|
|
system.stateVersion = "21.11"; # Did you read the comment?
|
|
|
|
|
|
|
|
|
|
environment.noXlibs = lib.mkForce false;
|
|
|
|
|
|
2023-05-05 10:04:38 +02:00
|
|
|
|
networking.firewall.allowedTCPPorts = [ port ];
|
2022-05-15 01:24:06 +02:00
|
|
|
|
|
|
|
|
|
vault-secrets.secrets.hedgedoc = { };
|
|
|
|
|
|
2023-04-14 22:28:06 +02:00
|
|
|
|
services.postgresql = {
|
|
|
|
|
enable = true;
|
|
|
|
|
package = pkgs.postgresql_13;
|
|
|
|
|
ensureDatabases = [ db_name ];
|
|
|
|
|
ensureUsers = [{
|
|
|
|
|
name = db_user;
|
|
|
|
|
ensurePermissions = { "DATABASE ${db_name}" = "ALL PRIVILEGES"; };
|
|
|
|
|
}];
|
|
|
|
|
};
|
2022-05-15 01:24:06 +02:00
|
|
|
|
|
|
|
|
|
services.hedgedoc = {
|
|
|
|
|
enable = true;
|
|
|
|
|
environmentFile = "${vs.hedgedoc}/environment";
|
2022-07-28 12:36:55 +02:00
|
|
|
|
settings = {
|
2022-05-15 01:24:06 +02:00
|
|
|
|
host = "0.0.0.0";
|
2023-05-04 15:14:36 +02:00
|
|
|
|
inherit port;
|
2022-05-15 01:24:06 +02:00
|
|
|
|
sessionSecret = "$SESSION_SECRET";
|
|
|
|
|
domain = "md.0x76.dev";
|
|
|
|
|
protocolUseSSL = true;
|
|
|
|
|
hsts.enable = true;
|
2023-04-14 22:28:06 +02:00
|
|
|
|
allowOrigin = [ config.services.hedgedoc.settings.domain "hedgedoc" ];
|
2022-05-16 14:17:55 +02:00
|
|
|
|
allowAnonymous = false;
|
2022-05-15 01:24:06 +02:00
|
|
|
|
allowEmailRegister = false;
|
2022-05-16 14:17:55 +02:00
|
|
|
|
allowAnonymousEdits = true;
|
2022-05-15 10:54:26 +02:00
|
|
|
|
allowFreeURL = true;
|
|
|
|
|
requireFreeURLAuthentication = true;
|
2022-05-15 01:24:06 +02:00
|
|
|
|
imageUploadType = "minio";
|
|
|
|
|
db = {
|
|
|
|
|
dialect = "postgres";
|
|
|
|
|
username = db_user;
|
|
|
|
|
database = db_name;
|
|
|
|
|
host = "/run/postgresql";
|
|
|
|
|
};
|
|
|
|
|
s3bucket = "hedgedoc";
|
|
|
|
|
minio = {
|
2022-05-15 10:54:26 +02:00
|
|
|
|
secure = true;
|
|
|
|
|
endPoint = "o.0x76.dev";
|
|
|
|
|
port = 443;
|
2022-05-15 01:24:06 +02:00
|
|
|
|
accessKey = "$MINIO_ACCESS_KEY";
|
|
|
|
|
secretKey = "$MINIO_SECRET_KEY";
|
|
|
|
|
};
|
2023-05-05 12:58:00 +02:00
|
|
|
|
email = false;
|
2023-09-25 11:56:02 +02:00
|
|
|
|
oauth2 =
|
|
|
|
|
let url = "https://dex.0x76.dev";
|
|
|
|
|
in {
|
|
|
|
|
providerName = "Dex";
|
|
|
|
|
clientID = "hedgedoc";
|
|
|
|
|
clientSecret = "$DEX_CLIENT_SECRET";
|
|
|
|
|
scope = "openid email profile";
|
|
|
|
|
authorizationURL = "${url}/auth";
|
|
|
|
|
tokenURL = "${url}/token";
|
|
|
|
|
userProfileURL = "${url}/userinfo";
|
|
|
|
|
userProfileUsernameAttr = "preferred_username";
|
|
|
|
|
userProfileDisplayNameAttr = "name";
|
|
|
|
|
userProfileEmailAttr = "email";
|
|
|
|
|
};
|
2022-05-15 01:24:06 +02:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|