{ config, lib, pkgs, ... }: let cfg = config.programs.keepassxc; iniFormat = pkgs.formats.ini { }; in { meta.maintainers = [ lib.maintainers.d-brasher ]; options.programs.keepassxc = { enable = lib.mkEnableOption "keepassxc"; package = lib.mkPackageOption pkgs "keepassxc" { }; settings = lib.mkOption { type = iniFormat.type; default = { }; example = lib.literalExpression '' { Browser.Enabled = true; GUI = { AdvancedSettings = true; ApplicationTheme = "dark"; CompactMode = true; HidePasswords = true; }; SSHAgent.Enabled = true; } ''; description = '' Configuration written to {file}`$XDG_CONFIG_HOME/keepassxc/keepassxc.ini`. See for the full list of options. ''; }; }; config = lib.mkIf cfg.enable { home.packages = [ cfg.package ]; xdg.configFile = { "keepassxc/keepassxc.ini" = lib.mkIf (cfg.settings != { }) { source = iniFormat.generate "keepassxc-settings" cfg.settings; }; }; }; }