at 18.03-beta 2.4 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.programs.zsh.ohMyZsh; 7in 8 { 9 options = { 10 programs.zsh.ohMyZsh = { 11 enable = mkOption { 12 default = false; 13 description = '' 14 Enable oh-my-zsh. 15 ''; 16 }; 17 18 package = mkOption { 19 default = pkgs.oh-my-zsh; 20 defaultText = "pkgs.oh-my-zsh"; 21 description = '' 22 Package to install for `oh-my-zsh` usage. 23 ''; 24 25 type = types.package; 26 }; 27 28 plugins = mkOption { 29 default = []; 30 type = types.listOf(types.str); 31 description = '' 32 List of oh-my-zsh plugins 33 ''; 34 }; 35 36 custom = mkOption { 37 default = ""; 38 type = types.str; 39 description = '' 40 Path to a custom oh-my-zsh package to override config of oh-my-zsh. 41 ''; 42 }; 43 44 theme = mkOption { 45 default = ""; 46 type = types.str; 47 description = '' 48 Name of the theme to be used by oh-my-zsh. 49 ''; 50 }; 51 52 cacheDir = mkOption { 53 default = "$HOME/.cache/oh-my-zsh"; 54 type = types.str; 55 description = '' 56 Cache directory to be used by `oh-my-zsh`. 57 Without this option it would default to the read-only nix store. 58 ''; 59 }; 60 }; 61 }; 62 63 config = mkIf cfg.enable { 64 65 # Prevent zsh from overwriting oh-my-zsh's prompt 66 programs.zsh.promptInit = mkDefault ""; 67 68 environment.systemPackages = [ cfg.package ]; 69 70 programs.zsh.interactiveShellInit = with builtins; '' 71 # oh-my-zsh configuration generated by NixOS 72 export ZSH=${cfg.package}/share/oh-my-zsh 73 74 ${optionalString (length(cfg.plugins) > 0) 75 "plugins=(${concatStringsSep " " cfg.plugins})" 76 } 77 78 ${optionalString (stringLength(cfg.custom) > 0) 79 "ZSH_CUSTOM=\"${cfg.custom}\"" 80 } 81 82 ${optionalString (stringLength(cfg.theme) > 0) 83 "ZSH_THEME=\"${cfg.theme}\"" 84 } 85 86 ${optionalString (cfg.cacheDir != null) '' 87 if [[ ! -d "${cfg.cacheDir}" ]]; then 88 mkdir -p "${cfg.cacheDir}" 89 fi 90 ZSH_CACHE_DIR=${cfg.cacheDir} 91 ''} 92 93 source $ZSH/oh-my-zsh.sh 94 ''; 95 }; 96 }