repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

cargo-tools: install crate only if binary not in PATH

1631ab2993f1771b0a91ba982e2e53d4c5114d7f

Oliver Krylow <o.krylow@isp-insoft.de> ·

unsigned

Browse filesCompare with HEAD

Changed files (7)

README.md

Modified
20 20 1. Install Build Tools with C++ Option (for Rust and cargo tools)
21 21 1. Install Git without internal SSH
22 22 1. Start ssh-agent service
23 +1. Enable `UTF-8` in regional settings
24 25 ## rough goals

nushell/config.nu

Modified
74 74 color_config: $default_theme
75 75 use_grid_icons: true
76 76 footer_mode: "auto" # always, never, number_of_rows, auto
77 - quick_completions: false # set this to false to prevent auto-selecting completions when only one remains
78 - partial_completions: false # set this to false to prevent partial filling of the prompt
77 + quick_completions: true # set this to false to prevent auto-selecting completions when only one remains
78 + partial_completions: true # set this to false to prevent partial filling of the prompt
79 79 animate_prompt: false # redraw the prompt every second
80 80 float_precision: 2
81 81 use_ansi_coloring: true
93 93 type: {
94 94 layout: columnar
95 95 columns: 4
96 - col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
96 + # col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
97 97 col_padding: 2
99 99 style: {

nushell/env.nu

Modified
3 3 # GLOBAL VARIABLES
5 5 let-env WIN32? = $nu.os-info.name =~ "windows"
6 6 let-env NURC_DIR = ($nu.config-path| path expand | path dirname)
7 7 let-env DOTFILES = ($env.NURC_DIR| path join ".." | path expand)
8 -let-env WORKSPACE = if $env.WIN32? { "W:/misc" } else { "~/Workspace" }
8 +let-env WORKSPACE = if $env.WIN32? { "W:/" } else { "~/Workspace" }
9 9 let-env CARGO_HOME = if $env.WIN32? { "C:/Users/okr/.cargo" } else { "~/.cargo" }
11 11 # Specifies how environment variables are:

nushell/modules/aliases.nu

Modified
4 4 # Semantic aliases
5 5 export alias view = bat
6 6 export alias list = exa --group-directories-first --classify --all --long --icons --git
7 7 export alias tree = exa --tree --group-directories-first
8 8 export alias look = xplr
9 9 export alias browse = firefox
10 -export def edit [ ...rest: string ] {
11 - if $env.WIN32? {
12 - code $rest
13 - } else {
14 - helix $rest
15 - }
16 -}
10 +export alias edit = code
18 -# wrapper to delegate to gsudo/sudo if available.
19 -export def doas [
20 - ...rest: string # arguments
21 -] {
22 - if ( which "sudo" | empty? ) {
23 - ^doas $rest
24 - } else {
25 - ^sudo $rest
26 - }
27 -}
12 +# TODO: HOST SPECIFIC ALIASES
13 +# I do not see a way right now the have different aliases per host with nu.
29 15 # CUSTOM LITTLE JAVA COMMANDS
30 16 export alias aes = java (build-string $env.DOTFILES /tools/ aes.java)
31 17 export alias download = java (build-string $env.DOTFILES /tools/ download.java)
32 18 export alias download_jar = java (build-string $env.DOTFILES /tools/ download_jar.java)
34 -# Open manual page.
35 -# On Windows, a man web page is opened.
36 -export def man [
37 - ...rest: string # Arguments to man
38 -] {
39 - if $env.WIN32? {
40 - ^start (build-string https://man.archlinux.org/man/ ($rest | to-string))
41 - } else {
42 - ^man $rest
43 - }
44 -}
46 -# Search the given query on the web with the default browser in DuckDuckGo.
47 -export def web [
48 - ...rest:string # The search query
49 -] {
50 - let query = (build-string "https://duckduckgo.com/?q=" ($rest | to-string))
51 - if $env.WIN32? {
52 - # There seems to be an issue with the nu start command on windows: It does not handle URLs
53 - # Using windows command for now:
54 - ^start $query
55 - } else {
56 - xdg-open $query
57 - }
58 -}

tools/cargo-tools.nu

Modified
1 +# names of binaries in cargo must not necessarily be equal to the crate name.
2 +# this table resolves the binary name of a crate.
3 +# also, a crate can have more than one binary, but for the purpose of checking if a crate is
4 +# already installed on the system, finding one binary is sufficient.
5 +# we also cannot use `cargo install --list` to search for the binary name, in case the crate
6 +# is not installed yet
1 7 let cargo_crates = [
2 - "sccache"
3 - "sd"
4 - "cbs"
5 - "ouch"
6 - "fd-find"
7 - "ripgrep"
8 - "eva"
9 - "mdcat"
10 - "hexyl"
11 - "hyperfine"
12 - "so"
13 - "tealdeer"
14 - "tokei"
15 - "bat"
16 - "pastel"
17 - "diskonaut"
18 - "menyoki"
19 - "grex"
20 - "xh"
21 - "comrak"
22 - "bandwhich"
23 - "linky"
24 - "viu"
25 - "licensor"
26 - "gib"
27 - "silicon"
28 - "bottom"
29 - "sic"
8 + [name bin features];
9 + ["sccache" "sccache" []]
10 + ["nu" "nu" ["--features=extra"]]
11 + ["sd" "sd" []]
12 + ["cbs" "cbs" []]
13 + ["ouch" "ouch" []]
14 + ["fd-find" "fd" []]
15 + ["ripgrep" "rg" []]
16 + ["onefetch" "onefetch" []]
17 + ["eva" "eva" []]
18 + ["mdcat" "mdcat" []]
19 + ["cargo-update" "cargo-install-update" []]
20 + ["hexyl" "hexyl" []]
21 + ["hyperfine" "hyperfine" []]
22 + ["so" "so" so-features]
23 + ["tealdeer" "tldr" []]
24 + ["tokei" "tokei" []]
25 + ["bat" "bat" []]
26 + ["pastel" "pastel" []]
27 + ["diskonaut" "diskonaut" []]
28 + ["menyoki" "menyoki" []]
29 + ["zoxide" "zoxide" []]
30 + ["grex" "grex" []]
31 + ["xh" "xh" []]
32 + ["comrak" "comrak" []]
33 + # ["bandwhich" "bandwhich" []] masked until https://github.com/imsnif/bandwhich/issues/233
34 + ["linky" "linky" []]
35 + ["viu" "viu" []]
36 + ["licensor" "licensor" []]
37 + ["gib" "gib" []]
38 + ["silicon" "silicon" []]
39 + ["bottom" "btm" []]
40 + ["sic" "sic" []]
43 +def so-features [] {
44 + if $env.WIN32? {
45 + ["--no-default-features" "--features=windows"]
46 + } else {
47 + []
48 + }
32 51 let cargo_git_crates = [
33 52 "https://github.com/mosmeh/indexa"
36 55 def install-helix-editor [] {
37 56 cd $env.WORKSPACE
38 - git clone https://github.com/helix-editor/helix
57 + if ( $env.WORKSPACE | path join "helix/.git" | path exists ) {
58 + git -C helix pull
59 + } else {
60 + git clone https://github.com/helix-editor/helix
61 + }
39 62 cd helix
40 63 cargo install --locked --path helix-term
41 - hx --grammar fetch
42 - hx --grammar build
64 + hx --grammar fetch | ignore
65 + hx --grammar build | ignore
68 +# install all my favorite crate, only if they are not already in PATH.
45 69 def main [] {
46 - $cargo_crates | each { |crate|
47 - if ( which $crate | empty? ) {
48 - cargo install --locked $crate
70 + $cargo_crates | each { | crate |
71 + if ( which $crate.bin | empty? ) {
72 + echo $'cargo install --locked ($crate.name) ($crate.features)'
73 + cargo install --locked $crate.name $crate.features
49 74 } else {
50 - echo $"($crate) already installed"
75 + echo $"($crate.name) already installed"
53 -
78 + # crates, that are not even on crates.io are not likely to be packeged anywhere else.
79 + # so we skip the check if the binary is already in path
54 80 $cargo_git_crates | each { |crate|
55 81 cargo install --locked --git $crate
57 -
58 83 install-helix-editor

topgrade/topgrade.linux.toml

Modified
12 12 # Do not set the terminal title
13 13 set_title = true
15 +# Display the time in step titles
16 +display_time = true
15 18 # Cleanup temporary or old files
16 19 cleanup = true
21 +[composer]
22 +self_update = false
18 24 [git]
19 25 # Additional git repositories to pull
20 26 repos = ["/home/oli/Workspace/*"]

topgrade/topgrade.windows.toml

Modified
12 12 # Do not set the terminal title
13 13 set_title = true
15 +# Display the time in step titles
16 +display_time = true
15 18 # Cleanup temporary or old files
16 19 cleanup = true
21 +[composer]
22 +self_update = true
18 24 [git]
19 25 # Additional git repositories to pull
20 -repos = ["W:/misc/*/", "W:/*/"]
26 +repos = ["W:/*/"]
22 28 max_concurrency = 12
30 36 enable_winget = true
32 38 # Commands to run before anything
33 -#[pre_commands]
34 -#"Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak"
39 +[pre_commands]
40 +"00 - Refresh dotfiles" = "java W:/dotfiles/bootstripper.java W:/dotfiles"
41 +"01 - Winget Backup" = "winget export --source winget 'D:/Tools/winget_installed_apps.json' *> $null"
36 43 # Custom commands
37 44 [commands]
38 -"00 - Refresh dotfiles" = "java W:/dotfiles/bootstripper.java W:/dotfiles"
40 45 "01 - Install Cargo Tools" = "nu W:/dotfiles/tools/cargo-tools.nu"
42 47 # Diese Skripte beziehen APM und MeMate aus dem Transfer.