From 8b8edf92112c63ec36fe17344437061ef51eb435 Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Sun, 8 Mar 2026 14:48:41 -0500 Subject: [PATCH] added resticprofile flake-part --- modules/home-manager/programs/ghostty.nix | 14 ++-- .../home-manager/programs/resticprofile.nix | 84 +++++++++++++++++++ modules/hosts/john-pc-ubuntu.nix | 5 +- resticprofile/base.nix | 51 +++++++++++ 4 files changed, 146 insertions(+), 8 deletions(-) create mode 100644 modules/home-manager/programs/resticprofile.nix create mode 100644 resticprofile/base.nix diff --git a/modules/home-manager/programs/ghostty.nix b/modules/home-manager/programs/ghostty.nix index 0ccde0c..e0572cd 100644 --- a/modules/home-manager/programs/ghostty.nix +++ b/modules/home-manager/programs/ghostty.nix @@ -33,12 +33,14 @@ shell-integration-features = [ "no-title" "sudo" ]; gtk-single-instance = true; - window-position-x = 50; - window-position-y = 50; + window-position-x = 25; + window-position-y = 25; + # window-height = 40; + # window-width = 200; - window-padding-balance = true; - window-padding-x = 5; - window-padding-y = 5; + # window-padding-balance = true; + # window-padding-x = 5; + # window-padding-y = 5; initial-window = true; resize-overlay = "never"; @@ -52,8 +54,6 @@ "ctrl+s>k=goto_split:down" ]; - window-height = 40; - window-width = 200; }; }; diff --git a/modules/home-manager/programs/resticprofile.nix b/modules/home-manager/programs/resticprofile.nix new file mode 100644 index 0000000..78b5248 --- /dev/null +++ b/modules/home-manager/programs/resticprofile.nix @@ -0,0 +1,84 @@ +{ inputs, ... }: +{ + perSystem = { pkgs, ... }: + let + resticprofilePkg = pkgs.buildGoModule rec { + pname = "resticprofile"; + version = "0.32.0"; + src = pkgs.fetchFromGitHub { + owner = "creativeprojects"; + repo = "resticprofile"; + rev = "v${version}"; + sha256 = "sha256-fmYsoGYppNgbtoX18aF5UHBG9ieYorBJ9JZkwrR+UBI="; + }; + vendorHash = "sha256-/GVWjOvkYe7xMRjANKIKV6FSU0F5VY1ZP/ppgAJyhvw="; + goPackagePath = "github.com/creativeprojects/resticprofile"; + doCheck = false; + meta = with pkgs.lib; { + description = "Configuration profiles manager and scheduler for restic backup"; + homepage = "https://creativeprojects.github.io/resticprofile/"; + license = licenses.gpl3Only; + maintainers = [ ]; + }; + }; + in { + packages = { + resticprofile = resticprofilePkg; + default = resticprofilePkg; + }; + }; + + flake.homeModules.resticprofile = { config, lib, pkgs, ... }: + let + cfg = config.programs.resticprofile; + yamlFormat = pkgs.formats.yaml { }; + baseProfile = import ../../../resticprofile/base.nix { inherit lib config; }; + profiles = lib.recursiveUpdate baseProfile cfg.profiles; + in { + options.programs.resticprofile = { + enable = lib.mkEnableOption "Enable resticprofile (Restic backup profile manager)"; + package = lib.mkPackageOption pkgs "resticprofile" { }; + profiles = lib.mkOption { + type = lib.types.attrsOf yamlFormat.type; + default = { }; + description = '' + Additional resticprofile configuration merged on top of the base profile. + Each attribute becomes a profile entry in + `$XDG_CONFIG_HOME/resticprofile/profiles.yaml`. + ''; + }; + }; + + config = lib.mkIf cfg.enable ( + let + resticprofilePackage = lib.mkDefault + inputs.self.packages.${pkgs.system}.resticprofile; + resticprofileBin = lib.getExe cfg.package; + rpScript = pkgs.writeShellScriptBin "rp" '' + set -e + sudo ${resticprofileBin} --config "${config.xdg.configHome}/resticprofile/profiles.yaml" $@ + ''; + rpbackupScript = pkgs.writeShellScriptBin "rp-backup" '' + ${lib.getExe rpScript} run-schedule backup@default + ''; + in { + programs.resticprofile.package = resticprofilePackage; + home.packages = [ + cfg.package + rpScript + rpbackupScript + (pkgs.writeShellScriptBin "rps" '' + set -e + ${lib.getExe rpScript} unschedule --all + ${lib.getExe rpScript} schedule --all + '') + (pkgs.writeShellScriptBin "rp-test" "${lib.getExe rpbackupScript} --dry-run") + ]; + xdg.configFile."resticprofile/profiles.yaml".source = yamlFormat.generate "profiles" { + version = "2"; + profiles = profiles; + }; + } + ); + }; +} diff --git a/modules/hosts/john-pc-ubuntu.nix b/modules/hosts/john-pc-ubuntu.nix index 1905d6b..4af79b7 100644 --- a/modules/hosts/john-pc-ubuntu.nix +++ b/modules/hosts/john-pc-ubuntu.nix @@ -2,8 +2,9 @@ { flake.homeModules."john-pc-ubuntu" = { imports = with inputs.self.homeModules; [ - desktop john + desktop + resticprofile ]; # TODO: Add host-specific settings here: @@ -26,6 +27,8 @@ appdaemon = true; homelab = true; }; + shell.program = "zsh"; + programs.resticprofile.enable = true; } ]; }; diff --git a/resticprofile/base.nix b/resticprofile/base.nix new file mode 100644 index 0000000..4d808b5 --- /dev/null +++ b/resticprofile/base.nix @@ -0,0 +1,51 @@ +{ lib, config, ... }: +{ + base = { + repository = "local:/mnt/backup"; + password-file = "{{ .ConfigDir }}/resticprofile/password.txt"; + status-file = "{{ .ConfigDir }}/backup-status.json"; + retention = { + after-backup = true; + keep-last = "10"; + keep-hourly = "8"; + keep-daily = "14"; + keep-weekly = "8"; + }; + backup = { + verbose = true; + exclude = [ + ".cache" + ".devenv" + ".rustup" + ".cargo" + ".venv" + ".pyenv" + ".vscode*" + "data/postgres" + "build" + "__pycache__" + "*.log" + "*.egg-info" + "*.csv" + "*.m4a" + + ".local/share/Steam" + ".local/share/Trash" + "build" + "dist" + "/home/*/Pictures" + "/home/*/Videos" + "/home/*/go" + "/home/*/snap" + "/home/john/john-nas" + ]; + schedule-permission = "user"; + schedule-priority = "background"; + check-after = true; + }; + prune = { + schedule-permission = "user"; + schedule-lock-wait = "1h"; + }; + }; +}