at 17.09-beta 1.9 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 }; 53 54 config = mkIf cfg.enable { 55 56 # Prevent zsh from overwriting oh-my-zsh's prompt 57 programs.zsh.promptInit = mkDefault ""; 58 59 environment.systemPackages = [ cfg.package ]; 60 61 programs.zsh.interactiveShellInit = with builtins; '' 62 # oh-my-zsh configuration generated by NixOS 63 export ZSH=${cfg.package}/share/oh-my-zsh 64 65 ${optionalString (length(cfg.plugins) > 0) 66 "plugins=(${concatStringsSep " " cfg.plugins})" 67 } 68 69 ${optionalString (stringLength(cfg.custom) > 0) 70 "ZSH_CUSTOM=\"${cfg.custom}\"" 71 } 72 73 ${optionalString (stringLength(cfg.theme) > 0) 74 "ZSH_THEME=\"${cfg.theme}\"" 75 } 76 77 source $ZSH/oh-my-zsh.sh 78 ''; 79 }; 80 }