{ config, lib, ... }: let cfg = config.my.defaults; mkCmdOption = description: lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; inherit description; }; in { options.my.defaults = { terminal = mkCmdOption "Command for the default terminal ($TERMINAL)."; browser = mkCmdOption "Command for the default browser ($BROWSER)."; editor = mkCmdOption "Command for the default editor ($EDITOR and $VISUAL)."; }; config.home.sessionVariables = lib.mkMerge [ (lib.mkIf (cfg.terminal != null) { TERMINAL = cfg.terminal; }) (lib.mkIf (cfg.browser != null) { BROWSER = cfg.browser; }) (lib.mkIf (cfg.editor != null) { EDITOR = cfg.editor; VISUAL = cfg.editor; }) ]; }