diff --git a/nix/hm-module.nix b/nix/hm-module.nix index b0a6359..21bbc9c 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -21,6 +21,12 @@ in { default = {}; description = "Restray backup profiles."; }; + + gui = lib.mkOption { + type = lib.types.submodule shared.guiOpts; + default = {}; + description = "GUI-only settings, ignored by restray daemon."; + }; }; options.services.restray.enable = lib.mkEnableOption "Restray backup scheduler daemon"; @@ -32,7 +38,7 @@ in { (lib.mkIf cfg.enable { home.packages = [cfg.package]; - home.file."${configDir}/config.toml".source = shared.configFile cfg.profiles; + home.file."${configDir}/config.toml".source = shared.configFile cfg.profiles cfg.gui; }) (lib.mkIf (daemon.enable && cfg.enable) { diff --git a/nix/nixos-module.nix b/nix/nixos-module.nix index f18eb50..78e9ac0 100644 --- a/nix/nixos-module.nix +++ b/nix/nixos-module.nix @@ -16,6 +16,12 @@ in { default = {}; description = "Restray backup profiles."; }; + + gui = lib.mkOption { + type = lib.types.submodule shared.guiOpts; + default = {}; + description = "GUI-only settings, ignored by restray daemon."; + }; }; config = lib.mkIf cfg.enable { @@ -43,6 +49,6 @@ in { }; }; - environment.etc."restray/config.toml".source = shared.configFile cfg.profiles; + environment.etc."restray/config.toml".source = shared.configFile cfg.profiles cfg.gui; }; } diff --git a/nix/shared.nix b/nix/shared.nix index 392765e..cef77fe 100644 --- a/nix/shared.nix +++ b/nix/shared.nix @@ -2,6 +2,41 @@ lib, pkgs, }: let + guiOpts = { + options = { + checkUpdates = lib.mkOption { + type = lib.types.bool; + default = true; + description = "MacOS/Windows only. Check for new Restray versions on startup and periodically. When an update is found, the version item in the menu changes to an update button"; + }; + manageRestic = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Windows only. If restic is not found in PATH, automatically downloads and updates a self-managed restic binary daily from GitHub."; + }; + notifications = lib.mkOption { + type = lib.types.str; + default = "none"; + description = ''"all" (success + errors), "errors" (errors only), or "none" (silent)''; + }; + icon = lib.mkOption { + type = lib.types.str; + default = ""; + description = ''"color", "mono", "white", or "black". Default is "mono" on MacOS/Windows and "color" elsewhere. "mono" follows OS light/dark mode.''; + }; + scheduleDisplay = lib.mkOption { + type = lib.types.str; + default = "description"; + description = ''"description" (human-readable, e.g. "every 6 hours"), "cron" (raw expression, e.g. "0 * * * *"), "last" (time since last backup, e.g. "2 hours ago"), or "none"''; + }; + terminal = lib.mkOption { + type = lib.types.str; + default = ""; + description = ''Terminal emulator used in "Shell" and "View Log". If unset, MacOS will use Terminal.app. Linux will use default. Not used on Windows. e.g. "Ghostty"''; + }; + }; + }; + profileOpts = {name, ...}: { options = { name = lib.mkOption { @@ -140,12 +175,23 @@ mount.args = prof.mount.args; }; + guiToToml = gui: + lib.filterAttrsRecursive (_: v: v != null && v != [] && v != "") { + check_updates = gui.checkUpdates; + manage_restic = gui.manageRestic; + notifications = gui.notifications; + icon = gui.icon; + schedule_display = gui.scheduleDisplay; + terminal = gui.terminal; + }; + toml = pkgs.formats.toml {}; - configFile = profiles: + configFile = profiles: gui: toml.generate "restray-config.toml" { profiles = lib.mapAttrsToList profileToToml profiles; + gui = guiToToml gui; }; in { - inherit profileOpts configFile; + inherit profileOpts guiOpts configFile; }