2024-05-16 16:21:04 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-05-16 01:26:47 +02:00
|
|
|
let
|
2024-05-30 20:02:02 +02:00
|
|
|
nu_scripts = "${pkgs.nu_scripts}/share/nu_scripts";
|
|
|
|
|
2024-08-02 17:54:48 +02:00
|
|
|
aliases = mkAliases (
|
|
|
|
(config.home.shellAliases or { })
|
|
|
|
// {
|
|
|
|
clipcopy = "clipboard copy";
|
|
|
|
clippaste = "clipboard paste";
|
|
|
|
}
|
2024-05-16 16:21:04 +02:00
|
|
|
);
|
|
|
|
|
2024-08-02 17:54:48 +02:00
|
|
|
mkAliases =
|
|
|
|
aliases: lib.concatStringsSep "\n" (lib.mapAttrsToList (k: v: "alias ${k} = ${v}") aliases);
|
|
|
|
|
2024-05-16 01:26:47 +02:00
|
|
|
mkCompletions =
|
|
|
|
completions:
|
|
|
|
lib.concatStringsSep "\n" (
|
|
|
|
builtins.map (
|
2024-08-02 17:54:48 +02:00
|
|
|
el: "source ${nu_scripts}/custom-completions/${el.name or el}/${el.filename or el}-completions.nu"
|
2024-05-16 01:26:47 +02:00
|
|
|
) completions
|
|
|
|
);
|
|
|
|
|
2024-08-02 17:54:48 +02:00
|
|
|
completions = mkCompletions [
|
2024-05-16 01:26:47 +02:00
|
|
|
"cargo"
|
|
|
|
"composer"
|
|
|
|
"gh"
|
|
|
|
"git"
|
|
|
|
"just"
|
|
|
|
"man"
|
|
|
|
"npm"
|
|
|
|
"pnpm"
|
|
|
|
"poetry"
|
|
|
|
"rg"
|
|
|
|
"tar"
|
|
|
|
{
|
|
|
|
name = "tealdeer";
|
|
|
|
filename = "tldr";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "yarn";
|
|
|
|
filename = "yarn-v4";
|
|
|
|
}
|
|
|
|
];
|
2024-05-16 18:42:34 +02:00
|
|
|
|
2024-08-02 17:54:48 +02:00
|
|
|
mkPlugins =
|
|
|
|
plugins:
|
|
|
|
lib.concatStringsSep "\n" (builtins.map (plugin: "plugin add ${lib.getExe plugin}") plugins);
|
|
|
|
|
|
|
|
plugins = mkPlugins (with pkgs.nushellPlugins; [ clipboard ]);
|
|
|
|
|
2024-05-16 18:42:34 +02:00
|
|
|
command-not-found = pkgs.writeShellScript "command-not-found" ''
|
|
|
|
source ${config.programs.nix-index.package}/etc/profile.d/command-not-found.sh
|
|
|
|
command_not_found_handle "$@"
|
|
|
|
'';
|
2024-05-16 01:26:47 +02:00
|
|
|
in
|
|
|
|
{
|
2024-08-01 21:54:44 +02:00
|
|
|
programs.carapace = {
|
|
|
|
enable = true;
|
2024-08-02 17:54:48 +02:00
|
|
|
# prefer my own completer
|
2024-08-01 21:54:44 +02:00
|
|
|
enableNushellIntegration = false;
|
|
|
|
};
|
|
|
|
|
2024-05-16 01:26:47 +02:00
|
|
|
programs.nushell = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
configFile.source = ./nu/config.nu;
|
|
|
|
|
2024-09-03 16:38:27 +02:00
|
|
|
extraConfig = # nu
|
2024-05-16 01:26:47 +02:00
|
|
|
''
|
2024-08-02 01:02:27 +02:00
|
|
|
$env.config = $env.config? | default {}
|
|
|
|
$env.config.hooks = $env.config.hooks? | default {}
|
2024-08-01 21:54:44 +02:00
|
|
|
$env.config.hooks.command_not_found = {|cmd_name|
|
|
|
|
try { ${command-not-found} $cmd_name }
|
2024-05-16 18:42:34 +02:00
|
|
|
}
|
|
|
|
|
2024-05-30 20:02:02 +02:00
|
|
|
source ${nu_scripts}/aliases/git/git-aliases.nu
|
2024-08-02 01:02:27 +02:00
|
|
|
source ${./nu/keybindings.nu}
|
2024-09-03 16:38:27 +02:00
|
|
|
|
|
|
|
${lib.concatStringsSep "\n" [
|
|
|
|
completions
|
|
|
|
plugins
|
|
|
|
aliases
|
|
|
|
]}
|
|
|
|
'';
|
|
|
|
extraEnv = # nu
|
2024-05-16 01:26:47 +02:00
|
|
|
''
|
2024-09-03 16:38:27 +02:00
|
|
|
$env.ENV_CONVERSIONS = {
|
|
|
|
"PATH": {
|
|
|
|
from_string: { |s| $s | split row (char esep) | path expand --no-symlink }
|
|
|
|
to_string: { |v| $v | path expand --no-symlink | str join (char esep) }
|
|
|
|
}
|
|
|
|
"Path": {
|
|
|
|
from_string: { |s| $s | split row (char esep) | path expand --no-symlink }
|
|
|
|
to_string: { |v| $v | path expand --no-symlink | str join (char esep) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
2024-05-16 01:26:47 +02:00
|
|
|
};
|
|
|
|
}
|