2021-12-11 05:31:28 +00:00
|
|
|
{ config, options, lib, pkgs, ... }:
|
|
|
|
|
2022-04-03 02:20:54 +00:00
|
|
|
let
|
|
|
|
cfg = config.services.bleachbit;
|
|
|
|
|
|
|
|
cleaners = cfg.cleaners ++ lib.optionals cfg.withBrowserCleanup [
|
|
|
|
"brave.cache"
|
|
|
|
"brave.form_history"
|
|
|
|
"brave.history"
|
|
|
|
"brave.passwords"
|
|
|
|
"chromium.cache"
|
|
|
|
"chromium.form_history"
|
|
|
|
"chromium.history"
|
|
|
|
"chromium.passwords"
|
|
|
|
"epiphany.cache"
|
|
|
|
"epiphany.passwords"
|
|
|
|
"firefox.cache"
|
|
|
|
"firefox.forms"
|
|
|
|
"firefox.passwords"
|
|
|
|
"firefox.url_history"
|
|
|
|
"google_chrome.cache"
|
|
|
|
"google_chrome.form_history"
|
|
|
|
"google_chrome.history"
|
|
|
|
"opera.cache"
|
|
|
|
"opera.form_history"
|
|
|
|
"opera.history"
|
|
|
|
"palemoon.cache"
|
|
|
|
"palemoon.forms"
|
|
|
|
"palemoon.passwords"
|
|
|
|
"palemoon.url_history"
|
|
|
|
"waterfox.cache"
|
|
|
|
"waterfox.forms"
|
|
|
|
"waterfox.passwords"
|
|
|
|
"waterfox.url_history"
|
|
|
|
] ++ lib.optionals cfg.withChatCleanup [
|
|
|
|
"discord.cache"
|
|
|
|
"discord.history"
|
|
|
|
"skype.chat_logs"
|
|
|
|
"skype.installers"
|
|
|
|
"slack.cache"
|
|
|
|
"slack.cookies"
|
|
|
|
"slack.history"
|
|
|
|
"slack.vacuum"
|
|
|
|
"thunderbird.cache"
|
|
|
|
"thunderbird.cookies"
|
|
|
|
"thunderbird.index"
|
|
|
|
"thunderbird.passwords"
|
|
|
|
"thunderbird.sessionjson"
|
|
|
|
];
|
2022-11-19 03:05:31 +00:00
|
|
|
in
|
|
|
|
{
|
2022-01-09 05:38:59 +00:00
|
|
|
options.services.bleachbit = {
|
2021-12-11 05:31:28 +00:00
|
|
|
enable = lib.mkEnableOption "automated cleanup with Bleachbit";
|
2022-01-02 01:28:28 +00:00
|
|
|
startAt = lib.mkOption {
|
2021-12-11 05:31:28 +00:00
|
|
|
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";
|
|
|
|
};
|
|
|
|
|
2022-11-12 21:55:59 +00:00
|
|
|
package = lib.mkOption {
|
|
|
|
type = lib.types.package;
|
|
|
|
description = ''
|
|
|
|
The derivation containing <literal>bleachbit</literal> executable.
|
|
|
|
'';
|
|
|
|
default = pkgs.bleachbit;
|
|
|
|
};
|
|
|
|
|
2021-12-11 05:31:28 +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;
|
2022-02-02 04:25:03 +00:00
|
|
|
defaultText = "true";
|
2021-12-11 05:31:28 +00:00
|
|
|
example = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
cleaners = lib.mkOption {
|
|
|
|
type = with lib.types; listOf str;
|
|
|
|
description = "List of cleaners to be used when cleaning.";
|
2022-11-19 03:05:31 +00:00
|
|
|
default = [ ];
|
2022-10-11 23:02:24 +00:00
|
|
|
example = lib.literalExpression ''
|
|
|
|
[
|
|
|
|
"bash.history"
|
|
|
|
"winetricks.temporary_files"
|
|
|
|
"wine.tmp"
|
|
|
|
"discord.history"
|
|
|
|
"google_earth.temporary_files"
|
|
|
|
"google_toolbar.search_history"
|
|
|
|
"thumbnails.cache"
|
|
|
|
"zoom.logs"
|
|
|
|
]
|
|
|
|
'';
|
2021-12-11 05:31:28 +00:00
|
|
|
};
|
2022-01-02 01:28:28 +00:00
|
|
|
|
2022-01-11 12:22:08 +00:00
|
|
|
withBrowserCleanup =
|
|
|
|
lib.mkEnableOption "browser-related cleaners to be included in the list";
|
2022-04-03 02:20:54 +00:00
|
|
|
|
|
|
|
withChatCleanup =
|
|
|
|
lib.mkEnableOption "communication apps-related cleaners to be included";
|
2021-12-11 05:31:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2023-02-11 01:16:32 +00:00
|
|
|
systemd.user.services.bleachbit = {
|
2022-11-12 21:57:09 +00:00
|
|
|
Unit = {
|
|
|
|
Description = "Periodic cleaning with Bleachbit";
|
|
|
|
Documentation = [ "man:bleachbit(1)" "https://www.bleachbit.org" ];
|
2021-12-11 05:31:28 +00:00
|
|
|
};
|
|
|
|
|
2022-11-12 21:57:09 +00:00
|
|
|
Service.ExecStart = ''
|
2022-11-19 03:05:31 +00:00
|
|
|
${cfg.package}/bin/bleachbit --clean ${lib.escapeShellArgs cleaners}
|
2022-11-12 21:57:09 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-02-11 01:16:32 +00:00
|
|
|
systemd.user.timers.bleachbit = {
|
2022-11-12 21:57:09 +00:00
|
|
|
Unit = {
|
|
|
|
Description = "Periodic cleaning with Bleachbit";
|
|
|
|
Documentation = [ "man:bleachbit(1)" "https://www.bleachbit.org" ];
|
|
|
|
PartOf = [ "default.target" ];
|
|
|
|
};
|
2021-12-11 05:31:28 +00:00
|
|
|
|
2022-11-12 21:57:09 +00:00
|
|
|
Install.WantedBy = [ "timers.target" ];
|
2021-12-19 09:37:47 +00:00
|
|
|
|
2022-11-12 21:57:09 +00:00
|
|
|
Timer = {
|
|
|
|
OnCalendar = cfg.startAt;
|
|
|
|
Persistent = cfg.persistent;
|
2021-12-11 05:31:28 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|