2021-11-15 10:02:05 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.userdata;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
systemd.tmpfiles.rules =
|
|
|
|
let
|
2022-07-13 11:08:29 +00:00
|
|
|
nextcloudDBPass = builtins.replaceStrings [ "\n" "\"" "\\" "%" ] [ "\\n" "\\\"" "\\\\" "%%" ] (builtins.fromJSON (builtins.readFile ./userdata/userdata.json).nextcloud.databasePassword);
|
2022-06-09 19:52:54 +00:00
|
|
|
nextcloudAdminPass = builtins.replaceStrings [ "\n" "\"" "\\" "%" ] [ "\\n" "\\\"" "\\\\" "%%" ] cfg.nextcloud.adminPassword;
|
|
|
|
resticPass = builtins.replaceStrings [ "\n" "\"" "\\" "%" ] [ "\\n" "\\\"" "\\\\" "%%" ] cfg.resticPassword;
|
|
|
|
domain = builtins.replaceStrings [ "\n" "\"" "\\" "%" ] [ "\\n" "\\\"" "\\\\" "%%" ] cfg.domain;
|
|
|
|
cloudflareCredentials = builtins.replaceStrings [ "\n" "\"" "\\" "%" ] [ "\\n" "\\\"" "\\\\" "%%" ] ''
|
2021-11-15 10:02:05 +00:00
|
|
|
CF_API_KEY=${cfg.cloudflare.apiKey}
|
|
|
|
CLOUDFLARE_DNS_API_TOKEN=${cfg.cloudflare.apiKey}
|
|
|
|
CLOUDFLARE_ZONE_API_TOKEN=${cfg.cloudflare.apiKey}
|
|
|
|
'';
|
2022-06-09 19:52:54 +00:00
|
|
|
rcloneConfig = builtins.replaceStrings [ "\n" "\"" "\\" "%" ] [ "\\n" "\\\"" "\\\\" "%%" ] ''
|
2021-11-30 20:49:35 +00:00
|
|
|
[backblaze]
|
|
|
|
type = b2
|
|
|
|
account = ${cfg.backblaze.accountId}
|
|
|
|
key = ${cfg.backblaze.accountKey}
|
2021-11-24 05:53:46 +00:00
|
|
|
'';
|
2021-11-15 10:02:05 +00:00
|
|
|
in
|
|
|
|
[
|
2022-05-02 08:04:02 +00:00
|
|
|
(if cfg.bitwarden.enable then "d /var/lib/bitwarden 0777 vaultwarden vaultwarden -" else "")
|
|
|
|
(if cfg.bitwarden.enable then "d /var/lib/bitwarden/backup 0777 vaultwarden vaultwarden -" else "")
|
2021-12-16 13:51:43 +00:00
|
|
|
(if cfg.pleroma.enable then "d /var/lib/pleroma 0700 pleroma pleroma - -" else "")
|
2021-11-17 08:54:36 +00:00
|
|
|
"d /var/lib/restic 0600 restic - - -"
|
2021-12-02 20:30:53 +00:00
|
|
|
"f+ /var/lib/restic/pass 0400 restic - - ${resticPass}"
|
|
|
|
"f+ /root/.config/rclone/rclone.conf 0400 root root - ${rcloneConfig}"
|
2021-12-16 13:51:43 +00:00
|
|
|
(if cfg.pleroma.enable then "f /var/lib/pleroma/secrets.exs 0755 pleroma pleroma - -" else "")
|
2021-12-02 20:30:53 +00:00
|
|
|
"f+ /var/domain 0444 selfprivacy-api selfprivacy-api - ${domain}"
|
|
|
|
(if cfg.nextcloud.enable then "f+ /var/lib/nextcloud/db-pass 0440 nextcloud nextcloud - ${nextcloudDBPass}" else "")
|
|
|
|
(if cfg.nextcloud.enable then "f+ /var/lib/nextcloud/admin-pass 0440 nextcloud nextcloud - ${nextcloudAdminPass}" else "")
|
|
|
|
"f+ /var/lib/cloudflare/Credentials.ini 0440 nginx acmerecievers - ${cloudflareCredentials}"
|
2021-11-15 10:02:05 +00:00
|
|
|
];
|
|
|
|
}
|