Compare commits

...

7 Commits

Author SHA1 Message Date
Illia Chub d1620a9680 Added fixes for disk expansion and VPN networking 2022-02-06 11:44:00 +02:00
Illia Chub 8878832ff9
Added write permissions for shared group members 2021-12-23 09:42:27 +02:00
Illia Chub cccbd177be
Added common access layer for internal services 2021-12-23 09:26:09 +02:00
Inex Code 2a15727170 Fix repository URI 2021-12-21 16:43:05 +03:00
Inex Code 84e0ae01f9 Move rclone conf to restic.nix 2021-12-21 16:24:51 +03:00
Inex Code 9f54887254 Fix permissions for restic 2021-12-21 13:12:27 +03:00
Inex Code b79acbaf6a Use b2 for backups 2021-12-21 13:01:25 +03:00
6 changed files with 36 additions and 20 deletions

4
.gitignore vendored
View File

@ -1,3 +1 @@
userdata/userdata.json
hardware-configuration.nix
networking.nix
userdata/userdata.json

View File

@ -4,13 +4,19 @@ let
in
{
services.restic.backups = {
options = {
passwordFile = "/etc/restic/resticPasswd";
repository = "s3:s3.anazonaws.com/${cfg.backblaze.bucket}";
varBackup = {
passwordFile = "/var/lib/restic/pass";
repository = "rclone:${cfg.backblaze.bucket}:/sfbackup";
extraOptions = [ "rclone.args='serve restic --stdio'" ];
rcloneConfig = {
type = "b2";
account = cfg.backblaze.accountId;
key = cfg.backblaze.accountKey;
hard_delete = false;
};
initialize = true;
paths = [
"/var/dkim"
"/var/vmail"
"/var"
];
timerConfig = {
OnCalendar = [ "daily" ];
@ -25,11 +31,4 @@ in
isNormalUser = false;
isSystemUser = true;
};
environment.etc."restic/resticPasswd".text = ''
${cfg.resticPassword}
'';
environment.etc."restic/s3Passwd".text = ''
AWS_ACCESS_KEY_ID=${cfg.backblaze.accountId}
AWS_SECRET_ACCESS_KEY=${cfg.backblaze.accountKey}
'';
}

View File

@ -6,7 +6,6 @@ in
{
imports = [
./hardware-configuration.nix
./variables-module.nix
./variables.nix
./files.nix
@ -34,9 +33,14 @@ in
boot.cleanTmpDir = true;
networking = {
hostName = config.services.userdata.hostname;
usePredictableInterfaceNames = false;
firewall = {
allowedTCPPorts = lib.mkForce [ 22 25 80 143 443 465 587 993 8443 ];
allowedUDPPorts = lib.mkForce [ 8443 ];
extraCommands = ''
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface vpn00 -j ACCEPT
'';
};
nameservers = [ "1.1.1.1" "1.0.0.1" ];
};
@ -84,4 +88,4 @@ in
enable = true;
};
};
}
}

View File

@ -22,10 +22,11 @@ in
'';
in
[
(if cfg.bitwarden.enable then "d /var/lib/bitwarden 0777 bitwarden_rs bitwarden_rs -" else "")
(if cfg.bitwarden.enable then "d /var/lib/bitwarden/backup 0777 bitwarden_rs bitwarden_rs -" else "")
(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 "")
(if cfg.pleroma.enable then "d /var/lib/pleroma 0700 pleroma pleroma - -" else "")
"d /var/lib/restic 0600 restic - - -"
"d /var 0760 root shared - -"
"d /var/lib/restic 0700 restic - - -"
"f+ /var/lib/restic/pass 0400 restic - - ${resticPass}"
"f+ /root/.config/rclone/rclone.conf 0400 root root - ${rcloneConfig}"
(if cfg.pleroma.enable then "f /var/lib/pleroma/secrets.exs 0755 pleroma pleroma - -" else "")

View File

@ -0,0 +1,9 @@
{ modulesPath, ... }:
{
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
boot.loader.grub.device = "/dev/sda";
fileSystems = {
"/" = { device = "/dev/sda1"; fsType = "ext4"; };
"/var" = { device = "/dev/sdb"; fsType = "ext4"; };
};
}

View File

@ -21,5 +21,10 @@ in
};
})
cfg.users);
groups = {
shared = {
members = [ "restic" ];
};
};
};
}