From c24d6892eac6939f71ec42b2140794e59a7a261c Mon Sep 17 00:00:00 2001 From: Laurent Le Houerou Date: Mon, 10 Mar 2025 21:11:26 +0400 Subject: [PATCH] wip --- home/base/zsh/default.nix | 81 +++++++++++++++++++++++++------------- switch.sh | 14 +++++-- system/desktop/default.nix | 15 ------- 3 files changed, 64 insertions(+), 46 deletions(-) diff --git a/home/base/zsh/default.nix b/home/base/zsh/default.nix index 8d15c7f..f2326d3 100644 --- a/home/base/zsh/default.nix +++ b/home/base/zsh/default.nix @@ -1,16 +1,21 @@ -{ pkgs, ... }: +{ pkgs, config, ... }: { programs.zsh = { enable = true; enableCompletion = true; + enableAutosuggestions = true; + enableSyntaxHighlighting = true; # History settings history = { - size = 10000; - path = "$HOME/.zsh_history"; + size = 5000; + path = "${config.xdg.stateHome}/zsh/history"; ignoreDups = true; + ignoreAllDups = true; + ignoreSpace = true; share = true; + extended = true; }; autosuggestion = { @@ -19,40 +24,39 @@ # Shell options initExtra = '' - # Enable vi mode - bindkey -v + # Keybindings + bindkey -e + bindkey '^p' history-search-backward + bindkey '^n' history-search-forward + bindkey '^[w' kill-region + # Bind Home key to beginning-of-line + bindkey '^[[H' beginning-of-line + bindkey '^[[1~' beginning-of-line + # Bind End key to end-of-line + bindkey '^[[F' end-of-line + bindkey '^[[4~' end-of-line + # Bind Delete key to delete-char + bindkey '^[[3~' delete-char - # Better history search - bindkey '^R' history-incremental-search-backward - - # Basic auto/tab completion - autoload -U compinit - zstyle ':completion:*' menu select - zmodload zsh/complist - compinit - _comp_options+=(globdots) + # Terminal settings + export TERM=xterm-256color ''; # Aliases shellAliases = { - ll = "ls -la"; + ls = "eza"; + ll = "eza -alh"; + tree = "eza --tree"; + dcupd = "docker compose up -d --remove-orphans"; + dcdown = "docker compose down"; + dclogs = "docker logs -f --tail 100"; + vi = "nvim"; + vim = "nvim"; + lg = "lazygit"; ".." = "cd .."; "..." = "cd ../.."; update = "sudo nixos-rebuild switch"; - vim = "nvim"; }; - - plugins = [ - { - name = "zsh-syntax-highlighting"; - src = pkgs.fetchFromGitHub { - owner = "zsh-users"; - repo = "zsh-syntax-highlighting"; - rev = "refs/tags/0.8.0"; - sha256 = "1yl8zdip1z9inp280sfa5byjbf2vqh2iazsycar987khjsi5d5w8"; - }; - } - ]; }; programs.oh-my-posh = { @@ -61,4 +65,25 @@ package = pkgs.oh-my-posh; settings = builtins.fromJSON (builtins.readFile ./oh-my-posh/config.json); }; + + programs.fzf = { + enable = true; + enableZshIntegration = true; + }; + + programs.zoxide = { + enable = true; + enableZshIntegration = true; + options = ["--cmd" "cd"]; + }; + + programs.eza = { + enable = true; + }; + + home.packages = with pkgs; [ + zsh-syntax-highlighting + zsh-fzf-tab + zsh-completions + ]; } diff --git a/switch.sh b/switch.sh index 50688f6..f3e1739 100755 --- a/switch.sh +++ b/switch.sh @@ -7,11 +7,19 @@ set -e # Default to the nixos configuration if no argument is provided CONFIG=${1:-nixos} -# Check if the configuration exists in flake.nix -if ! grep -q "nixosConfigurations.$CONFIG" flake.nix; then +# Use nix itself to list available configurations +AVAILABLE_CONFIGS=$(nix flake show --json | jq -r '.nixosConfigurations | keys[]' 2>/dev/null) + +# If the above command fails, fall back to a simple grep method +if [ -z "$AVAILABLE_CONFIGS" ]; then + AVAILABLE_CONFIGS=$(grep -A 100 "nixosConfigurations = {" flake.nix | grep -E "^\s+[a-zA-Z0-9_-]+ = " | sed 's/^\s*\([a-zA-Z0-9_-]*\)\s*=.*/\1/') +fi + +# Check if the configuration exists +if ! echo "$AVAILABLE_CONFIGS" | grep -q "^${CONFIG}$"; then echo "Error: Configuration '$CONFIG' not found in flake.nix" echo "Available configurations:" - grep -o "nixosConfigurations\.[a-zA-Z0-9_-]*" flake.nix | sed 's/nixosConfigurations\./ - /' + echo "$AVAILABLE_CONFIGS" | sed 's/^/ - /' exit 1 fi diff --git a/system/desktop/default.nix b/system/desktop/default.nix index 31a3d89..5432331 100644 --- a/system/desktop/default.nix +++ b/system/desktop/default.nix @@ -27,19 +27,4 @@ services.displayManager.defaultSession = "none+i3"; - # Additional desktop-specific packages - environment.systemPackages = with pkgs; [ - firefox - libreoffice - vlc - gimp - ]; - - # Enable sound - sound.enable = true; - hardware.pulseaudio.enable = true; - - # Enable bluetooth - hardware.bluetooth.enable = true; - services.blueman.enable = true; } \ No newline at end of file