Skip to content

Commit

Permalink
Fix obsidian sync module
Browse files Browse the repository at this point in the history
  • Loading branch information
pniedzwiedzinski committed Oct 17, 2024
1 parent 4de7acb commit 2ecdfe5
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions modules/obsidian-livesync.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ config, lib, ... }:
let
cfg = config.services.obsidian-livesync;
couchdb-port = config.services.couchdb.port or 5984;
in
{
options = {
Expand All @@ -10,7 +11,6 @@ in
domain = lib.mkOption {
type = lib.types.str;
description = "This option is required and must be set by the user.";
default = lib.mkDefault null;
};

couchdb.adminPass = lib.mkOption {
Expand All @@ -27,10 +27,7 @@ in
};
};

config = lib.mkIf cfg.enable (
lib.mkIf (cfg.domain == null)
(throw "You must set `services.obsidian-livesync.domain` to use this service")
{
config = lib.mkIf cfg.enable {
services.couchdb = {
enable = true;
adminPass = cfg.couchdb.adminPass;
Expand All @@ -39,19 +36,19 @@ in

services.nginx = {
enable = true;
virtualHost.${cfg.domain} = {
virtualHosts.${cfg.domain} = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:${config.services.couchdb.port}";
proxySetHeader = {
Host = "$host";
X-Real-IP = "$remote_addr";
X-Forwarded-For = "$proxy_add_x_forwarded_for";
X-Forwarded-Proto = "$scheme";
};
proxyPass = "http://127.0.0.1:${toString couchdb-port}";
extraConfig = ''
proxy_set_header Host "$host";
proxy_set_header X-Real-IP "$remote_addr";
proxy_set_header X-Forwarded-For "$proxy_add_x_forwarded_for";
proxy_set_header X-Forwarded-Proto "$scheme";
'';
};
};
};
});
};
}

0 comments on commit 2ecdfe5

Please sign in to comment.