dotfiles/home/apps/nu.nix

81 lines
1.7 KiB
Nix
Raw Normal View History

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";
# milspec = (pkgs.callPackage ../../_sources/generated.nix { }).milspec;
milspec.src = /Users/winston/Code/neovim/milspec;
2024-05-16 01:26:47 +02:00
2024-05-16 16:21:04 +02:00
shellAliases = lib.concatStringsSep "\n" (
lib.mapAttrsToList (k: v: "alias ${k} = ${v}") config.home.shellAliases
);
2024-05-16 01:26:47 +02:00
mkCompletions =
completions:
lib.concatStringsSep "\n" (
builtins.map (
el:
let
name = el.name or el;
filename = el.filename or el;
in
2024-05-30 20:02:02 +02:00
"source ${nu_scripts}/custom-completions/${name}/${filename}-completions.nu"
2024-05-16 01:26:47 +02:00
) completions
);
completions = [
"cargo"
"composer"
"gh"
"git"
"just"
"man"
"nix"
"npm"
"pnpm"
"poetry"
"rg"
"tar"
{
name = "tealdeer";
filename = "tldr";
}
{
name = "yarn";
filename = "yarn-v4";
}
];
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-05-17 23:49:48 +02:00
programs.carapace.enable = true;
2024-05-16 01:26:47 +02:00
programs.nushell = {
enable = true;
configFile.source = ./nu/config.nu;
extraConfig =
''
2024-05-16 18:42:34 +02:00
$env.config = ($env.config? | default {})
$env.config.hooks = ($env.config.hooks? | default {})
$env.config.hooks.command_not_found = {
|cmd_name| (try { ${command-not-found} $cmd_name })
}
2024-05-30 20:02:02 +02:00
source ${nu_scripts}/aliases/git/git-aliases.nu
2024-05-16 01:26:47 +02:00
''
2024-05-16 16:21:04 +02:00
+ shellAliases
2024-05-16 01:26:47 +02:00
+ mkCompletions completions;
};
xdg.configFile."nushell/config".source = ./nu/config;
2024-05-16 01:26:47 +02:00
}