Zsh zplug powerlevel10k ~/.zshrc is readonly

The problem

I am following the example in https://nixos.wiki/wiki/Zsh for zsh configured using Home Manager. The example uses zplug to configure powerlevel10k for repeated use. The p10k configuration cannot be saved because ~/.zshrc is a read-only link.

Steps to reproduce

My configuration.nix and home.nix build fine. When I open a terminal after adding the zplug example, the zsh shell tries to do a p10k configure, which runs perfectly until it tries to save the updates to ~/.zshrc

~/.zshrc is read-only, and is a symbolic link to /nix/store/bi54nzg6fwr44jby9j9bpzmg870sb7j2-home-manager-files/.zshrc
So how is p110k supposed to save my configuration? Why isn’t the example running as expected?

Happy to post my configuration if needed. I am following the example closely.


My environment

I am in a standalone VMware VM running NixOS with desktop from the full ISO,

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.38, NixOS, 23.05 (Stoat), 23.05.1875.8df7a67abaf`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - channels(root): `"home-manager-23.05.tar.gz, nixos-23.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

If have this in my zsh config and it works greate:

{ pkgs, ... }:
  programs.zsh = {
    initExtra = ''
      [[ ! -f ${./p10k.zsh;} ]] || source ${./p10k.zsh}
    plugins = [
        name = "powerlevel10k";
        src = pkgs.zsh-powerlevel10k;
        file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";

you can put the p10k theme config in the same folder as your home-manager config and link it with the let binding described above

I also have this in my NixOS host config:

  fonts.fonts = with pkgs; [

p10k is not supposed to save to your shells RC file directly, and when I updated p10k for the last time, it happily suggested to manually add some commands to my zshrc, as it was RO.

You could follow that advice using HMs programs.zsh.extraInit or so like Janik does.

Alternatively you can put everything in zsh-plugins, as I do:

Here p10k-config is a folder beside the nix file which contains nothing but the p10k.zsh.

For me this approach works well.


Thanks very much!
I used to work with the ENVY/Manager Smalltalk system 30 years ago. It was a very powerful configuration management system with an immutable model. It worked very much like nix does. Enjoying nix very much…

Thanks for your help!
It makes complete sense that RC files are immutable. It’s a bit of a problem that the Home Manager example from the wiki ignores how to deal with that. It’s a very good use-case - just needs to be fully worked. I don’t know enough yet to update any documentation.

Doesn’t deal with what exactly?

It mentions Zplug, OMZ and manual plugin management.

Remembering I’ve only got a few hours on NixOS…

Yes, the page does cover zsh in the context of Home Manager.
I was stumped because I didn’t understand how fix a plugin that insists on writing to ~/.zshrc. Given that example is from the wiki page, it would be nice if it mentioned this difficulty, and suggested a resource to learn how to fix it.

Plugins monkeying with configuration files should be a frequent problem, so I think it’s something to learn how to deal with early. I may be struggling with something obvious to someone with more NixOS experience.

Thanks again…