From 4cf3e09d41b5af75de65e0159d89963554883c62 Mon Sep 17 00:00:00 2001 From: foglar Date: Thu, 26 Dec 2024 13:44:36 +0100 Subject: [PATCH] shell customization --- leanix/home.nix | 8 +- nixos/home/packages/packages.nix | 23 ++++- nixos/home/packages/tools/oh-my-posh.nix | 17 +++- nixos/home/packages/tools/shell.nix | 90 ++++++++++++------- .../system/settings/default-applications.nix | 9 ++ 5 files changed, 107 insertions(+), 40 deletions(-) diff --git a/leanix/home.nix b/leanix/home.nix index 8599b9e..4fbf3d4 100644 --- a/leanix/home.nix +++ b/leanix/home.nix @@ -17,11 +17,17 @@ desktop.gnome.enable = true; # Shell management + sh.oh-my-posh.enable = false; sh.bash = { enable = true; oh-my-posh.enable = false; }; + sh.zsh = { + enable = false; + oh-my-posh.enable = false; + }; + # Application lists app_list = { hacking.enable = false; @@ -38,7 +44,7 @@ vscode.enable = false; git.enable = false; neovim.enable = false; - firefox.enable = false; + firefox.enable = true; spotify.enable = false; }; diff --git a/nixos/home/packages/packages.nix b/nixos/home/packages/packages.nix index 9407a40..2118709 100644 --- a/nixos/home/packages/packages.nix +++ b/nixos/home/packages/packages.nix @@ -26,10 +26,29 @@ ]; sh.bash = { - enable = lib.mkDefault true; - oh-my-posh.enable = lib.mkDefault true; + enable = + if userSettings.shell == "bash" + then lib.mkDefault true + else lib.mkDefault false; + oh-my-posh.enable = + if userSettings.shell == "bash" + then lib.mkDefault true + else lib.mkDefault false; }; + sh.zsh = { + enable = + if userSettings.shell == "zsh" + then lib.mkDefault true + else lib.mkDefault false; + oh-my-posh.enable = + if userSettings.shell == "zsh" + then lib.mkDefault true + else lib.mkDefault false; + }; + + sh.oh-my-posh.enable = lib.mkDefault true; + program = { kitty.enable = if userSettings.terminal == "kitty" diff --git a/nixos/home/packages/tools/oh-my-posh.nix b/nixos/home/packages/tools/oh-my-posh.nix index b86c306..e166bb3 100644 --- a/nixos/home/packages/tools/oh-my-posh.nix +++ b/nixos/home/packages/tools/oh-my-posh.nix @@ -5,13 +5,24 @@ ... }: { options = { - sh.bash.oh-my-posh.enable = lib.mkEnableOption "enable oh-my-posh"; + sh.oh-my-posh.enable = lib.mkEnableOption "enable oh-my-posh"; + sh.bash.oh-my-posh.enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = "enable oh-my-posh for bash"; + }; + sh.zsh.oh-my-posh.enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = "enable oh-my-posh for zsh"; + }; }; - config = lib.mkIf config.sh.bash.oh-my-posh.enable { + config = lib.mkIf config.sh.oh-my-posh.enable { programs.oh-my-posh = { enable = true; - enableBashIntegration = true; + enableBashIntegration = if config.sh.bash.enable == true then true else false; + enableZshIntegration = if config.sh.zsh.enable == true then true else false; settings = { "$schema" = "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json"; "blocks" = [ diff --git a/nixos/home/packages/tools/shell.nix b/nixos/home/packages/tools/shell.nix index e9eb07d..75c4573 100644 --- a/nixos/home/packages/tools/shell.nix +++ b/nixos/home/packages/tools/shell.nix @@ -5,45 +5,67 @@ ... }: { options = { - sh.bash.enable = - lib.mkEnableOption "enables shell tools"; + sh.bash.enable = lib.mkEnableOption "enables shell bash"; + sh.zsh.enable = lib.mkEnableOption "enables shell zsh"; }; - config = lib.mkIf config.sh.bash.enable { - programs.bash = { - enable = true; - enableCompletion = true; + config = lib.mkMerge [ + (lib.mkIf config.sh.bash.enable { + programs.bash = { + enable = true; + enableCompletion = true; - shellAliases = { - #vim = "nvim"; - ls = "${pkgs.eza}/bin/eza --icons"; - ll = "${pkgs.eza}/bin/eza -alh --icons"; - l = "${pkgs.eza}/bin/eza -lh --icons=auto"; - tree = "${pkgs.eza}/bin/eza --tree --icons"; - open = "rifle"; - ip = "ip -c"; - s = "kitten ssh"; - diff = "diff --color"; - respawn = "clear; ${pkgs.pfetch}/bin/pfetch"; - mkdir = "mkdir -p"; - cat = "${pkgs.bat}/bin/bat --style plain"; - rasp = "s foglar@192.168.8.140"; - hist = "history | awk '{for (i=2; i<=NF; i++) printf \$i\" \"; print \"\"}' | fzf | wl-copy"; - cdx = "${pkgs.zoxide}/bin/zoxide query --interactive"; + shellAliases = { + ls = "${pkgs.eza}/bin/eza --icons"; + ll = "${pkgs.eza}/bin/eza -alh --icons"; + l = "${pkgs.eza}/bin/eza -lh --icons=auto"; + tree = "${pkgs.eza}/bin/eza --tree --icons"; + open = "rifle"; + ip = "ip -c"; + s = "kitten ssh"; + diff = "diff --color"; + respawn = "clear; ${pkgs.pfetch}/bin/pfetch"; + mkdir = "mkdir -p"; + cat = "${pkgs.bat}/bin/bat --style plain"; + rasp = "s foglar@192.168.8.140"; + hist = "history | awk '{for (i=2; i<=NF; i++) printf \$i\" \"; print \"\"}' | fzf | wl-copy"; + cdx = "${pkgs.zoxide}/bin/zoxide query --interactive"; - #distrobox-enter = "distrobox-enter --root"; - #distrobox-create = "distrobox-create --root"; - #distrobox-list = "distrobox-list --root"; + #distrobox-enter = "distrobox-enter --root"; + #distrobox-create = "distrobox-create --root"; + #distrobox-list = "distrobox-list --root"; + }; + + bashrcExtra = '' + ${pkgs.pfetch}/bin/pfetch''; }; - bashrcExtra = '' - ${pkgs.pfetch}/bin/pfetch''; - }; + home.sessionVariables = { + XDG_DATA_HOME = "$HOME/.local/share"; + XDG_PICTURES_DIR = "$HOME/Pictures/Screenshots/"; + }; + }) + (lib.mkIf config.sh.zsh.enable { + programs.zsh = { + enable = true; + enableCompletion = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; - home.sessionVariables = { - FLAKE = "/home/foglar/dotfiles"; - XDG_DATA_HOME = "$HOME/.local/share"; - XDG_PICTURES_DIR = "$HOME/Pictures/Screenshots/"; - }; - }; + shellAliases = { + ls = "${pkgs.eza}/bin/eza --icons"; + ll = "${pkgs.eza}/bin/eza -alh --icons"; + l = "${pkgs.eza}/bin/eza -lh --icons=auto"; + tree = "${pkgs.eza}/bin/eza --tree --icons"; + open = "rifle"; + ip = "ip -c"; + s = "kitten ssh"; + diff = "diff --color"; + respawn = "clear; ${pkgs.pfetch}/bin/pfetch"; + mkdir = "mkdir -p"; + cat = "${pkgs.bat}/bin/bat --style plain"; + }; + }; + }) + ]; } diff --git a/nixos/system/settings/default-applications.nix b/nixos/system/settings/default-applications.nix index 82bd8e3..c87b384 100644 --- a/nixos/system/settings/default-applications.nix +++ b/nixos/system/settings/default-applications.nix @@ -46,5 +46,14 @@ "image/jpeg" = "org.gnome.Loupe.desktop"; "image/png" = "org.gnome.Loupe.desktop"; }; + + programs.zsh.enable = + if userSettings.shell == "zsh" + then lib.mkDefault true + else lib.mkDefault false; + users.defaultUserShell = + if userSettings.shell == "zsh" + then pkgs.zsh + else pkgs.bash; }; }