diff --git a/flake.lock b/flake.lock index 7f321c8..9116023 100644 --- a/flake.lock +++ b/flake.lock @@ -60,11 +60,11 @@ "utils": "utils_2" }, "locked": { - "lastModified": 1658751516, - "narHash": "sha256-Y/3dHoTjbvYBtWd+TTBQJUIgDPO9d+Gqt05C5dyR7E4=", + "lastModified": 1659484873, + "narHash": "sha256-6VoPiGyDdjBHOJ3IpS24lY1lrDiOHeuEefOFI0qz3WE=", "owner": "nix-community", "repo": "home-manager", - "rev": "dbed4c794d20d51027fc1107f063ec5be027dafc", + "rev": "d8d9ff0b2df77defa10375c6665b51f0251c34d6", "type": "github" }, "original": { @@ -134,11 +134,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1658346836, - "narHash": "sha256-c9BZZbi0tqCQ4j6CMVDlsut3Q3ET1Fezf+qIslCfkhs=", + "lastModified": 1659375853, + "narHash": "sha256-aiMfO6U1w1u93vB+5qCHCQDZKgpJ7qs4GJOQvI3CN/4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a1fe662eb26ffc2a036b37c4670392ade632c413", + "rev": "511f6a5c3248f9019a41e70c1891484de2bc906c", "type": "github" }, "original": { @@ -150,11 +150,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1658737577, - "narHash": "sha256-xosJ5nJT9HX+b6UWsSX6R+ap4AdZOCrl/r+IKFp2ASQ=", + "lastModified": 1659305579, + "narHash": "sha256-SFeQTmh7hc9Y2fSkooHaoS8mDfPa04sfmUCtQ8MA6Pg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5a0e0d73b944157328d54c4ded1cf2f0146a86a5", + "rev": "5857574d45925585baffde730369414319228a84", "type": "github" }, "original": { diff --git a/home/apps/rclone.nix b/home/apps/rclone.nix new file mode 100644 index 0000000..eaa93da --- /dev/null +++ b/home/apps/rclone.nix @@ -0,0 +1 @@ +{ config, pkgs, ... }: { home.packages = with pkgs; [ rclone ]; } diff --git a/home/apps/restic.nix b/home/apps/restic.nix new file mode 100644 index 0000000..92b3f11 --- /dev/null +++ b/home/apps/restic.nix @@ -0,0 +1 @@ +{ config, pkgs, ... }: { home.packages = with pkgs; [ restic ]; } \ No newline at end of file diff --git a/hosts/hetzner-vm/services/restic.nix b/hosts/hetzner-vm/services/restic.nix index 63ca893..374ed41 100644 --- a/hosts/hetzner-vm/services/restic.nix +++ b/hosts/hetzner-vm/services/restic.nix @@ -1,4 +1,4 @@ -_: +{ lib, pkgs, ... }: let mail_config = (import ./mailserver/config.nix { }); @@ -18,21 +18,46 @@ let OnBootSec = "1m"; OnCalendar = "daily"; }; + repos = { + Chaos-Backups-HetznerVM = { + repository = "b2:Chaos-Backups:HetznerVM"; + passwordFile = "/secrets/restic-Chaos-Backups-HetznerVM-password"; + environmentFile = "/secrets/restic-Chaos-Backups-HetznerVM-env"; + }; + Cassie-Backups-HetznerVM = { + repository = "b2:Cryptidz-Backup:HetznerVM"; + passwordFile = "/secrets/restic-Cassie-Backups-HetznerVM-password"; + environmentFile = "/secrets/restic-Cassie-Backups-HetznerVM-env"; + }; + }; + + restic_commands = lib.mapAttrsToList (repoName: repoInfo: ( + # nya + pkgs.writeShellScriptBin "restic-${repoName}" '' + env \ + $(cat ${repoInfo.environmentFile}) \ + RESTIC_PASSWORD_FILE=${repoInfo.passwordFile} \ + RESTIC_REPOSITORY=${repoInfo.repository} \ + ${pkgs.restic}/bin/restic $@ + '' + )) repos; in { - services.restic.backups.hetzner-vm = { - user = backupUser; - paths = backupPaths; - inherit timerConfig; - repository = "b2:Backups-HetznerVM:/"; - passwordFile = "/secrets/restic-password"; - environmentFile = "/secrets/restic-env"; - }; - services.restic.backups.cassie-hetzner-vm = { - user = backupUser; - paths = backupPaths; - inherit timerConfig; - repository = "b2:Cryptidz-Backup:HetznerVM"; - passwordFile = "/secrets/restic-password-cassie"; - environmentFile = "/secrets/restic-env-cassie"; - }; + environment.systemPackages = restic_commands; + + services.restic.backups.hetzner-vm = lib.mkMerge [ + { + user = backupUser; + paths = backupPaths; + inherit timerConfig; + } + repos.Chaos-Backups-HetznerVM + ]; + services.restic.backups.cassie-hetzner-vm = lib.mkMerge [ + { + user = backupUser; + paths = backupPaths; + inherit timerConfig; + } + repos.Cassie-Backups-HetznerVM + ]; } diff --git a/hosts/lappy/lappy.nix b/hosts/lappy/lappy.nix index b9dbe00..77d828d 100644 --- a/hosts/lappy/lappy.nix +++ b/hosts/lappy/lappy.nix @@ -83,6 +83,9 @@ in { home.apps.mullvad home.apps.aria2 home.apps.aegisub + home.apps.rclone + home.apps.restic + home.programming.editors.vscode home.programming.languages.go