From 1d1bfd4336060d5964da98def907ce2ac7dfa331 Mon Sep 17 00:00:00 2001 From: Julien Malka <julien@malka.sh> Date: Wed, 22 Nov 2023 18:09:11 +0100 Subject: [PATCH] change shell to zsh --- home-manager-modules/zsh/default.nix | 183 +++++++++++++++++++++++++++ machines/telecom/home-julien.nix | 6 +- users/default.nix | 4 +- users/julien.nix | 2 +- users/status.nix | 1 - 5 files changed, 187 insertions(+), 9 deletions(-) create mode 100644 home-manager-modules/zsh/default.nix diff --git a/home-manager-modules/zsh/default.nix b/home-manager-modules/zsh/default.nix new file mode 100644 index 0000000..98ef9b6 --- /dev/null +++ b/home-manager-modules/zsh/default.nix @@ -0,0 +1,183 @@ +{ config, pkgs, lib, ... }: +let + cfg = config.luj.programs.zsh; + fetchFromGitHub = pkgs.fetchFromGitHub; +in +with lib; +{ + options.luj.programs.zsh = { + enable = mkEnableOption "Enable Zsh"; + }; + + config = mkIf cfg.enable { + + programs.zsh = { + enable = true; + enableCompletion = true; + enableAutosuggestions = true; + history = { save = 1000000; extended = true; ignoreDups = true; }; + initExtra = '' + setopt notify autopushd + unsetopt autocd beep + ZSH_AUTOSUGGEST_STRATEGY=(completion history) + ''; + + shellAliases = { + + ka = "killall"; + mkd = "mkdir -pv"; + + ca = "khal interactive"; + sync_ca = "vsync sync"; + + dnd = "dunstctl set-paused true"; + nodnd = "dunstctl set-paused false"; + + lg = "lazygit"; + g = "git"; + gua = "git remote | xargs -L1 git push --all"; + + v = "$EDITOR"; + sdn = "shutdown now"; + + SU = "systemctl --user"; + SS = "sudo systemctl"; + + + weather = "curl wttr.in"; + v6 = "curl api6.ipify.org"; + v4 = "curl api.ipify.org"; + clbin = "curl -F'clbin=<-' https://clbin.com"; + _0x0 = "curl -F'file=@-' https://0x0.st"; + + phs = "python -m http.server"; + + ls = "eza"; + + rtmv = "rsync -avP"; + archive = "rsync --remove-source-files -avPzz"; + + luks_integrity_check = "gocryptfs -fsck -extpass 'pass Private/LUKS' /boot/luks"; + + fetch-emails = "mbsync --all && notmuch new && afew -t -n -v"; + + nsp = "nix-shell -p"; + ns = "nix-shell"; + + ncg = "sudo nix-collect-garbage --delete-older-than 30d"; + ncga = "sudo nix-collect-garbage -d"; + nso = "sudo nix-store --optimise"; + + lln = "NIX_PATH=\"nixpkgs=$LOCAL_NIXPKGS_CHECKOUT\""; + # Local build + lnb = "NIX_PATH=\"nixpkgs=$LOCAL_NIXPKGS_CHECKOUT\" nom-build '<nixpkgs>' --no-out-link -A $1"; + # Local shell + lns = "NIX_PATH=\"nixpkgs=$LOCAL_NIXPKGS_CHECKOUT\" nix-shell -p $1"; + # Local test + ltt = ''NIX_PATH=\"nixpkgs=$LOCAL_NIXPKGS_CHECKOUT\" nom-build --no-out-link "$LOCAL_NIXPKGS_CHECKOUT/nixos/tests/$1"''; + }; + + dirHashes = { + config = "/home/julien/dev/nix-config"; + }; + plugins = [ + { + name = "history-search-multi-word"; + src = fetchFromGitHub { + repo = "history-search-multi-word"; + owner = "zdharma-continuum"; + rev = "458e75c16db72596e4d7c6a45619dec285ebdcd7"; + sha256 = "sha256-6B8uoKJm3gWmufsnLJzLEdSm1tQasrs2fUmS0pDsdMw="; + }; + } + { + name = "git-aliases"; + src = fetchFromGitHub { + repo = "git-aliases"; + owner = "mdumitru"; + rev = "c4cfe2cf5cf59a3da6bf3b735a20921a2c06c58d"; + sha256 = "sha256-640qGgVeFaTIQBgYGY05/4wzMCxni0uWLWtByEFM2tE="; + }; + } + { + name = "zsh-bitwarden"; + src = fetchFromGitHub { + repo = "zsh-bitwarden"; + owner = "Game4Move78"; + rev = "8b32434d18765fe95ffc2191f5fb68100d913de7"; + sha256 = "sha256-3zuutTUSdf218+jcn2z7yEGMYkg5VewXm9zO43aIYdI="; + }; + } + { + name = "alias-tips"; + src = fetchFromGitHub { + repo = "alias-tips"; + owner = "djui"; + rev = "4d2cf6f10e5080f3273be06b9801e1fd1f25d28d"; + sha256 = "sha256-0N2DCpMraIXtEc7hMp0OBANNuYhHPLqzJ/hrAFcLma8="; + }; + } + { + name = "auto-notify"; + src = fetchFromGitHub { + repo = "zsh-auto-notify"; + owner = "MichaelAquilina"; + rev = "fb38802d331408e2ebc8e6745fb8e50356344aa4"; + sha256 = "sha256-bY0qLX5Kpt2x4KnfvXjYK2+BhR3zKBgGsCvIxSzApws="; + }; + } + { + name = "nix-shell"; + src = fetchFromGitHub { + repo = "zsh-nix-shell"; + owner = "chisui"; + rev = "f8574f27e1d7772629c9509b2116d504798fe30a"; + sha256 = "sha256-WNa8RljYhkOWk7AZbdTOvYhWw1fR8PjFxH/tnUCbems="; + }; + } + { + name = "syntax-highlighting"; + src = fetchFromGitHub { + repo = "zsh-syntax-highlighting"; + owner = "zsh-users"; + rev = "bb27265aeeb0a22fb77f1275118a5edba260ec47"; + sha256 = "sha256-bD0oKXSw9lucJR+6/O16m7prwA1cP36C0Tvh5mklapw="; + }; + } + { + name = "jq"; + src = fetchFromGitHub { + repo = "jq-zsh-plugin"; + owner = "reegnz"; + rev = "98650d6eac46b5f87aa19f0a3dd321b0105643b8"; + sha256 = "sha256-L2+PW39BZTy8h4yxxZxbKCVVKlfPruM12gRZ9FJ8YD8="; + }; + } + ]; + }; + + # Broot + programs.broot = { + enable = true; + enableZshIntegration = true; + }; + + # Direnv: must have. + programs.direnv = { + enable = true; + enableZshIntegration = true; + nix-direnv.enable = true; + }; + + programs.oh-my-posh = { + enable = true; + enableZshIntegration = true; + useTheme = "catppuccin_mocha"; + }; + + # Misc + programs.lesspipe.enable = true; + + home.packages = with pkgs; [ eza python3 libnotify ]; + }; +} diff --git a/machines/telecom/home-julien.nix b/machines/telecom/home-julien.nix index 0e639e5..c09aef3 100644 --- a/machines/telecom/home-julien.nix +++ b/machines/telecom/home-julien.nix @@ -13,6 +13,7 @@ luj.programs.waybar.enable = true; luj.programs.waybar.interfaceName = "enp0s13f0u1u4u4"; luj.programs.kitty.enable = true; + luj.programs.zsh.enable = true; luj.emails.enable = true; programs.rofi = { @@ -22,11 +23,6 @@ theme = "DarkBlue"; }; - programs.direnv = { - enable = true; - enableFishIntegration = true; - nix-direnv.enable = true; - }; home.pointerCursor = { name = "Adwaita"; diff --git a/users/default.nix b/users/default.nix index 293de80..a84bcb0 100644 --- a/users/default.nix +++ b/users/default.nix @@ -1,10 +1,10 @@ { config, pkgs, lib, ... }: { users.mutableUsers = false; - users.defaultUserShell = pkgs.fish; + users.defaultUserShell = pkgs.zsh; sops.secrets.user-root-password.neededForUsers = true; - programs.fish.enable = true; + programs.zsh.enable = true; users.users.root = { uid = config.ids.uids.root; diff --git a/users/julien.nix b/users/julien.nix index eb520c8..4fa1c9c 100644 --- a/users/julien.nix +++ b/users/julien.nix @@ -6,7 +6,7 @@ isNormalUser = true; home = "/home/julien"; extraGroups = [ "wheel" config.users.groups.keys.name "filerun" "networkmanager" "davfs2" "adbusers" "audio" ]; - shell = pkgs.fish; + shell = pkgs.zsh; passwordFile = config.sops.secrets.user-julien-password.path; }; diff --git a/users/status.nix b/users/status.nix index 2a961e8..b374a64 100644 --- a/users/status.nix +++ b/users/status.nix @@ -4,7 +4,6 @@ isNormalUser = true; home = "/home/status"; extraGroups = [ "wheel" ]; - shell = pkgs.fish; openssh.authorizedKeys.keyFiles = [ (pkgs.fetchurl { url = "https://github.com/JulienMalka.keys";