From 217e22fdc00bb979455e648083dbda8bdc677c59 Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Fri, 31 May 2024 09:32:15 +0200 Subject: [PATCH] refactor(shell): move `direnv` and `starship` config to own modules --- configuration.nix | 2 + modules/shell/direnv.nix | 34 ++++++++++++++ modules/shell/fish.nix | 92 ------------------------------------- modules/shell/starship.nix | 93 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 129 insertions(+), 92 deletions(-) create mode 100644 modules/shell/direnv.nix create mode 100644 modules/shell/starship.nix diff --git a/configuration.nix b/configuration.nix index 4c6e1b6..52ef153 100644 --- a/configuration.nix +++ b/configuration.nix @@ -134,6 +134,8 @@ hardware.grub.enable = true; shell = { tmux.enable = true; + direnv.enable = true; + starship.enable = true; fish = { enable = true; direnv.enable = true; diff --git a/modules/shell/direnv.nix b/modules/shell/direnv.nix new file mode 100644 index 0000000..0fed03f --- /dev/null +++ b/modules/shell/direnv.nix @@ -0,0 +1,34 @@ +{ + config, + lib, + username, + ... +}: +with lib; +with lib.my; let + cfg = config.modules.shell.direnv; +in { + options.modules.shell.direnv = { + enable = mkEnableOption "direnv shell integration"; + }; + + config = mkIf (cfg.enable) { + environment.variables = { + DIRENV_LOG_FORMAT = ""; + }; + + home-manager.users.${username} = { + programs.direnv = { + enable = true; + nix-direnv.enable = true; + config = { + global = { + load_dotenv = true; + disable_stdin = true; + }; + whitelist.prefix = ["$HOME/dev"]; + }; + }; + }; + }; +} diff --git a/modules/shell/fish.nix b/modules/shell/fish.nix index 292d835..2c2143d 100644 --- a/modules/shell/fish.nix +++ b/modules/shell/fish.nix @@ -11,7 +11,6 @@ with lib; let in { options.modules.shell.fish = { enable = mkEnableOption "fish shell"; - direnv.enable = mkEnableOption "direnv integration"; default = mkOption { description = "Whether to set fish as a default shell for the user"; example = true; @@ -26,98 +25,7 @@ in { programs.fish.enable = true; home-manager.users.${username} = { - home.sessionVariables = { - DIRENV_LOG_FORMAT = ""; - }; - programs = { - direnv = { - enable = cfg.direnv.enable; - nix-direnv.enable = cfg.direnv.enable; - config = { - global = { - load_dotenv = true; - disable_stdin = true; - }; - whitelist.prefix = ["/home/${username}/dev"]; - }; - }; - - starship = { - enable = true; - catppuccin.enable = true; - settings = { - add_newline = true; - - directory.read_only = " 󰌾"; - docker_context.symbol = " "; - nix_shell.symbol = " "; - git_branch.symbol = " "; - hostname.ssh_symbol = "󰖟 "; - kubernetes = { - symbol = "󱃾 "; - disabled = false; - }; - - package.symbol = "󰏗 "; - c.symbol = " "; - cmake.symbol = " "; - golang.symbol = " "; - java.symbol = " "; - kotlin.symbol = " "; - lua.symbol = " "; - nodejs.symbol = "󰎙 "; - python.symbol = " "; - php.symbol = " "; - ruby.symbol = " "; - rust.symbol = " "; - dotnet.symbol = "󰪮 "; - gradle.symbol = " "; - - os.symbols = { - Alpaquita = " "; - Alpine = " "; - Amazon = " "; - Android = " "; - Arch = " "; - Artix = " "; - CentOS = " "; - Debian = " "; - DragonFly = " "; - Emscripten = " "; - EndeavourOS = " "; - Fedora = " "; - FreeBSD = " "; - Garuda = "󰛓 "; - Gentoo = " "; - HardenedBSD = "󰞌 "; - Illumos = "󰈸 "; - Linux = " "; - Mabox = " "; - Macos = " "; - Manjaro = " "; - Mariner = " "; - MidnightBSD = " "; - Mint = " "; - NetBSD = " "; - NixOS = " "; - OpenBSD = "󰈺 "; - openSUSE = " "; - OracleLinux = "󰌷 "; - Pop = " "; - Raspbian = " "; - Redhat = " "; - RedHatEnterprise = " "; - Redox = "󰀘 "; - Solus = "󰠳 "; - SUSE = " "; - Ubuntu = " "; - Unknown = " "; - Windows = "󰍲 "; - }; - }; - }; - fish = { enable = true; catppuccin.enable = true; diff --git a/modules/shell/starship.nix b/modules/shell/starship.nix new file mode 100644 index 0000000..f795670 --- /dev/null +++ b/modules/shell/starship.nix @@ -0,0 +1,93 @@ +{ + config, + lib, + username, + ... +}: +with lib; +with lib.my; let + cfg = config.modules.shell.starship; +in { + options.modules.shell.starship = { + enable = mkEnableOption "starship shell prompt"; + }; + + config = mkIf (cfg.enable) { + home-manager.users.${username} = { + programs.starship = { + enable = true; + catppuccin.enable = true; + settings = { + add_newline = true; + + directory.read_only = " 󰌾"; + docker_context.symbol = " "; + nix_shell.symbol = " "; + git_branch.symbol = " "; + hostname.ssh_symbol = "󰖟 "; + kubernetes = { + symbol = "󱃾 "; + disabled = false; + }; + + package.symbol = "󰏗 "; + c.symbol = " "; + cmake.symbol = " "; + golang.symbol = " "; + java.symbol = " "; + kotlin.symbol = " "; + lua.symbol = " "; + nodejs.symbol = "󰎙 "; + python.symbol = " "; + php.symbol = " "; + ruby.symbol = " "; + rust.symbol = " "; + dotnet.symbol = "󰪮 "; + gradle.symbol = " "; + + os.symbols = { + Alpaquita = " "; + Alpine = " "; + Amazon = " "; + Android = " "; + Arch = " "; + Artix = " "; + CentOS = " "; + Debian = " "; + DragonFly = " "; + Emscripten = " "; + EndeavourOS = " "; + Fedora = " "; + FreeBSD = " "; + Garuda = "󰛓 "; + Gentoo = " "; + HardenedBSD = "󰞌 "; + Illumos = "󰈸 "; + Linux = " "; + Mabox = " "; + Macos = " "; + Manjaro = " "; + Mariner = " "; + MidnightBSD = " "; + Mint = " "; + NetBSD = " "; + NixOS = " "; + OpenBSD = "󰈺 "; + openSUSE = " "; + OracleLinux = "󰌷 "; + Pop = " "; + Raspbian = " "; + Redhat = " "; + RedHatEnterprise = " "; + Redox = "󰀘 "; + Solus = "󰠳 "; + SUSE = " "; + Ubuntu = " "; + Unknown = " "; + Windows = "󰍲 "; + }; + }; + }; + }; + }; +}