added resticprofile flake-part

This commit is contained in:
John Lancaster
2026-03-08 14:48:41 -05:00
parent e9c54606e2
commit 8b8edf9211
4 changed files with 146 additions and 8 deletions

View File

@@ -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;
};
};

View File

@@ -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;
};
}
);
};
}

View File

@@ -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;
}
];
};

51
resticprofile/base.nix Normal file
View File

@@ -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";
};
};
}