Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] programs.zsh.promptInit required for powerlevel10k ? #1338

Closed
PierreR opened this issue Jun 17, 2020 · 4 comments
Closed

[Question] programs.zsh.promptInit required for powerlevel10k ? #1338

PierreR opened this issue Jun 17, 2020 · 4 comments

Comments

@PierreR
Copy link

PierreR commented Jun 17, 2020

Issue description

I am trying to install powerlevel10k with the home-manager. But this snippet does not seem to work:

  config = {
    programs.zsh = {
      enable = cfg.enable;
      oh-my-zsh.enable = true;
      oh-my-zsh.custom = "$HOME/.zsh_custom";
      oh-my-zsh.theme = "${cfg.zshTheme}";
      initExtra = ''
        [ "${cfg.zshTheme}"  == "powerlevel10k" ] && source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme
     '';
    };
  };

The error I have:

/nix/store/m6gvpz4n02svmc1vi8p07pzslaygrwq5-oh-my-zsh-2020-02-07/share/oh-my-zsh/oh-my-zsh.sh:source:118: no such file or directory: /nix/store/m6gvpz4n02svmc1vi8p07pzslaygrwq5-oh-my-zsh-2020-02-07/share/oh-my-zsh/themes/powerlevel10k.zsh-theme

Meta

zsh module

Maintainer CC

@carlostome
@rycee @uvNikita

Technical details

The nixpkgs derivation suggests to use programs.zsh.promptInit but it does not seems to be exposed in the zsh module of the home-manager.
I haven't found much help on the web:
https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/

Thanks for your help.

@PierreR PierreR changed the title programs.zsh.promptInit for powerlevel10k [Question] programs.zsh.promptInit required for powerlevel10k ? Jun 17, 2020
@PierreR
Copy link
Author

PierreR commented Jun 17, 2020

Would zplug be a better option to install powerlevel10k ?

@06kellyjac
Copy link
Contributor

Here's a pretty bare-bones version of my config that works

{ config, pkgs, ... }:

{
  programs.zsh = {
    enable = true;
    enableAutosuggestions = true;
    dotDir = ".config/zsh"; # Already prepends $HOME

    initExtraBeforeCompInit = ''
      # p10k instant prompt
      local P10K_INSTANT_PROMPT="${config.xdg.cacheHome}/p10k-instant-prompt-''${(%):-%n}.zsh"
      [[ ! -r "$P10K_INSTANT_PROMPT" ]] || source "$P10K_INSTANT_PROMPT"
    '';

    plugins = with pkgs; [
      {
        file = "powerlevel10k.zsh-theme";
        name = "powerlevel10k";
        src = "${zsh-powerlevel10k}/share/zsh-powerlevel10k";
      }
      {
        file = "p10k.zsh";
        name = "powerlevel10k-config";
        src = ../config/zsh/p10k; # Some directory containing your p10k.zsh file
      }
    ];

    initExtra = ''
      # blah blah
    '';
  };
}

Whenever I want to run p10k configure again I make sure to unset POWERLEVEL9K_CONFIG_FILE so it dumps it in ~/.config/zsh/p10k.zsh or point it somewhere else as by default it'll try overwriting the config I've put in the plugins which goes in the nix store so it's Read Only.
Or you could just avoid the plugin/derivation method and add source ./some/location/p10k.zsh in your initExtra and p10k configure can continue to overwrite it.

I'm considering making a home-manager module for configuring p10k similar to the emacs init.d module @rycee has in a GitLab repo but it's a pretty big undertaking, lots of settings.

@nrdsp
Copy link

nrdsp commented Jul 11, 2020

Appending the following line alone seems to work in my case (after declaring zsh in the packages = with pkgs module):

initExtra = "source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme";

@stale
Copy link

stale bot commented Apr 29, 2021

Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

If you have nothing of substance to add, please refrain from commenting and allow the bot close the issue. Also, don't be afraid to manually close an issue, even if it holds valuable information.

Closed issues stay in the system for people to search, read, cross-reference, or even reopen--nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

@stale stale bot added the status: stale label Apr 29, 2021
@stale stale bot closed this as completed May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants