From ec2df57d71b1a42c6573f732014dd3862b242b31 Mon Sep 17 00:00:00 2001 From: kossLAN Date: Thu, 14 Nov 2024 22:37:06 -0500 Subject: [PATCH] Add zsh flake --- .zshrc | 0 flake.lock | 26 +++++++++++++++++++++ flake.nix | 27 +++++++++++++++++++++ nix/config.nix | 54 ++++++++++++++++++++++++++++++++++++++++++ nix/wrapZsh.nix | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 169 insertions(+) create mode 100644 .zshrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/config.nix create mode 100644 nix/wrapZsh.nix diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..e69de29 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c5e3bc3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1731630592, + "narHash": "sha256-LRWOwLGeIeKc5fW/P3TF8yi7IMHtiXyQsrbSKj0RveI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4aad3e8c772be76cbbc6fd2530204bf6ff993d1b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5f9a910 --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + description = "My zsh dot files in flake format"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + }; + + outputs = { + self, + nixpkgs, + }: let + forEachSystem = fn: + nixpkgs.lib.genAttrs + ["x86_64-linux" "aarch64-linux"] + (system: fn system nixpkgs.legacyPackages.${system}); + in { + # Define a package for your project + packages = forEachSystem (system: pkgs: rec { + zsh = import ./nix/wrapZsh.nix { + inherit pkgs; + lib = nixpkgs.lib; + }; + + default = zsh; + }); + }; +} diff --git a/nix/config.nix b/nix/config.nix new file mode 100644 index 0000000..2c84eb3 --- /dev/null +++ b/nix/config.nix @@ -0,0 +1,54 @@ +# This is where personal configuration is expected to be, I'll probably add more, but for the moment this +# will do. +{ + pkgs, + lib, + ... +}: let + oh-my-zsh = pkgs.fetchFromGitHub { + owner = "ohmyzsh"; + repo = "ohmyzsh"; + rev = "fd01fd66ce27c669e5ffaea94460a37423d1e134"; + sha256 = "sha256-5G96Iae543/CVmwRVpwAlbRB7vf+t/E2fl0pOu+RM6Y="; + }; +in { + # Whether or not to enable auto suggestions + autoSuggestions = true; + + # Additional .zshrc configuration that you can add that will be appended to the .zshrc + extraZshrc = '' + # Movement bindings + bindkey -v + bindkey "^[[1;5C" forward-word + bindkey "^[[1;5D" backward-word + ''; + + # A list of path's to a plugin + plugins = [ + # The ZSH theme that I use, I think it looks good, go check it out. + "${pkgs.fetchFromGitHub { + owner = "zthxxx"; + repo = "jovial"; + rev = "701ea89b6dd2b9859dab32bd083a16643b338b47"; + sha256 = "sha256-VVGBG0ZoL25v+Ht1QbnZMc1TqTiJvr211OvyVwNc3bc="; + }}/jovial.zsh-theme" + + "${pkgs.fetchFromGitHub { + owner = "zthxxx"; + repo = "zsh-history-enquirer"; + rev = "6fdfedc4e581740e7db388b36b5e66f7c86e8046"; + sha256 = "sha256-/RGBIoieqexK2r4onFbXAt4ALEIb17mn/all0P1xFkE="; + }}/zsh-history-enquirer.plugin.zsh" + + "${pkgs.fetchFromGitHub { + owner = "zsh-users"; + repo = "zsh-syntax-highlighting"; + rev = "e0165eaa730dd0fa321a6a6de74f092fe87630b0"; + sha256 = "sha256-4rW2N+ankAH4sA6Sa5mr9IKsdAg7WTgrmyqJ2V1vygQ="; + }}/zsh-syntax-highlighting.zsh" + + "${oh-my-zsh}/plugins/git/git.plugin.zsh" + "${oh-my-zsh}/plugins/urltools/urltools.plugin.zsh" + "${oh-my-zsh}/plugins/bgnotify/bgnotify.plugin.zsh" + ]; +} diff --git a/nix/wrapZsh.nix b/nix/wrapZsh.nix new file mode 100644 index 0000000..f466afd --- /dev/null +++ b/nix/wrapZsh.nix @@ -0,0 +1,62 @@ +{ + pkgs, + lib, + ... +}: let + conf = import ./config.nix {inherit pkgs lib;}; +in + pkgs.symlinkJoin { + name = "zsh"; + paths = [pkgs.zsh]; + buildInputs = [pkgs.makeWrapper]; + postBuild = '' + # When it comes to zsh options, I'm probably missing some important ones, + # if you know of any that I should add please make an issue for me, thank you. + # The sh comment before the multiline is for syntax highlighting in neovim. + mkdir -p $out/etc/zsh + cp ${pkgs.writeText "zshrc" #sh + + '' + # Auto suggestions + ${ + if conf.autoSuggestions + then '' + source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh + ZSH_AUTOSUGGEST_STRATEGY=(history) + '' + else "" + } + + # History configuration + HISTFILE="$HOME/.zsh_history" + HISTSIZE=10000 + SAVEHIST=10000 + setopt AUTO_CD + setopt AUTO_PUSHD + setopt PUSHD_IGNORE_DUPS + setopt EXTENDED_HISTORY + setopt SHARE_HISTORY + setopt HIST_EXPIRE_DUPS_FIRST + setopt HIST_IGNORE_DUPS + setopt HIST_IGNORE_SPACE + setopt HIST_VERIFY + setopt INTERACTIVE_COMMENTS + + # Basic autocompletion + autoload -Uz compinit + compinit + + # Plugins import + ${lib.concatMapStrings (plugin: '' + if [[ -f "${plugin}" ]]; then + source "${plugin}" + fi + '') + conf.plugins} + ${conf.extraZshrc} + ''} $out/etc/zsh/.zshrc + + wrapProgram $out/bin/zsh \ + --set ZDOTDIR "$out/etc/zsh" \ + ''; + }