From 5ffd4dfc8bb8a616d7755eec123370489cad470d Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Tue, 17 Sep 2024 19:38:22 -0400 Subject: [PATCH] backblaze: drop module --- homeManagerModules/apps/backblaze/default.nix | 29 ------------------- homeManagerModules/apps/default.nix | 1 - homeManagerModules/options.nix | 16 ---------- homes/aly/common.nix | 8 ----- homes/aly/secrets.nix | 2 -- hosts/mauville/home.nix | 11 +++++-- 6 files changed, 9 insertions(+), 58 deletions(-) delete mode 100644 homeManagerModules/apps/backblaze/default.nix diff --git a/homeManagerModules/apps/backblaze/default.nix b/homeManagerModules/apps/backblaze/default.nix deleted file mode 100644 index cf2d1fb7..00000000 --- a/homeManagerModules/apps/backblaze/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - cfg = config.ar.home.apps.backblaze; -in { - config = lib.mkIf cfg.enable { - home = { - activation.backblazeAuthentication = lib.hm.dag.entryAfter ["reloadSystemd"] '' - ${ - if ((cfg.keyIdFile != null) && (cfg.keyFile != null)) - then - ( - if !(builtins.pathExists "${config.xdg.configHome}/b2/account_info") - then '' - XDG_RUNTIME_DIR=''${XDG_RUNTIME_DIR:-/run/user/$(id -u)} - run --quiet ${lib.getExe pkgs.backblaze-b2} authorize_account `${lib.getExe' pkgs.coreutils "cat"} ${cfg.keyIdFile}` `${lib.getExe' pkgs.coreutils "cat"} ${cfg.keyFile}`'' - else ''run echo "backblaze: Already authenticated."'' - ) - else ''run echo "backblaze: Missing keyIDfile and keyFile."'' - } - ''; - - packages = with pkgs; [backblaze-b2]; - }; - }; -} diff --git a/homeManagerModules/apps/default.nix b/homeManagerModules/apps/default.nix index afeaf7d0..49eb4ece 100644 --- a/homeManagerModules/apps/default.nix +++ b/homeManagerModules/apps/default.nix @@ -1,7 +1,6 @@ { imports = [ ./alacritty - ./backblaze ./chromium ./emacs ./fastfetch diff --git a/homeManagerModules/options.nix b/homeManagerModules/options.nix index 10ce5f2f..f8eaf7de 100644 --- a/homeManagerModules/options.nix +++ b/homeManagerModules/options.nix @@ -11,22 +11,6 @@ in { apps = { alacritty.enable = lib.mkEnableOption "Alacritty terminal."; - backblaze = { - enable = lib.mkEnableOption "Backblaze-b2 client with declarative authentication."; - - keyIdFile = lib.mkOption { - description = "Backblaze key ID."; - default = null; - type = lib.types.nullOr lib.types.str; - }; - - keyFile = lib.mkOption { - description = "Backblaze application key."; - default = null; - type = lib.types.nullOr lib.types.str; - }; - }; - chromium = { enable = lib.mkEnableOption "Chromium-based browser with default extensions."; package = lib.mkPackageOption pkgs "brave" {}; diff --git a/homes/aly/common.nix b/homes/aly/common.nix index 8b07c359..d57c42f4 100644 --- a/homes/aly/common.nix +++ b/homes/aly/common.nix @@ -1,5 +1,4 @@ { - config, pkgs, ... }: { @@ -7,7 +6,6 @@ homeDirectory = "/home/aly"; packages = with pkgs; [ - browsh curl ]; @@ -47,12 +45,6 @@ ar.home = { apps = { - backblaze = { - enable = true; - keyIdFile = config.age.secrets.backblazeKeyId.path; - keyFile = config.age.secrets.backblazeKey.path; - }; - fastfetch.enable = true; helix.enable = true; shell.enable = true; diff --git a/homes/aly/secrets.nix b/homes/aly/secrets.nix index 65a1ad65..3e42d545 100644 --- a/homes/aly/secrets.nix +++ b/homes/aly/secrets.nix @@ -2,8 +2,6 @@ age.secrets = { achacegaGmail.file = ../../secrets/aly/mail/achacega_gmail.age; alyraffaufFastmail.file = ../../secrets/aly/mail/alyraffauf_fastmail.age; - backblazeKeyId.file = ../../secrets/aly/backblaze/keyId.age; - backblazeKey.file = ../../secrets/aly/backblaze/key.age; transmissionRemote = { file = ../../secrets/aly/transmissionRemote.age; diff --git a/hosts/mauville/home.nix b/hosts/mauville/home.nix index 1fbd291b..05dda53f 100644 --- a/hosts/mauville/home.nix +++ b/hosts/mauville/home.nix @@ -33,9 +33,14 @@ } ]; - users.aly = lib.mkForce { + users.aly = lib.mkForce ({config, ...}: { imports = [self.homeManagerModules.aly]; + age.secrets = { + backblazeKeyId.file = ../../secrets/aly/backblaze/keyId.age; + backblazeKey.file = ../../secrets/aly/backblaze/key.age; + }; + systemd.user = { services.backblaze-sync = { Unit.Description = "Backup to Backblaze."; @@ -61,6 +66,8 @@ ['/mnt/Archive/Shows']="b2://aly-shows" ) + backblaze-b2 authorize_account `cat ${config.age.secrets.backblazeKeyId.path}` `cat ${config.age.secrets.backblazeKey.path}` + # Recursively backup folders to B2 with sanity checks. for folder in "''${!backups[@]}"; do if [ -d "$folder" ] && [ "$(ls -A "$folder")" ]; then @@ -80,6 +87,6 @@ Unit.Description = "Daily backups to Backblaze."; }; }; - }; + }); }; }