Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

amtoine/nupm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nupm

A manager for Nushell packages.

📯 this project has been archived => please refer to the official nupm package manager of Nushell

♻️ installation

  1. run
http get https://raw.githubusercontent.com/amtoine/nupm/main/bootstrap/bootstrap.nu | save --force ($nu.temp-path | path join "nupm-bootstrap"); nu ($nu.temp-path | path join "nupm-bootstrap")

to have a look at the bootstrap script (HIGHLY RECOMMENDED IN ALL CASES) or

nu --commands (http get https://raw.githubusercontent.com/amtoine/nupm/main/bootstrap/bootstrap.nu)

to run the bootstrap script directly.

  1. add
export-env {
    let-env NUPM_HOME = ...
    let-env NU_LIB_DIRS = ($env.NU_LIB_DIRS? | default [] | append [
        $env.NUPM_HOME
    ])
}

to env.nu

Note
it is also recommended to add the following to allow the use of the --save option on install and activate

let-env NUPM_CONFIG = {
    activations: ...
    packages: ...
}
  1. add use nupm/activations * to config.nu
  2. install packages
  3. activate items

Note
in all the following, we assume nupm has been installed and loaded with use nupm

⚙️ install packages

💡 an example with nu-git-manager

please find intructions here

💡 another example with goatfiles/nu_scripts

i'm not using the main revision of this package, rather the nightly branch... we can use nupm install --revision to make this happen!

nupm install https://github.com/goatfiles/nu_scripts --revision nightly

and then something like

nupm activate nu-goat-scripts misc back    # module import syntax
nupm activate "nu-goat-scripts misc edit"  # single-block syntax

📂 use files

as i have the activations above exported with

nupm activate --list
| to nuon -i 4
| save --force ($nu.config-path | path dirname | path join "nupm" "activations.nuon")

i can run a simpler

nupm activate --from-file ($nu.config-path | path dirname | path join "nupm" "activations.nuon")

one can also export the packages installed with

nupm install --list
| to nuon -i 4
| save --force ($nu.config-path | path dirname | path join "nupm" "packages.nuon")

Note
alternatively, one can define NUPM_CONFIG in env.nu, e.g.

let-env NUPM_CONFIG = {
    activations: ($nu.default-config-dir | path join "nupm" "activations.nuon")
    packages: ($nu.default-config-dir | path join "nupm" "packages.nuon")
    set_prompt: false
}

and then use the --save option of nupm install and nupm activate to dump the installed packaged and activated items to the files in NUPM_CONFIG, e.g.

nupm install --list --save
nupm activate --list --save

♻️ update nupm

one can use the following to update the package manager

nupm update --self
# or
nupm update nupm

or something like this to update all the packages

nupm install --list
| get name
| each {|pkg| nupm update $pkg --ignore}
# or
nupm update --all

Note
nupm update --self will automagically reload itself after the update, no need to run use nupm/! 🥳
try nupm version before and after an update --self... 😏

📆 the roadmap of nupm

  • 🔴 install packages from a NUON file
  • 🟢 hot-swap the version of packages once installed
  • 🟢 update packages
  • 🔴 add support for Nushell plugins, e.g. the nu_plugin_* in nushell/crates/
  • 🔴 list all official packages and plugins in a centralized remote store
  • 🔴 support unit and integration tests of Nushell packages

❗ some ideas of advanced (?) usage

in order to load nupm in the blink of an eye, i've added the following to my $env.config.keybindings:

{
    name: nupm
    modifier: control
    keycode: char_n
    mode: [emacs, vi_insert, vi_normal]
    event: {
        send: executehostcommand
        cmd: "overlay use --prefix nupm"
    }
}

which allows me to load nupm BLAZZINGLY FAST on <c-n> 💪