mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-10 02:51:05 +01:00
zsh: refactor zsh configuration for better order control over .zshrc (#6479)
* zsh: add initContent option for custom .zshrc content insertion - Users can add content anywhere by using `lib.mkOrder`, `lib.mkBefore` and `lib.mkAfter` custom configurations. - Add test cases to verify the insertion of content before and after existing configurations in `.zshrc`. consolidate zshrc content tests into a single priorities test
This commit is contained in:
parent
1878091234
commit
7832b5aa95
4 changed files with 177 additions and 117 deletions
|
|
@ -9,4 +9,5 @@
|
|||
zsh-prezto = ./prezto.nix;
|
||||
zsh-syntax-highlighting = ./syntax-highlighting.nix;
|
||||
zsh-abbr = ./zsh-abbr.nix;
|
||||
zshrc-contents-priorities = ./zshrc-content-priorities.nix;
|
||||
}
|
||||
|
|
|
|||
36
tests/modules/programs/zsh/zshrc-content-priorities.nix
Normal file
36
tests/modules/programs/zsh/zshrc-content-priorities.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{ lib, ... }: {
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
|
||||
initContent = lib.mkMerge [
|
||||
(lib.mkBefore ''
|
||||
# High priority (mkBefore)
|
||||
echo "High priority content"
|
||||
'')
|
||||
|
||||
(lib.mkAfter ''
|
||||
# Low priority (mkAfter)
|
||||
echo "Low priority content"
|
||||
'')
|
||||
|
||||
''
|
||||
# Default priority
|
||||
echo "Default priority content"
|
||||
''
|
||||
];
|
||||
|
||||
zprof.enable = true;
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.zshrc
|
||||
|
||||
assertFileContains home-files/.zshrc "zmodload zsh/zprof"
|
||||
assertFileContains home-files/.zshrc "High priority content"
|
||||
assertFileContains home-files/.zshrc "Default priority content"
|
||||
assertFileContains home-files/.zshrc "Low priority content"
|
||||
|
||||
assertFileRegex home-files/.zshrc '^zmodload zsh/zprof'
|
||||
assertFileRegex home-files/.zshrc 'echo "Low priority content"$'
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue