diff --git a/modules/programs/zsh/history.nix b/modules/programs/zsh/history.nix index 3b766d62b5c3..28dc9f80963d 100644 --- a/modules/programs/zsh/history.nix +++ b/modules/programs/zsh/history.nix @@ -18,6 +18,12 @@ in { config, ... }: { options = { + enableConfig = lib.mkOption { + type = types.bool; + default = true; + description = "let home-manager configure history settings"; + }; + append = mkOption { type = types.bool; default = false; @@ -170,7 +176,7 @@ in }; }; - config = { + config = lib.mkIf cfg.history.enableConfig { warnings = lib.optionals (!lib.hasPrefix "/" cfg.history.path && !lib.hasInfix "$" cfg.history.path) [ diff --git a/tests/modules/programs/zsh/default.nix b/tests/modules/programs/zsh/default.nix index b1b090b057a6..3b712932261b 100644 --- a/tests/modules/programs/zsh/default.nix +++ b/tests/modules/programs/zsh/default.nix @@ -5,6 +5,7 @@ zsh-dotdir-default = import ./dotdir.nix "default"; zsh-dotdir-relative = import ./dotdir.nix "relative"; zsh-dotdir-shell-variable = import ./dotdir.nix "shell-variable"; + zsh-history-disable-config = ./history-disable-config.nix; zsh-history-ignore-pattern = ./history-ignore-pattern.nix; zsh-history-path-absolute = import ./history-path.nix "absolute"; zsh-history-path-default = import ./history-path.nix "default"; diff --git a/tests/modules/programs/zsh/history-disable-config.nix b/tests/modules/programs/zsh/history-disable-config.nix new file mode 100644 index 000000000000..ddc44cfbabec --- /dev/null +++ b/tests/modules/programs/zsh/history-disable-config.nix @@ -0,0 +1,10 @@ +{ + programs.zsh = { + enable = true; + history.enableConfig = false; + }; + + nmt.script = '' + assertFileNotRegex home-files/.zshrc "setopt HIST_.*" + ''; +}