nixos/modules/services/hedgedoc/default.nix

96 lines
2 KiB
Nix
Raw Normal View History

2022-10-15 16:40:38 +02:00
# HedgeDoc is an open-source, web-based, self-hosted, collaborative markdown editor.
2024-07-28 21:08:02 +02:00
{
config,
lib,
pkgs,
...
}:
2022-10-15 16:40:38 +02:00
let
cfg = config.my.services.hedgedoc;
2023-11-07 23:13:51 +01:00
inherit (config.networking) domain;
2022-10-15 16:40:38 +02:00
in
{
options.my.services.hedgedoc = with lib; {
2023-03-15 22:38:22 +01:00
enable = mkEnableOption "Hedgedoc Music Server";
2022-10-15 16:40:38 +02:00
settings = mkOption {
2023-11-07 23:13:51 +01:00
inherit (pkgs.formats.json { }) type;
2022-10-15 16:40:38 +02:00
default = { };
example = {
"LastFM.ApiKey" = "MYKEY";
"LastFM.Secret" = "MYSECRET";
"Spotify.ID" = "MYKEY";
"Spotify.Secret" = "MYSECRET";
};
description = ''
Additional settings.
'';
};
port = mkOption {
type = types.port;
2022-12-25 12:15:01 +01:00
default = 3080;
2022-10-15 16:40:38 +02:00
example = 8080;
description = "Internal port for webui";
};
};
config = lib.mkIf cfg.enable {
services = {
hedgedoc = {
enable = true;
2022-10-15 16:40:38 +02:00
settings = {
domain = "notes.${domain}";
inherit (cfg) port;
protocolUseSSL = true;
db = {
dialect = "sqlite";
storage = "/var/lib/hedgedoc/hedgedoc.sqlite";
};
} // cfg.settings;
};
2022-10-15 16:40:38 +02:00
prometheus = {
scrapeConfigs = [
{
job_name = "hedgedoc";
static_configs = [
{
targets = [ "localhost:${toString cfg.port}" ];
labels = {
instance = config.networking.hostName;
};
}
];
}
];
};
2022-12-25 12:15:01 +01:00
grafana.provision.dashboards.settings.providers = [
{
name = "Hedgedoc";
options.path = pkgs.grafana-dashboards.hedgedoc;
disableDeletion = true;
}
];
};
2022-10-15 16:40:38 +02:00
my.services.nginx.virtualHosts = [
{
subdomain = "notes";
inherit (cfg) port;
}
];
webapps.apps.hedgedoc = {
dashboard = {
name = "Notes";
category = "app";
icon = "edit";
2023-11-12 20:39:44 +01:00
url = "https://notes.${domain}";
2022-10-15 16:40:38 +02:00
};
};
};
}