flake.nix 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. {
  2. description = "Zsh configuration";
  3. inputs = {
  4. flake-utils.url = "github:numtide/flake-utils";
  5. };
  6. outputs = { self, nixpkgs, flake-utils }:
  7. flake-utils.lib.eachDefaultSystem (system:
  8. with nixpkgs.legacyPackages.${system}; {
  9. packages.zsh =
  10. let
  11. config = runCommand "zsh-config" {
  12. nativeBuildInputs = [ makeWrapper ];
  13. } ''
  14. mkdir -p $out/share/zsh
  15. cat <<EOF > $out/share/zsh/.zprofile
  16. emulate sh -c 'source /etc/profile'
  17. EOF
  18. cat <<EOF > $out/share/zsh/.zshenv
  19. unsetopt GLOBAL_RCS
  20. EOF
  21. cat <<EOF > $out/share/zsh/.zshrc
  22. source ${nix-zsh-completions}/share/zsh/plugins/nix/nix-zsh-completions.plugin.zsh
  23. fpath+=(${nix-zsh-completions}/share/zsh/site-functions)
  24. fpath+=(~/.nix-profile/share/zsh/site-functions)
  25. autoload -U compinit && compinit
  26. source ${zsh-bd}/share/zsh-bd/bd.plugin.zsh
  27. source ${zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme
  28. path+=(${lib.makeBinPath [ any-nix-shell ]})
  29. source ${./config/fzf/fzf.zsh}
  30. source ${./config/config.zsh}
  31. source ${./config/p10k.zsh}
  32. source ${./config/title.zsh}
  33. if [ -f "\$HOME/.zsh/local.zsh" ]; then
  34. source "\$HOME/.zsh/local.zsh"
  35. fi
  36. # must be last
  37. source ${zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  38. EOF
  39. '';
  40. in
  41. writeScriptBin "zsh" ''
  42. #!/bin/sh
  43. export ZDOTDIR=${config}/share/zsh
  44. for zsh in $(which -a zsh); do
  45. if [ "$0" = "$zsh" ]; then
  46. continue
  47. fi
  48. exec "$zsh" "$@"
  49. done
  50. echo "Could not find system zsh"
  51. exit 1
  52. '';
  53. packages.default = self.packages.${system}.zsh;
  54. }
  55. );
  56. }