diff --git a/nixos/modules/programs/zsh/zsh.nix b/nixos/modules/programs/zsh/zsh.nix index d81f63c2acca..5b7d94157454 100644 --- a/nixos/modules/programs/zsh/zsh.nix +++ b/nixos/modules/programs/zsh/zsh.nix @@ -84,6 +84,14 @@ in type = types.bool; }; + enableSyntaxHighlighting = mkOption { + default = false; + description = '' + Enable zsh-syntax-highlighting + ''; + type = types.bool; + }; + }; }; @@ -120,6 +128,10 @@ in ${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""} + ${optionalString (cfg.enableSyntaxHighlighting) + "source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" + } + HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" ''; @@ -182,7 +194,8 @@ in environment.etc."zinputrc".source = ./zinputrc; environment.systemPackages = [ pkgs.zsh ] - ++ optional cfg.enableCompletion pkgs.nix-zsh-completions; + ++ optional cfg.enableCompletion pkgs.nix-zsh-completions + ++ optional cfg.enableSyntaxHighlighting pkgs.zsh-syntax-highlighting; environment.pathsToLink = optional cfg.enableCompletion "/share/zsh"; diff --git a/pkgs/shells/zsh-syntax-highlighting/default.nix b/pkgs/shells/zsh-syntax-highlighting/default.nix new file mode 100644 index 000000000000..301ad13fa738 --- /dev/null +++ b/pkgs/shells/zsh-syntax-highlighting/default.nix @@ -0,0 +1,31 @@ +{ stdenv, fetchurl, zsh }: + +# To make use of this derivation, use the `programs.zsh.enableSyntaxHighlighting` option + +let + + pkgName = "zsh-syntax-highlighting"; + version = "0.4.1"; + +in + +stdenv.mkDerivation rec { + name = "${pkgName}-${version}"; + + src = fetchurl { + url = "https://github.com/zsh-users/${pkgName}/archive/${version}.tar.gz"; + sha256 = "15sih7blqz11d8wdybx38d91vgcq9jg3q0205r26138si0g9q6wp"; + }; + + buildInputs = [ zsh ]; + + installFlags="PREFIX=$(out)"; + + meta = with stdenv.lib; { + description = "Fish shell like syntax highlighting for Zsh"; + homepage = "https://github.com/zsh-users/zsh-syntax-highlighting"; + license = licenses.bsd3; + platforms = platforms.linux; + maintainers = [ maintainers.loskutov ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a06f4a0a1386..a56f46c37767 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4339,6 +4339,8 @@ in zsh-navigation-tools = callPackage ../tools/misc/zsh-navigation-tools { }; + zsh-syntax-highlighting = callPackage ../shells/zsh-syntax-highlighting { }; + zstd = callPackage ../tools/compression/zstd { }; zsync = callPackage ../tools/compression/zsync { };