nushell: move to modules/home
Signed-off-by: Bloxx12 <charlie@charlieroot.dev> Change-Id: I6a6a6964b332aee4de78ddbba4d16b55f6783485
This commit is contained in:
parent
71505a4629
commit
8c3ff343b0
10 changed files with 183 additions and 128 deletions
|
@ -26,7 +26,6 @@
|
|||
})
|
||||
fish
|
||||
kakoune
|
||||
nushell
|
||||
;
|
||||
}) pkgsFor;
|
||||
devShells = lib.mapAttrs (_: pkgs: {
|
||||
|
|
1
modules/home/nushell/completions.nu
Normal file
1
modules/home/nushell/completions.nu
Normal file
|
@ -0,0 +1 @@
|
|||
|
|
@ -24,6 +24,102 @@ $env.config = {
|
|||
}
|
||||
}
|
||||
|
||||
$env.config.color_config = {
|
||||
binary: '#b48ead'
|
||||
block: '#81a1c1'
|
||||
cell-path: '#e5e9f0'
|
||||
closure: '#88c0d0'
|
||||
custom: '#8fbcbb'
|
||||
duration: '#ebcb8b'
|
||||
float: '#bf616a'
|
||||
glob: '#8fbcbb'
|
||||
int: '#b48ead'
|
||||
list: '#88c0d0'
|
||||
nothing: '#bf616a'
|
||||
range: '#ebcb8b'
|
||||
record: '#88c0d0'
|
||||
string: '#a3be8c'
|
||||
|
||||
bool: {|| if $in { '#88c0d0' } else { '#ebcb8b' } }
|
||||
|
||||
datetime: {|| (date now) - $in |
|
||||
if $in < 1hr {
|
||||
{ fg: '#bf616a' attr: 'b' }
|
||||
} else if $in < 6hr {
|
||||
'#bf616a'
|
||||
} else if $in < 1day {
|
||||
'#ebcb8b'
|
||||
} else if $in < 3day {
|
||||
'#a3be8c'
|
||||
} else if $in < 1wk {
|
||||
{ fg: '#a3be8c' attr: 'b' }
|
||||
} else if $in < 6wk {
|
||||
'#88c0d0'
|
||||
} else if $in < 52wk {
|
||||
'#81a1c1'
|
||||
} else { 'dark_gray' }
|
||||
}
|
||||
|
||||
filesize: {|e|
|
||||
if $e == 0b {
|
||||
'#e5e9f0'
|
||||
} else if $e < 1mb {
|
||||
'#88c0d0'
|
||||
} else {{ fg: '#81a1c1' }}
|
||||
}
|
||||
|
||||
shape_and: { fg: '#b48ead' attr: 'b' }
|
||||
shape_binary: { fg: '#b48ead' attr: 'b' }
|
||||
shape_block: { fg: '#81a1c1' attr: 'b' }
|
||||
shape_bool: '#88c0d0'
|
||||
shape_closure: { fg: '#88c0d0' attr: 'b' }
|
||||
shape_custom: '#a3be8c'
|
||||
shape_datetime: { fg: '#88c0d0' attr: 'b' }
|
||||
shape_directory: '#88c0d0'
|
||||
shape_external: '#88c0d0'
|
||||
shape_external_resolved: '#88c0d0'
|
||||
shape_externalarg: { fg: '#a3be8c' attr: 'b' }
|
||||
shape_filepath: '#88c0d0'
|
||||
shape_flag: { fg: '#81a1c1' attr: 'b' }
|
||||
shape_float: { fg: '#bf616a' attr: 'b' }
|
||||
shape_garbage: { fg: '#FFFFFF' bg: '#FF0000' attr: 'b' }
|
||||
shape_glob_interpolation: { fg: '#88c0d0' attr: 'b' }
|
||||
shape_globpattern: { fg: '#88c0d0' attr: 'b' }
|
||||
shape_int: { fg: '#b48ead' attr: 'b' }
|
||||
shape_internalcall: { fg: '#88c0d0' attr: 'b' }
|
||||
shape_keyword: { fg: '#b48ead' attr: 'b' }
|
||||
shape_list: { fg: '#88c0d0' attr: 'b' }
|
||||
shape_literal: '#81a1c1'
|
||||
shape_match_pattern: '#a3be8c'
|
||||
shape_matching_brackets: { attr: 'u' }
|
||||
shape_nothing: '#bf616a'
|
||||
shape_operator: '#ebcb8b'
|
||||
shape_or: { fg: '#b48ead' attr: 'b' }
|
||||
shape_pipe: { fg: '#b48ead' attr: 'b' }
|
||||
shape_range: { fg: '#ebcb8b' attr: 'b' }
|
||||
shape_raw_string: { fg: '#8fbcbb' attr: 'b' }
|
||||
shape_record: { fg: '#88c0d0' attr: 'b' }
|
||||
shape_redirection: { fg: '#b48ead' attr: 'b' }
|
||||
shape_signature: { fg: '#a3be8c' attr: 'b' }
|
||||
shape_string: '#a3be8c'
|
||||
shape_string_interpolation: { fg: '#88c0d0' attr: 'b' }
|
||||
shape_table: { fg: '#81a1c1' attr: 'b' }
|
||||
shape_vardecl: { fg: '#81a1c1' attr: 'u' }
|
||||
shape_variable: '#b48ead'
|
||||
|
||||
foreground: '#e5e9f0'
|
||||
background: '#2e3440'
|
||||
cursor: '#e5e9f0'
|
||||
|
||||
empty: '#81a1c1'
|
||||
header: { fg: '#a3be8c' attr: 'b' }
|
||||
hints: '#4c566a'
|
||||
leading_trailing_space_bg: { attr: 'n' }
|
||||
row_index: { fg: '#a3be8c' attr: 'b' }
|
||||
search_result: { fg: '#bf616a' bg: '#e5e9f0' }
|
||||
separator: '#e5e9f0'
|
||||
}
|
||||
|
||||
$env.config.ls = {
|
||||
clickable_links: true
|
||||
use_ls_colors: true
|
||||
|
@ -111,7 +207,7 @@ let menus = [
|
|||
{
|
||||
name: completion_menu
|
||||
only_buffer_difference: false
|
||||
marker: "(ansi yellow)╋ "
|
||||
marker: $"(ansi yellow)╋ "
|
||||
type: {
|
||||
layout: ide
|
||||
min_completion_width: 0
|
||||
|
@ -195,12 +291,10 @@ def switch [] {
|
|||
|
||||
# fix sudo by prepending /run/wrappers/bin to the PATH.
|
||||
$env.PATH = ($env.PATH | split row (char esep) | prepend '/run/wrappers/bin')
|
||||
$env.PATH = ($env.PATH | split row (char esep) | prepend '/etc/profiles/per-user/cr/bin')
|
||||
|
||||
$env.CARAPACE_BRIDGES = 'inshellisense,fish,carapace,clap,bash'
|
||||
$env.CARAPACE_MATCH = 1
|
||||
carapace _carapace nushell
|
||||
| save -f ($nu.user-autoload-dirs | path join carapace.nu)
|
||||
|
||||
# Set environment variables according to the path of the clone
|
||||
$env.TOPIARY_CONFIG_FILE = ($env.HOME | path join .config | path join topiary languages.ncl)
|
||||
$env.TOPIARY_LANGUAGE_DIR = ($env.HOME | path join .config | path join topiary languages)
|
||||
# The prompt indicators are environmental variables that represent
|
||||
# the state of the prompt.
|
||||
source ./prompt.nu
|
||||
source ./zoxide.nu
|
22
modules/home/nushell/nu.hjem.nix
Normal file
22
modules/home/nushell/nu.hjem.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
|
||||
packages = with pkgs; [
|
||||
nushell
|
||||
inshellisense
|
||||
carapace
|
||||
];
|
||||
environment.sessionVariables = {
|
||||
CARAPACE_BRIDGES = "inshellisense,carapace,clap,bash";
|
||||
CARAPACE_MATCH = 1;
|
||||
};
|
||||
|
||||
files = {
|
||||
".config/nushell/config.nu".source = ./config.nu;
|
||||
".config/nushell/prompt.nu".source = ./prompt.nu;
|
||||
".config/nushell/zoxide.nu".source = ./zoxide.nu;
|
||||
};
|
||||
}
|
54
modules/home/nushell/zoxide.nu
Normal file
54
modules/home/nushell/zoxide.nu
Normal file
|
@ -0,0 +1,54 @@
|
|||
# Initialize hook to add new entries to the database.
|
||||
export-env {
|
||||
$env.config = (
|
||||
$env.config?
|
||||
| default {}
|
||||
| upsert hooks { default {} }
|
||||
| upsert hooks.env_change { default {} }
|
||||
| upsert hooks.env_change.PWD { default [] }
|
||||
)
|
||||
let __zoxide_hooked = (
|
||||
$env.config.hooks.env_change.PWD | any { try { get __zoxide_hook } catch { false } }
|
||||
)
|
||||
if not $__zoxide_hooked {
|
||||
$env.config.hooks.env_change.PWD = ($env.config.hooks.env_change.PWD | append {
|
||||
__zoxide_hook: true,
|
||||
code: {|_, dir| zoxide add -- $dir}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
def zoxide_completions [context: string] {
|
||||
let parts = $context | split row " " | skip 1
|
||||
{
|
||||
options: {
|
||||
sort: false,
|
||||
completion_algorithm: substring,
|
||||
case_sensitive: false,
|
||||
},
|
||||
completions: (^zoxide query --list --exclude $env.PWD -- ...$parts | lines | first 10)
|
||||
}
|
||||
}
|
||||
|
||||
# Jump to a directory using only keywords.
|
||||
def --env --wrapped __zoxide_z [...rest: string@zoxide_completions] {
|
||||
let path = match $rest {
|
||||
[] => {'~'},
|
||||
[ '-' ] => {'-'},
|
||||
[ $arg ] if ($arg | path expand | path type) == 'dir' => {$arg}
|
||||
_ => {
|
||||
zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n"
|
||||
}
|
||||
}
|
||||
cd $path
|
||||
}
|
||||
|
||||
# Jump to a directory using interactive search.
|
||||
def --env --wrapped __zoxide_zi [...rest:string] {
|
||||
cd $'(zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
alias z = __zoxide_z
|
||||
alias zi = __zoxide_zi
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
self,
|
||||
sources,
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
@ -10,10 +10,9 @@ let
|
|||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) listOf str package;
|
||||
inherit (config.meta.mainUser) username;
|
||||
|
||||
nushell = pkgs.callPackage (self + "/packages/nushell") { };
|
||||
in
|
||||
{
|
||||
imports = [ (sources.hjem + "/modules/nixos") ];
|
||||
options.meta = {
|
||||
users = mkOption {
|
||||
type = listOf str;
|
||||
|
@ -52,7 +51,7 @@ in
|
|||
};
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = nushell;
|
||||
default = pkgs.nushell;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -72,7 +71,7 @@ in
|
|||
"nix"
|
||||
"docker"
|
||||
];
|
||||
shell = nushell;
|
||||
shell = pkgs.nushell;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -7,12 +7,10 @@ let
|
|||
inherit (pkgs) lib;
|
||||
kakoune = pkgs.callPackage ./kakoune.nix { };
|
||||
fish = pkgs.callPackage ./fish { inherit lib; };
|
||||
nushell = pkgs.callPackage ./nushell { };
|
||||
in
|
||||
{
|
||||
inherit
|
||||
kakoune
|
||||
fish
|
||||
nushell
|
||||
;
|
||||
}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
inherit (lib.meta) getExe;
|
||||
|
||||
nu-config =
|
||||
pkgs.writeText "nu-init"
|
||||
# nu
|
||||
''
|
||||
#!/usr/bin/env nu
|
||||
source ${./config.nu}
|
||||
source ${./prompt.nu}
|
||||
|
||||
let autoload_dir = $nu.user-autoload-dirs.0
|
||||
mkdir $autoload_dir
|
||||
|
||||
let zoxide_path = $autoload_dir | path join zoxide.nu
|
||||
if not ($zoxide_path | path exists) {
|
||||
${getExe pkgs.zoxide} init nushell --cmd cd | save -f $zoxide_path
|
||||
}
|
||||
# Atuin is too slow, sadly.
|
||||
# let atuin_path = $autoload_dir | path join atuin.nu
|
||||
# if not ($atuin_path | path exists) {
|
||||
# ${getExe pkgs.atuin} init nu | save -f $atuin_path
|
||||
# }
|
||||
let carapace_path = $autoload_dir | path join carapace.nu
|
||||
if not ($carapace_path | path exists) {
|
||||
${getExe pkgs.carapace} _carapace nushell | save -f $carapace_path
|
||||
}
|
||||
'';
|
||||
packages = import ./packages.nix pkgs;
|
||||
in
|
||||
(pkgs.symlinkJoin {
|
||||
name = "nushell";
|
||||
paths = [ pkgs.nushell ] ++ packages;
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/nu --add-flags "\
|
||||
--config ${nu-config}"
|
||||
'';
|
||||
}).overrideAttrs
|
||||
(_: {
|
||||
passthru = {
|
||||
shellPath = "/bin/nu";
|
||||
};
|
||||
meta.mainProgram = "nu";
|
||||
})
|
|
@ -1,65 +0,0 @@
|
|||
pkgs:
|
||||
builtins.attrValues {
|
||||
inherit (pkgs)
|
||||
# better cd
|
||||
zoxide
|
||||
# pipe viewer
|
||||
pv
|
||||
# hex editor
|
||||
bvi
|
||||
#better ls
|
||||
eza
|
||||
atuin
|
||||
# better cat
|
||||
bat
|
||||
# clipboard
|
||||
# yazi
|
||||
serpl
|
||||
diff-so-fancy
|
||||
tig
|
||||
direnv
|
||||
sesh
|
||||
mprocs
|
||||
curlie
|
||||
entr
|
||||
procs
|
||||
sd
|
||||
# mult
|
||||
glow
|
||||
# dua-cli
|
||||
dust
|
||||
kondo
|
||||
# better grep
|
||||
ripgrep
|
||||
# IP stuff
|
||||
dig
|
||||
# simply the best fetch tool out there
|
||||
microfetch
|
||||
fzf
|
||||
element
|
||||
difftastic
|
||||
hexyl
|
||||
yazi
|
||||
gnumake
|
||||
asciinema
|
||||
inetutils
|
||||
tokei
|
||||
starship
|
||||
wget
|
||||
cpufetch
|
||||
watchman
|
||||
tealdeer
|
||||
hyperfine
|
||||
imagemagick
|
||||
ffmpeg-full
|
||||
timg
|
||||
nmap
|
||||
fd
|
||||
jq
|
||||
rsync
|
||||
figlet
|
||||
unzip
|
||||
zip
|
||||
ouch
|
||||
;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue