diff --git a/nixos/flake.nix b/nixos/flake.nix index 59776e4..4b07dfd 100644 --- a/nixos/flake.nix +++ b/nixos/flake.nix @@ -41,6 +41,7 @@ sharedOverlays = [ (import ./overlays/letter) (import ./overlays/icosystem) + (import ./overlays/cmdtime) ]; hostDefaults = { diff --git a/nixos/hosts/Tibo-NixFat/default.nix b/nixos/hosts/Tibo-NixFat/default.nix index 1d85891..0e382b5 100644 --- a/nixos/hosts/Tibo-NixFat/default.nix +++ b/nixos/hosts/Tibo-NixFat/default.nix @@ -46,10 +46,15 @@ environment.systemPackages = with pkgs; [ git + vim wget zenith-nvidia ]; + programs = { + zsh.enable = true; + }; + hardware.bluetooth.enable = true; networking.hostName = "Tibo-NixFat"; diff --git a/nixos/modules-old/shells/default.nix b/nixos/modules-old/shells/default.nix deleted file mode 100644 index 87b90be..0000000 --- a/nixos/modules-old/shells/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - imports = [ - ./zsh - ]; -} diff --git a/nixos/modules-old/shells/zsh/default.nix b/nixos/modules-old/shells/zsh/default.nix deleted file mode 100644 index 6b69e7e..0000000 --- a/nixos/modules-old/shells/zsh/default.nix +++ /dev/null @@ -1,77 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - programs.zsh.enable = true; - users.users.tdpeuter.shell = pkgs.zsh; - - home-manager.users.tdpeuter = { pkgs, ... }: { - home = { - packages = with pkgs; [ - font-awesome - fzf - ]; - - file = { - ".oh-my-zsh".source = ../../../../stow/zsh/.oh-my-zsh; - }; - }; - - programs.zsh = { - enable = true; - enableAutosuggestions = true; - enableSyntaxHighlighting = true; - history = { - expireDuplicatesFirst = true; - extended = true; - }; - initExtra = '' - eval "$(direnv hook zsh)" - - # Add fzf - if [ -x "$(command -v fzf-share)" ]; then - source "$(fzf-share)/key-bindings.zsh" - source "$(fzf-share)/completion.zsh" - fi - ''; - oh-my-zsh = { - enable = true; - custom = "$HOME/.oh-my-zsh"; - plugins = [ - "dirhistory" - "git" - "screen" - ]; - theme = "mrfortem"; - }; - plugins = [ - { - name = "cmdtime"; - src = pkgs.fetchFromGitHub { - owner = "tom-auger"; - repo = "cmdtime"; - rev = "ffc72641dcfa0ee6666ceb1dc712b61be30a1e8b"; - hash = "sha256-v6wCfNoPXDD3sS6yUYE6lre8Ir1yJcLGoAW3O8sUOCg="; - }; - } - ]; - shellAliases = { - cp = "cp -i"; # Confirm before overwriting something - df = "df -h"; - free = "free -m"; - ll = "ls -la"; - np = "nano -w PKGBUILD"; - more = "less"; - hgrep = "history | grep"; - - gs = "git status"; - - update = '' - pushd ~/projects/sisyphus/nixos - nix flake update - sudo nixos-rebuild switch --flake .# --show-trace - popd - ''; - }; - }; - }; -} diff --git a/nixos/modules/users/tdpeuter/default.nix b/nixos/modules/users/tdpeuter/default.nix index 89753e4..0d877be 100644 --- a/nixos/modules/users/tdpeuter/default.nix +++ b/nixos/modules/users/tdpeuter/default.nix @@ -18,9 +18,11 @@ in { config.users.groups.wheel.name ]; initialPassword = "ChangeMe"; + shell = pkgs.zsh; }; fonts.fonts = with pkgs; [ + font-awesome # Dependency of zsh font-awesome_5 # Dependency of Vifm config noto-fonts # Dependency of Zellij config noto-fonts-cjk # Dependency of Zellij config @@ -38,7 +40,9 @@ in { # and the configuration files will be put in place for you. packages = (with pkgs; [ chafa # Terminal image viewer + cmdtime # Zsh plugin duf # Df alternative + fzf glow # Terminal Markdown renderer jellyfin-media-player kitty @@ -53,6 +57,9 @@ in { vifm # File manager zathura # PDF viewer zellij # Tmux + screen alternative + zsh + zsh-autosuggestions + zsh-syntax-highlighting ]) ++ (with pkgs-unstable; [ mpv ]) ++ (with pkgs.vimPlugins; [ @@ -65,37 +72,65 @@ in { ".config/alacritty" = lib.mkIf (builtins.elem pkgs.alacritty installedPkgs) { source = ../../../../stow/alacritty/.config/alacritty; }; - ".config/git" = lib.mkIf (builtins.elem pkgs.git installedPkgs) { + ".config/git" = { + enable = (builtins.elem pkgs.git installedPkgs); source = ../../../../stow/git/.config/git; + recursive = true; }; ".config/kitty" = { enable = builtins.elem pkgs.kitty installedPkgs; source = ../../../../stow/kitty/.config/kitty; recursive = true; }; - ".config/mpv" = lib.mkIf (builtins.elem pkgs-unstable.mpv installedPkgs) { + ".config/mpv" = { + enable = (builtins.elem pkgs-unstable.mpv installedPkgs); source = ../../../../stow/mpv/.config/mpv; }; ".ssh/config" = lib.mkIf config.sisyphus.programs.ssh.enable { source = ../../../../stow/ssh/.ssh/config; }; - ".config/vifm" = lib.mkIf (builtins.elem pkgs.vifm installedPkgs) { + ".config/vifm" = { + enable = (builtins.elem pkgs.vifm installedPkgs); source = ../../../../stow/vifm/.config/vifm; recursive = true; }; - ".config/zellij" = lib.mkIf (builtins.elem pkgs.zellij installedPkgs) { + ".config/zellij" = { + enable = (builtins.elem pkgs.zellij installedPkgs); source = ../../../../stow/zellij/.config/zellij; }; - ".vim" = lib.mkIf (builtins.elem pkgs.vim installedPkgs) { + ".oh-my-zsh" = { + enable = (builtins.elem pkgs.zsh installedPkgs); + source = ../../../../stow/zsh/.oh-my-zsh; + }; + ".vim" = { + enable = (builtins.elem pkgs.vim installedPkgs); source = ../../../../stow/vim/.vim; recursive = true; }; - ".vim/autoload/plug.vim" = lib.mkIf (builtins.elem pkgs.vim installedPkgs) { + ".vim/autoload/plug.vim" = { + enable = (builtins.elem pkgs.vim installedPkgs); source = "${pkgs.vimPlugins.vim-plug}/plug.vim"; }; - ".vimrc" = lib.mkIf (builtins.elem pkgs.vim installedPkgs) { + ".vimrc" = { + enable = (builtins.elem pkgs.vim installedPkgs); source = ../../../../stow/vim/.vimrc; }; + ".zshrc" = { + enable = (config.users.users.tdpeuter.shell == pkgs.zsh); + source = ../../../../stow/zsh/.zshrc; + }; + ".zsh/plugins/cmdtime/cmdtime.plugin.zsh" = { + enable = (builtins.elem pkgs.cmdtime installedPkgs); + source = "${pkgs.cmdtime}/share/cmdtime/cmdtime.plugin.zsh"; + }; + ".zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" = { + enable = (builtins.elem pkgs.zsh-autosuggestions installedPkgs); + source = "${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh"; + }; + ".zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" = { + enable = (builtins.elem pkgs.zsh-syntax-highlighting installedPkgs); + source = "${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"; + }; }; }; diff --git a/nixos/overlays/cmdtime/default.nix b/nixos/overlays/cmdtime/default.nix new file mode 100644 index 0000000..afc864f --- /dev/null +++ b/nixos/overlays/cmdtime/default.nix @@ -0,0 +1,17 @@ +final: prev: { + cmdtime = final.stdenv.mkDerivation { + name = "cmdtime"; + version = "v0.0.0"; + src = final.fetchFromGitHub { + owner = "tom-auger"; + repo = "cmdtime"; + rev = "ffc72641dcfa0ee6666ceb1dc712b61be30a1e8b"; + hash = "sha256-v6wCfNoPXDD3sS6yUYE6lre8Ir1yJcLGoAW3O8sUOCg="; + }; + + installPhase = '' + mkdir -p $out/share/cmdtime + cp $src/cmdtime.plugin.zsh $out/share/cmdtime.plugin.zsh + ''; + }; +} diff --git a/stow/zsh/.oh-my-zsh/themes/mrfortem.zsh-theme b/stow/zsh/.oh-my-zsh/themes/tdpeuter.zsh-theme similarity index 97% rename from stow/zsh/.oh-my-zsh/themes/mrfortem.zsh-theme rename to stow/zsh/.oh-my-zsh/themes/tdpeuter.zsh-theme index 3515550..958c7fe 100644 --- a/stow/zsh/.oh-my-zsh/themes/mrfortem.zsh-theme +++ b/stow/zsh/.oh-my-zsh/themes/tdpeuter.zsh-theme @@ -1,5 +1,5 @@ # -# ~/.oh-my-zsh/themes/mrfortem.zsh-theme +# ~/.oh-my-zsh/themes/tdpeuter.zsh-theme # Stolen from gentoo-theme and gianni # diff --git a/stow/zsh/.zshrc b/stow/zsh/.zshrc new file mode 100644 index 0000000..5209f6b --- /dev/null +++ b/stow/zsh/.zshrc @@ -0,0 +1,68 @@ +typeset -U path cdpath fpath manpath + +path+="$HOME/.zsh/plugins/cmdtime" +fpath+="$HOME/.zsh/plugins/cmdtime" + +plugins=(dirhistory git screen) +ZSH_CUSTOM="$HOME/.oh-my-zsh" +ZSH_THEME="tdpeuter" +# source $ZSH/oh-my-zsh.sh + +if [[ -f "$HOME/.zsh/plugins/cmdtime/cmdtime.plugin.zsh" ]]; then + source "$HOME/.zsh/plugins/cmdtime/cmdtime.plugin.zsh" +fi +if [[ -f "$HOME/.zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" ]]; then + source "$HOME/.zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" +fi + +if [[ -f "$HOME/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then + source "$HOME/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" +fi + +# History options should be set in .zshrc and after oh-my-zsh sourcing. +# See https://github.com/nix-community/home-manager/issues/177. +HISTSIZE="10000" +SAVEHIST="10000" + +HISTFILE="$HOME/.zsh_history" +mkdir -p "$(dirname "$HISTFILE")" + +setopt HIST_FCNTL_LOCK +setopt HIST_IGNORE_DUPS +setopt HIST_IGNORE_SPACE +setopt HIST_EXPIRE_DUPS_FIRST +setopt SHARE_HISTORY +setopt EXTENDED_HISTORY + +# Add direnv +if [ -x "$(command -v direnv)" ]; then + eval "$(direnv hook zsh)" +fi + +# Add fzf +if [ -x "$(command -v fzf-share)" ]; then + source "$(fzf-share)/key-bindings.zsh" + source "$(fzf-share)/completion.zsh" +fi + +# Aliases +alias cp='cp -i' +alias df='df -h' +alias free='free -m' +alias gs='git status' +alias hgrep='history | grep' +alias ll='ls -la' +alias more='less' +alias np='nano -w PKGBUILD' +alias update='pushd ~/projects/sisyphus/nixos +nix flake update +sudo nixos-rebuild switch --flake .# --show-trace +popd +' + +# -- Barrier -- + +for profile in ${(z)NIX_PROFILES}; do + fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions) +done +