mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
zsh: fix history.path issues
- Default value is set to static '$HOME/.zsh_history' -- dotDir is not prepended anymore - $HOME is not prepended to the option value - Ensure history path directory exists Fixes #886, replaces #427.
This commit is contained in:
parent
05dabb7239
commit
4505710565
8 changed files with 120 additions and 4 deletions
|
@ -18,4 +18,8 @@ The state version in this release includes the changes below. These
|
|||
changes are only active if the `home.stateVersion` option is set to
|
||||
"20.03" or later.
|
||||
|
||||
* Nothing has happened.
|
||||
* The <<opt-programs.zsh.history.path>> option is no longer prepended
|
||||
by `$HOME`, which allows specifying absolute paths, for example,
|
||||
using the xdg module. Also, the default value is fixed to
|
||||
`$HOME/.zsh_history` and `dotDir` path is not prepended to it
|
||||
anymore.
|
||||
|
|
|
@ -1214,6 +1214,21 @@ in
|
|||
A new module is available: 'programs.pazi'.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2019-11-05T21:54:04+00:00";
|
||||
condition = config.programs.zsh.enable;
|
||||
message = ''
|
||||
The 'programs.zsh.history.path' option behavior and the
|
||||
default value has changed for state version 20.03 and above.
|
||||
|
||||
Specifically, '$HOME' will no longer be prepended to the
|
||||
option value, which allows specifying absolute paths (e.g.
|
||||
using the xdg module). Also, the default value is fixed to
|
||||
'$HOME/.zsh_history' and 'dotDir' path is not prepended to
|
||||
it anymore.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ let
|
|||
vicmd = "bindkey -a";
|
||||
};
|
||||
|
||||
stateVersion = config.home.stateVersion;
|
||||
|
||||
historyModule = types.submodule ({ config, ... }: {
|
||||
options = {
|
||||
size = mkOption {
|
||||
|
@ -43,8 +45,10 @@ let
|
|||
|
||||
path = mkOption {
|
||||
type = types.str;
|
||||
default = relToDotDir ".zsh_history";
|
||||
defaultText = ".zsh_history";
|
||||
default = if versionAtLeast stateVersion "20.03"
|
||||
then "$HOME/.zsh_history"
|
||||
else relToDotDir ".zsh_history";
|
||||
example = literalExample ''"''${config.xdg.dataHome}/zsh/zsh_history"'';
|
||||
description = "History file location";
|
||||
};
|
||||
|
||||
|
@ -402,8 +406,11 @@ in
|
|||
# History options should be set in .zshrc and after oh-my-zsh sourcing.
|
||||
# See https://github.com/rycee/home-manager/issues/177.
|
||||
HISTSIZE="${toString cfg.history.size}"
|
||||
HISTFILE="$HOME/${cfg.history.path}"
|
||||
SAVEHIST="${toString cfg.history.save}"
|
||||
${if versionAtLeast config.home.stateVersion "20.03"
|
||||
then ''HISTFILE="${cfg.history.path}"''
|
||||
else ''HISTFILE="$HOME/${cfg.history.path}"''}
|
||||
mkdir -p "$(dirname "$HISTFILE")"
|
||||
|
||||
setopt HIST_FCNTL_LOCK
|
||||
${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
{
|
||||
zsh-session-variables = ./session-variables.nix;
|
||||
zsh-history-path-new-default = ./history-path-new-default.nix;
|
||||
zsh-history-path-new-custom = ./history-path-new-custom.nix;
|
||||
zsh-history-path-old-default = ./history-path-old-default.nix;
|
||||
zsh-history-path-old-custom = ./history-path-old-custom.nix;
|
||||
}
|
||||
|
|
23
tests/modules/programs/zsh/history-path-new-custom.nix
Normal file
23
tests/modules/programs/zsh/history-path-new-custom.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
home.stateVersion = "20.03";
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
history.path = "$HOME/some/directory/zsh_history";
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(self: super: {
|
||||
zsh = pkgs.writeScriptBin "dummy-zsh" "";
|
||||
})
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/some/directory/zsh_history"$'
|
||||
'';
|
||||
};
|
||||
}
|
20
tests/modules/programs/zsh/history-path-new-default.nix
Normal file
20
tests/modules/programs/zsh/history-path-new-default.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
home.stateVersion = "20.03";
|
||||
programs.zsh.enable = true;
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(self: super: {
|
||||
zsh = pkgs.writeScriptBin "dummy-zsh" "";
|
||||
})
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/.zsh_history"$'
|
||||
'';
|
||||
};
|
||||
}
|
23
tests/modules/programs/zsh/history-path-old-custom.nix
Normal file
23
tests/modules/programs/zsh/history-path-old-custom.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
home.stateVersion = "19.09";
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
history.path = "some/directory/zsh_history";
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(self: super: {
|
||||
zsh = pkgs.writeScriptBin "dummy-zsh" "";
|
||||
})
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/some/directory/zsh_history"$'
|
||||
'';
|
||||
};
|
||||
}
|
20
tests/modules/programs/zsh/history-path-old-default.nix
Normal file
20
tests/modules/programs/zsh/history-path-old-default.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
home.stateVersion = "19.03";
|
||||
programs.zsh.enable = true;
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(self: super: {
|
||||
zsh = pkgs.writeScriptBin "dummy-zsh" "";
|
||||
})
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/.zsh_history"$'
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue