From db9e19eff03669e772787ec55a56713584f68692 Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Thu, 22 Feb 2024 11:33:31 +0100 Subject: [PATCH] carapace: Use home-manager module --- home-manager/modules/nushell/config.nu | 13 ----- home-manager/modules/nushell/default.nix | 65 ++++++++++-------------- 2 files changed, 28 insertions(+), 50 deletions(-) diff --git a/home-manager/modules/nushell/config.nu b/home-manager/modules/nushell/config.nu index 66081e9..4d61d1f 100644 --- a/home-manager/modules/nushell/config.nu +++ b/home-manager/modules/nushell/config.nu @@ -1,15 +1,3 @@ -let carapace_completer = {|spans| - let expanded_alias = (scope aliases | where name == $spans.0 | get -i 0 | get -i expansion) - - let spans = (if $expanded_alias != null { - spans | skip 1 | prepend ($expanded_alias | split row " " | take 1) - } else { - $spans - }) - - carapace $spans.0 nushell ...$spans | from json -} - # The default config record. This is where much of your global configuration is setup. $env.config = { explore: { @@ -34,7 +22,6 @@ $env.config = { algorithm: "fuzzy" # prefix or fuzzy external: { enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up my be very slow - completer: $carapace_completer # check 'carapace_completer' above as an example } } filesize: { diff --git a/home-manager/modules/nushell/default.nix b/home-manager/modules/nushell/default.nix index 9a43a66..477be39 100644 --- a/home-manager/modules/nushell/default.nix +++ b/home-manager/modules/nushell/default.nix @@ -7,8 +7,6 @@ with lib; let cfg = config.eboskma.programs.nushell; - - zoxideOptions = concatStringsSep " " config.programs.zoxide.options; in { options.eboskma.programs.nushell = { @@ -16,56 +14,49 @@ in }; config = mkIf cfg.enable { - programs.nushell = { - enable = true; - package = pkgs.nushellFull; - configFile.source = ./config.nu; - envFile.source = ./env.nu; + programs = { + nushell = { + enable = true; + package = pkgs.nushellFull; + configFile.source = ./config.nu; + envFile.source = ./env.nu; - extraEnv = '' - $env.command_not_found_db = ${config.programs.command-not-found.dbPath} - $env.NIX_SYSTEM = "${pkgs.system}" + extraEnv = '' + $env.command_not_found_db = ${config.programs.command-not-found.dbPath} + $env.NIX_SYSTEM = "${pkgs.system}" - let zoxide_cache = "${config.xdg.cacheHome}/zoxide" - if not ($zoxide_cache | path exists) { - mkdir $zoxide_cache - } - ${config.programs.zoxide.package}/bin/zoxide init nushell ${zoxideOptions} | save --force ${config.xdg.cacheHome}/zoxide/init.nu - # Temporary fix until zoxide releases new version - sed -i 's/def-env/def --env/g' ${config.xdg.cacheHome}/zoxide/init.nu + $env.NU_LIB_DIRS = ($env.NU_LIB_DIRS | append ${pkgs.nu_scripts}/share/nu_scripts) + ''; + extraConfig = '' + alias vim = nvim + alias tree = ${pkgs.eza}/bin/eza -F -b --git --tree --icons - $env.NU_LIB_DIRS = ($env.NU_LIB_DIRS | append ${pkgs.nu_scripts}/share/nu_scripts) - ''; - extraConfig = '' - alias vim = nvim - alias tree = ${pkgs.eza}/bin/eza -F -b --git --tree --icons + $env.LS_COLORS = (${pkgs.vivid}/bin/vivid generate gruvbox-dark | str trim) - $env.LS_COLORS = (${pkgs.vivid}/bin/vivid generate gruvbox-dark | str trim) + register ${pkgs.nushellPlugins.query}/bin/nu_plugin_query + register ${pkgs.nushellPlugins.formats}/bin/nu_plugin_formats + register ${pkgs.nushellPlugins.net}/bin/nu_plugin_net - register ${pkgs.nushellPlugins.query}/bin/nu_plugin_query - register ${pkgs.nushellPlugins.formats}/bin/nu_plugin_formats - register ${pkgs.nushellPlugins.net}/bin/nu_plugin_net + use kink.nu - use kink.nu + # use ${pkgs.nu_scripts}/share/nu_scripts/themes/nu-themes/dracula.nu + use themes/nu-themes/dracula.nu - # use ${pkgs.nu_scripts}/share/nu_scripts/themes/nu-themes/dracula.nu - use themes/nu-themes/dracula.nu + $env.config = ($env.config | merge { color_config: (dracula)}) + ''; + }; - $env.config = ($env.config | merge { color_config: (dracula)}) - - source ${config.xdg.cacheHome}/zoxide/init.nu - ''; + carapace = { + enable = true; + }; }; - # Temporary until zoxide releases new version - programs.zoxide.enableNushellIntegration = false; - xdg.configFile."nushell/scripts" = { source = ./scripts; }; home.packages = with pkgs; [ - carapace + # carapace nu_scripts ]; };