From 9b13797b9b444f866dc93f54e7023b25f7c788a1 Mon Sep 17 00:00:00 2001 From: jasmine Date: Wed, 16 Oct 2024 04:59:02 +0800 Subject: [PATCH] install wiki-js --- ...2e226886559938be8ab210a35772b1-wiki-js.age | 8 ++++ .../viridian/services/postgresql/default.nix | 20 ++++++++ nixos/viridian/services/wiki-js/default.nix | 48 +++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 nixos/common/global/secrets/rekeyed/viridian/ad2e226886559938be8ab210a35772b1-wiki-js.age create mode 100644 nixos/viridian/services/postgresql/default.nix create mode 100644 nixos/viridian/services/wiki-js/default.nix diff --git a/nixos/common/global/secrets/rekeyed/viridian/ad2e226886559938be8ab210a35772b1-wiki-js.age b/nixos/common/global/secrets/rekeyed/viridian/ad2e226886559938be8ab210a35772b1-wiki-js.age new file mode 100644 index 0000000..81235fa --- /dev/null +++ b/nixos/common/global/secrets/rekeyed/viridian/ad2e226886559938be8ab210a35772b1-wiki-js.age @@ -0,0 +1,8 @@ +age-encryption.org/v1 +-> ssh-ed25519 KTkZog 7QJNbtDdO9LpwTDNgeaEtm4KTONs5Hgukenu2AL6dSY +l7Nz7xlPLUmYWxbL2tcUT/pgaoZUcGppKaUzoSDty7g +-> PLN-grease +KPAHJevjQIdgSu1kVhcefi2Y6aNgqaqhKXS0D3QWBFlSk7Kr8YQw2dDFpFW7fH/1 +9tvZZz5hJe+sJA +--- ZiUHAguNDc75YzOTCuWOz3HEAyA6KrWZJvWB/bLDJw8 +P|6("p3l."2aѤTB:6i4kb23` \ No newline at end of file diff --git a/nixos/viridian/services/postgresql/default.nix b/nixos/viridian/services/postgresql/default.nix new file mode 100644 index 0000000..a1e0c5e --- /dev/null +++ b/nixos/viridian/services/postgresql/default.nix @@ -0,0 +1,20 @@ +{pkgs, ...}: { + services.postgresql = { + enable = true; + package = pkgs.postgresql_15; + settings = { + port = 5432; + }; + dataDir = "/var/lib/postgresql/15"; + }; + + environment.persistence."/persist" = { + directories = [ + { + directory = "/var/lib/postgresql"; + user = "postgres"; + group = "postgres"; + } + ]; + }; +} diff --git a/nixos/viridian/services/wiki-js/default.nix b/nixos/viridian/services/wiki-js/default.nix new file mode 100644 index 0000000..45c4727 --- /dev/null +++ b/nixos/viridian/services/wiki-js/default.nix @@ -0,0 +1,48 @@ +{config, ...}: { + systemd.services.wiki-js = { + requires = ["postgresql.service"]; + after = ["postgresql.service"]; + }; + + services.wiki-js = { + enable = true; + settings.db = { + db = "wiki-js"; + host = "/run/postgresql"; + type = "postgres"; + user = "wiki-js"; + }; + }; + + services.postgresql = { + ensureDatabases = ["wiki-js"]; + ensureUsers = [ + { + name = "wiki-js"; + ensureDBOwnership = true; + } + ]; + }; + + services.traefik.dynamicConfigOptions.http.routers = { + wiki-js = { + rule = "Host(`wiki.sajkbd.io`)"; + entryPoints = [ + "websecure" + ]; + middlewares = [ + "crowdsec" + "geoblock" + ]; + service = "wiki-js"; + }; + }; + + services.traefik.dynamicConfigOptions.http.services = { + wiki-js.loadBalancer.servers = [ + {url = "http://127.0.0.1:${toString config.services.wiki-js.settings.port}";} + ]; + }; + + environment.persistence."/persist".directories = ["/var/lib/wiki-js"]; +}