{ config, lib, pkgs, ... }: let inherit (lib) mkEnableOption mkOption mkPackageOption mkIf types; cfg = config.programs.resticprofile; yamlFormat = pkgs.formats.yaml { }; in { options.programs.resticprofile = { enable = mkEnableOption "Enable resticprofile (Restic backup profile manager)"; package = mkPackageOption pkgs "resticprofile" { }; # Config structured as an attrset that maps to resticprofile's YAML format config = mkOption { type = yamlFormat.type; default = { }; description = '' Configuration for resticprofile, which will be written as YAML to `$XDG_CONFIG_HOME/resticprofile/profiles.yaml`. ''; example = { repository = "local:/backup"; passwordFile = "password.txt"; backup = { source = [ "/home/user/Documents" ]; schedule = "12:30"; }; }; }; configFile = mkOption { type = types.str; default = "profiles.yaml"; description = "The configuration file name under $XDG_CONFIG_HOME/resticprofile/"; }; }; config = mkIf cfg.enable { home.packages = [ cfg.package ]; xdg.configFile."resticprofile/${cfg.configFile}".source = yamlFormat.generate "resticprofile-config" cfg.config; }; }