diff --git a/config/users.nix b/config/users.nix index f7f1721..fbcf31c 100644 --- a/config/users.nix +++ b/config/users.nix @@ -1,9 +1,19 @@ { config, + lib, pkgs, ... }: let keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILm0O46zW/XfVOSwz0okRWYeOAg+wCVkCtCAoVTpZsOh"]; + + nu_scripts = "${pkgs.nu_scripts}/share/nu_scripts"; + mkCompletions = completions: + lib.concatStringsSep "\n" ( + builtins.map ( + el: "source ${nu_scripts}/custom-completions/${el.name or el}/${el.filename or el}-completions.nu" + ) + completions + ); in { i18n.defaultLocale = "en_US.UTF-8"; @@ -29,29 +39,72 @@ in { initExtra = # bash '' - if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]]; then - shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION="" - exec ${pkgs.fish}/bin/fish $LOGIN_OPTION + if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "nu" && -z ''${BASH_EXECUTION_STRING} ]]; then + exec ${lib.getExe pkgs.nushell} fi ''; }; - direnv.enable = true; - fish = { + direnv = { enable = true; - interactiveShellInit = "set fish_greeting"; - plugins = [ - { - name = "plugin-git"; - src = pkgs.fishPlugins.plugin-git.src; - } - ]; + nix-direnv.enable = true; + }; + nushell = { + enable = true; + extraConfig = + # nu + '' + let carapace_completer = {|spans: list| + ^${lib.getExe pkgs.carapace} $spans.0 nushell ...$spans + | from json + | if ($in | default [] | where value == $"($spans | last)ERR" | is-empty) { $in } else { null } + } + + let nix_completer = {|spans: list| + let current_arg = $spans | length| $in - 1 + with-env { NIX_GET_COMPLETIONS: $current_arg } { $spans| skip 1| ^nix ...$in } + | lines + | skip 1 + | parse "{value}\t{description}" + } + + let external_completer = {|spans| + let expanded_alias = scope aliases + | where name == $spans.0 + | get -i 0.expansion + + let spans = if $expanded_alias != null { + $spans + | skip 1 + | prepend ($expanded_alias | split row ' ' | take 1) + } else { + $spans + } + + match $spans.0 { + nix => $nix_completer + _ => $carapace_completer + } | do $in $spans + } + + $env.config = { + show_banner: false + table: { mode: "psql" } + completions: { + case_sensitive: false + external: { + enable: true + max_results: 100 + completer: $external_completer + } + } + } + + source ${nu_scripts}/aliases/git/git-aliases.nu + ${mkCompletions ["git" "man" "rg" "tar"]} + ''; }; - nix-index.enable = true; - nix-index-database.comma.enable = true; starship.enable = true; }; - - services.vscode-server.enable = true; }; }; }