Skip to content

Commit

Permalink
zsh: rename initContents to initExtra in zsh module
Browse files Browse the repository at this point in the history
- Renamed `initContents` to `initExtra` for consistency and clarity
- Updated related test files to reflect the change
- Added a new test file `zshrc-contents-insert.nix` to ensure proper
functionality

Signed-off-by: Qiming Chu <[email protected]>
  • Loading branch information
Emin017 committed Mar 5, 2025
1 parent 472e79e commit 776daea
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
6 changes: 2 additions & 4 deletions modules/programs/zsh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ in
++ optional cfg.enableCompletion pkgs.nix-zsh-completions
++ optional cfg.oh-my-zsh.enable cfg.oh-my-zsh.package;

programs.zsh.initContents = mkMerge [
programs.zsh.initExtra = mkMerge [
# zprof must be loaded before everything else, since it
# benchmarks the shell initialization.
(mkOrder 500 (optionalString cfg.zprof.enable ''
Expand Down Expand Up @@ -727,8 +727,6 @@ in
${if cfg.autocd != null then "${if cfg.autocd then "setopt" else "unsetopt"} autocd" else ""}
'')

(mkOrder 1200 cfg.initExtra)

# Aliases
(mkOrder 1250 aliasesStr)
(mkOrder 1250 (concatStringsSep "\n" (mapAttrsToList
Expand Down Expand Up @@ -777,7 +775,7 @@ in
''))
];

home.file."${relToDotDir ".zshrc"}".text = cfg.initContents;
home.file."${relToDotDir ".zshrc"}".text = cfg.initExtra;
}

(mkIf cfg.oh-my-zsh.enable {
Expand Down
1 change: 1 addition & 0 deletions tests/modules/programs/zsh/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
zsh-prezto = ./prezto.nix;
zsh-syntax-highlighting = ./syntax-highlighting.nix;
zsh-abbr = ./zsh-abbr.nix;
zshrc-contents-insert = ./zshrc-contents-insert.nix;
zshrc-contents-insert-before = ./zshrc-contents-insert-before.nix;
zshrc-contents-insert-after = ./zshrc-contents-insert-after.nix;
}
2 changes: 1 addition & 1 deletion tests/modules/programs/zsh/zshrc-contents-insert-after.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ lib, ... }: {
programs.zsh = {
enable = true;
initContents = lib.mkAfter ''
initExtra = lib.mkAfter ''
# Custom contents
echo "Custom contents"
'';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ lib, ... }: {
programs.zsh = {
enable = true;
initContents = lib.mkBefore ''
initExtra = lib.mkBefore ''
# Custom contents
echo "Custom contents"
'';
Expand Down
13 changes: 13 additions & 0 deletions tests/modules/programs/zsh/zshrc-contents-insert.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
programs.zsh = {
enable = true;
initExtra = ''
# Custom contents
echo "Custom contents"
'';
};

nmt.script = ''
assertFileContains home-files/.zshrc $'# Custom contents\necho "Custom contents"'
'';
}

0 comments on commit 776daea

Please sign in to comment.