mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 04:58:01 +00:00
Add modules
- `modules.bleachbit` for home-manager. - `modules.hardware-setup.backup-archive` for NixOS. This might be converted to a generic backup service for removable devices.
This commit is contained in:
parent
7991d33650
commit
2ccaca429a
93
modules/home-manager/bleachbit.nix
Normal file
93
modules/home-manager/bleachbit.nix
Normal file
@ -0,0 +1,93 @@
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let cfg = config.modules.bleachbit;
|
||||
in {
|
||||
options.modules.bleachbit = {
|
||||
enable = lib.mkEnableOption "automated cleanup with Bleachbit";
|
||||
dates = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
How often or when cleanup will occur. For most cases, it should be enough to clean it up once per month.
|
||||
|
||||
See systemd.time(7) to see the date format.
|
||||
'';
|
||||
default = "monthly";
|
||||
example = "Fri 10:00:00";
|
||||
};
|
||||
|
||||
persistent = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
description =
|
||||
"Whether to enable persistence for the cleanup, allowing it to activate the next time it boots when missed.";
|
||||
default = true;
|
||||
example = false;
|
||||
};
|
||||
|
||||
cleaners = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
description = "List of cleaners to be used when cleaning.";
|
||||
default = [
|
||||
"bash.history"
|
||||
"winetricks.temporary-files"
|
||||
"wine.tmp"
|
||||
"brave.history"
|
||||
"brave.form_history"
|
||||
"brave.passwords"
|
||||
"chromium.form_history"
|
||||
"chromium.history"
|
||||
"chromium.passwords"
|
||||
"discord.history"
|
||||
"epiphany.passwords"
|
||||
"firefox.forms"
|
||||
"firefox.passwords"
|
||||
"firefox.url_history"
|
||||
"google_chrome.form_history"
|
||||
"google_chrome.history"
|
||||
"google_earth.temporary_files"
|
||||
"google_toolbar.search_history"
|
||||
"palemoon.forms"
|
||||
"palemoon.passwords"
|
||||
"palemoon.url_history"
|
||||
"thumbnails.cache"
|
||||
"waterfox.forms"
|
||||
"waterfox.passwords"
|
||||
"waterfox.url_history"
|
||||
"zoom.logs"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.user = {
|
||||
services = {
|
||||
hm-bleachbit-cleanup = {
|
||||
Unit = {
|
||||
Description = "Monthly cleanup with Bleachbit";
|
||||
Documentation = [ "man:bleachbit(1)" "https://www.bleachbit.org" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
Restart = "on-failure";
|
||||
ExecStart = "${pkgs.bleachbit}/bin/bleachbit --clean ${
|
||||
lib.concatStringsSep " " cfg.cleaners
|
||||
}";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
timers = {
|
||||
hm-bleachbit-cleanup = {
|
||||
Unit = {
|
||||
Description = "Periodic clean with Bleachbit";
|
||||
Documentation = [ "man:bleachbit(1)" "https://www.bleachbit.org" ];
|
||||
};
|
||||
|
||||
Timer = {
|
||||
OnCalendar = cfg.dates;
|
||||
Persistent = cfg.persistent;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
77
modules/nixos/hardware-setup/backup-archive.nix
Normal file
77
modules/nixos/hardware-setup/backup-archive.nix
Normal file
@ -0,0 +1,77 @@
|
||||
# This is my external hard drive.
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
# TODO: Make this a generic service.
|
||||
# There are multiple external storage drives now.
|
||||
let
|
||||
cfg = config.modules.hardware-setup.backup-archive;
|
||||
in {
|
||||
options.modules.hardware-setup.backup-archive.enable = lib.mkEnableOption "external hard drive and automated backup service with BorgBackup";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [{
|
||||
assertion = config.modules.agenix.enable;
|
||||
message = "Agenix module is not enabled.";
|
||||
}];
|
||||
|
||||
age.secrets.archive-password.file = ../../../secrets/archive/password;
|
||||
fileSystems."/mnt/external-storage" = {
|
||||
device = "/dev/disk/by-uuid/665A391C5A38EB07";
|
||||
fsType = "ntfs";
|
||||
noCheck = true;
|
||||
options = [
|
||||
"nofail"
|
||||
"noauto"
|
||||
"user"
|
||||
|
||||
# See systemd.mount.5 and systemd.automount.5 manual page for more
|
||||
# details.
|
||||
"x-systemd.automount"
|
||||
"x-systemd.device-timeout=2"
|
||||
"x-systemd.idle-timeout=2"
|
||||
];
|
||||
};
|
||||
|
||||
services.borgbackup.jobs.external-storage = {
|
||||
dateFormat = "%F-%H-%M-%S-%z";
|
||||
doInit = false;
|
||||
removableDevice = true;
|
||||
paths = [
|
||||
"/home/*/.config/environment.d"
|
||||
"/home/*/.config/systemd"
|
||||
"/home/*/.gnupg"
|
||||
"/home/*/.password-store"
|
||||
"/home/*/.ssh"
|
||||
"/home/*/.thunderbird"
|
||||
"/home/*/dotfiles"
|
||||
"/home/*/library"
|
||||
];
|
||||
exclude = [
|
||||
"*/.cache"
|
||||
"*.pyc"
|
||||
"*/node_modules"
|
||||
"*/.next"
|
||||
"*/result"
|
||||
"projects/software/*/build"
|
||||
"projects/software/*/target"
|
||||
];
|
||||
repo = "/mnt/external-storage/backups";
|
||||
encryption = {
|
||||
mode = "repokey";
|
||||
passCommand = "cat ${config.age.secrets.archive-password.path}";
|
||||
};
|
||||
compression = "lz4";
|
||||
prune = {
|
||||
prefix = "{hostname}-";
|
||||
keep = {
|
||||
within = "1w"; # Keep all archives from the last week.
|
||||
daily = 30;
|
||||
weekly = 4;
|
||||
monthly = -1; # Keep at least one archive for each month.
|
||||
yearly = 3;
|
||||
};
|
||||
};
|
||||
startAt = "04/8:00:00"; # Every 8 hours starting at 04:00.
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user