summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2017-04-23 13:58:07 +0200
committerJörg Thalheim <Mic92@users.noreply.github.com>2017-04-23 13:58:07 +0200
commit9ec64d28902b9f89fe704679e1d5c8fc83270130 (patch)
tree73bbccc016f91e495fd393ab0bd110d8c481063e /nixos
parentf1bc5a3a83bc8f101f0f40b2921e071a28160212 (diff)
downloadnixpkgs-9ec64d28902b9f89fe704679e1d5c8fc83270130.tar
nixpkgs-9ec64d28902b9f89fe704679e1d5c8fc83270130.tar.gz
nixpkgs-9ec64d28902b9f89fe704679e1d5c8fc83270130.tar.bz2
nixpkgs-9ec64d28902b9f89fe704679e1d5c8fc83270130.tar.lz
nixpkgs-9ec64d28902b9f89fe704679e1d5c8fc83270130.tar.xz
nixpkgs-9ec64d28902b9f89fe704679e1d5c8fc83270130.tar.zst
nixpkgs-9ec64d28902b9f89fe704679e1d5c8fc83270130.zip
oh-my-zsh: add module (#25140)
* programs.zsh: add enableOhMyZsh option to automate setup of oh-my-zsh in global zshrc

* programs.zsh: make oh-my-zsh plugins configurable

* programs.zsh: add ohMyZshCustom option

* programs.zsh: add ohMyZshTheme option

* programs.zsh: applying minor fixes to evaluate expressions properly

* programs.zsh: fix ordering of oh-my-zsh config and execution

* programs.zsh: move all oh-my-zsh params into its own scope named programs.zsh.oh-my-zsh
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/programs/zsh/oh-my-zsh.nix66
-rw-r--r--nixos/modules/programs/zsh/zsh.nix2
3 files changed, 68 insertions, 1 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 530ae1d1cf0..6e99ead5862 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -102,6 +102,7 @@
   ./programs/wvdial.nix
   ./programs/xfs_quota.nix
   ./programs/xonsh.nix
+  ./programs/zsh/oh-my-zsh.nix
   ./programs/zsh/zsh.nix
   ./rename.nix
   ./security/acme.nix
diff --git a/nixos/modules/programs/zsh/oh-my-zsh.nix b/nixos/modules/programs/zsh/oh-my-zsh.nix
new file mode 100644
index 00000000000..335f596ca80
--- /dev/null
+++ b/nixos/modules/programs/zsh/oh-my-zsh.nix
@@ -0,0 +1,66 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.programs.zsh.oh-my-zsh;
+in
+  {
+    options = {
+      programs.zsh.oh-my-zsh = {
+        enable = mkOption {
+          default = false;
+          description = ''
+            Enable oh-my-zsh.
+          '';
+        };
+
+        plugins = mkOption {
+          default = [];
+          type = types.listOf(types.str);
+          description = ''
+            List of oh-my-zsh plugins
+          '';
+        };
+
+        custom = mkOption {
+          default = "";
+          type = types.str;
+          description = ''
+            Path to a custom oh-my-zsh package to override config of oh-my-zsh.
+          '';
+        };
+
+        theme = mkOption {
+          default = "";
+          type = types.str;
+          description = ''
+            Name of the theme to be used by oh-my-zsh.
+          '';
+        };
+      };
+    };
+
+    config = mkIf cfg.enable {
+      environment.systemPackages = with pkgs; [ oh-my-zsh ];
+
+      programs.zsh.interactiveShellInit = with pkgs; with builtins; ''
+        # oh-my-zsh configuration generated by NixOS
+        export ZSH=${oh-my-zsh}/share/oh-my-zsh
+
+        ${optionalString (length(cfg.plugins) > 0)
+          "plugins=(${concatStringsSep " " cfg.plugins})"
+        }
+
+        ${optionalString (stringLength(cfg.custom) > 0)
+          "ZSH_CUSTOM=\"${cfg.custom}\""
+        }
+
+        ${optionalString (stringLength(cfg.theme) > 0)
+          "ZSH_THEME=\"${cfg.theme}\""
+        }
+
+        source $ZSH/oh-my-zsh.sh
+      '';
+    };
+  }
diff --git a/nixos/modules/programs/zsh/zsh.nix b/nixos/modules/programs/zsh/zsh.nix
index 990e6648e82..a39c06c0913 100644
--- a/nixos/modules/programs/zsh/zsh.nix
+++ b/nixos/modules/programs/zsh/zsh.nix
@@ -99,6 +99,7 @@ in
         '';
       };
 
+
     };
 
   };
@@ -143,7 +144,6 @@ in
 
         ${cfge.interactiveShellInit}
 
-
         HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help"
       '';