mirror of
https://github.com/kmein/niveum
synced 2026-03-30 09:11:10 +02:00
Compare commits
3 Commits
fd38db79c0
...
6079c109f9
| Author | SHA1 | Date | |
|---|---|---|---|
| 6079c109f9 | |||
| d74b261897 | |||
| fa192a3977 |
@@ -1,4 +1,12 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
let
|
||||||
|
backupLocation = "/var/lib/codimd-backup";
|
||||||
|
stateLocation = "/var/lib/codimd/state.sqlite";
|
||||||
|
nixpkgs-unstable = import <nixpkgs-unstable> {};
|
||||||
|
in
|
||||||
{
|
{
|
||||||
|
imports = [ <stockholm/krebs/3modules/permown.nix> ];
|
||||||
|
|
||||||
services.nginx.virtualHosts."pad.xn--kiern-0qa.de" = {
|
services.nginx.virtualHosts."pad.xn--kiern-0qa.de" = {
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
addSSL = true;
|
addSSL = true;
|
||||||
@@ -17,9 +25,41 @@
|
|||||||
allowFreeURL = true;
|
allowFreeURL = true;
|
||||||
db = {
|
db = {
|
||||||
dialect = "sqlite";
|
dialect = "sqlite";
|
||||||
storage = "/var/lib/codimd/state.sqlite";
|
storage = stateLocation;
|
||||||
};
|
};
|
||||||
port = 3091;
|
port = 3091;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
krebs.permown.${backupLocation} = { owner = "codimd"; group = "codimd"; umask = "0002"; };
|
||||||
|
|
||||||
|
systemd.services.hedgedoc-backup = {
|
||||||
|
description = "Hedgedoc backup service";
|
||||||
|
script = ''
|
||||||
|
${nixpkgs-unstable.sqlite}/bin/sqlite3 -json ${stateLocation} "select shortid, alias, ownerId, content from Notes" \
|
||||||
|
| ${pkgs.writers.writePython3 "hedgedoc-json-to-fs.py" {} ''
|
||||||
|
import json
|
||||||
|
import pathlib
|
||||||
|
import sys
|
||||||
|
|
||||||
|
for note in json.load(sys.stdin):
|
||||||
|
user_directory = pathlib.Path()
|
||||||
|
if note["ownerId"]:
|
||||||
|
user_directory = pathlib.Path(note["ownerId"])
|
||||||
|
user_directory.mkdir(exist_ok=True)
|
||||||
|
file_path = user_directory / (
|
||||||
|
(note["alias"] if note["alias"] else note["shortid"]) + ".md"
|
||||||
|
)
|
||||||
|
file_path.write_text(note["content"])
|
||||||
|
print(f"✔ {file_path}", file=sys.stderr)
|
||||||
|
''}
|
||||||
|
'';
|
||||||
|
startAt = "hourly";
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "codimd";
|
||||||
|
Group = "codimd";
|
||||||
|
WorkingDirectory = backupLocation;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,13 @@ in
|
|||||||
boot.loader.grub.enable = true;
|
boot.loader.grub.enable = true;
|
||||||
boot.loader.grub.version = 2;
|
boot.loader.grub.version = 2;
|
||||||
|
|
||||||
nixpkgs.config.allowUnfree = true;
|
nixpkgs.config = {
|
||||||
|
allowUnfree = true;
|
||||||
|
packageOverrides = pkgs: {
|
||||||
|
writeDashBin = pkgs.writers.writeDashBin;
|
||||||
|
writeDash = pkgs.writers.writeDash;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
networking.useDHCP = false;
|
networking.useDHCP = false;
|
||||||
networking.interfaces.ens3.useDHCP = true;
|
networking.interfaces.ens3.useDHCP = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user