programs.zsh.ohMyZsh explained

Hi there… I’m new to NixOS and I’m setup my configuration.nix file.
I have a question about the option programs.zsh.ohMyZsh.
Here’s a snippet from my configuration.

  # Enable zsh
  programs.zsh.enable = true;

  # Enable Oh-my-zsh
  programs.zsh.ohMyZsh = {
    enable = true;
    plugins = [ "git" "sudo" "docker" "kubectl" ];

I get that ohMyZsh will be installed and located at $ZSH, but what about the plugis? I cant figure out the idea behind it. Also, whats the point in installing the package?
Its not like the users created will get an .zshrc file in their home dir.
What good is the plugins line?

I just want Oh my zsh to be a standard thing. :slight_smile:

I believe if you set it up this way, Nix installs an etc/zshrc that, among other things, sources oh-my-zsh and sets up the configured plugins. So it’ll be set up globally.

You can set zsh as the default shell for your user via users.users.<name?>.shell. The nix derivation for ZSH also comes with many options.

Home-Manager also has many options to configure zsh (although I haven’t tried then yet).

@lilyball Nope… Nothing in /etc/z*

@Aeschylus Yes, I should have posted my user part as well.

  users = { 
    mutableUsers = true;
    defaultUserShell = pkgs.zsh; # Make zsh default shell
    users = {
      kerwood = { # Change your username here
        isNormalUser = true;
        extraGroups = [ "wheel" "networkmanager" "docker" ];
        initialPassword = "password"; # Initial password, remember to change after first boot.

But that doesn’t really solve my issue.

From the source e.g. nixpkgs/oh-my-zsh.nix at 0943e4adc630017918c6cdac6b6632822d9cf44d · NixOS/nixpkgs · GitHub it looks like it should be automatically loaded as it sets programs.zsh.interactiveShellInit. Normally it is somewhere in /etc.

Oh yeah…

lrwxrwxrwx 1 root root   17 Apr 20 12:45 zshrc -> /etc/static/zshrc

So… how does a user with no .zshrc file in their home dir, source that file and “activate” Oh my zsh ?

They don’t, the shell does it automatically. When zsh is run in interactive mode it always reads /etc/zshrc (or I guess /etc/static/zshrc in this case) prior to reading ~/.zshrc. Same thing for login shells and zprofile / zlogin.

I know this topic is old but here is a basic example without using homemanager:

    programs = {
      zsh = {
        enable = true;
        ohMyZsh = {
          enable = true;
          theme = "robbyrussell";
          plugins = [
    }; = {
      isNormalUser = true;
      description = "My User";
      extraGroups = [ "networkmanager" "wheel" ];
      shell = pkgs.zsh;
      openssh.authorizedKeys.keys = [ "SSHKEY" ];
      packages = with pkgs; [

1 Like