Skip to content

pkgxdev/dev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dev

dev uses pkgx and shellcode to automatically, install and activate the packages you need for different projects as you navigate in your shell.

Installation

pkgx dev integrate

We support macOS & Linux, Bash & Zsh. PRs are very welcome for more shells.

Important

pkgx is a required dependency.

brew install pkgxdev/made/pkgx || sh <(curl https://pkgx.sh)

Note

pkgx dev integrate looks for and edits known shell.rc files adding one line:

eval "$(pkgx dev --shellcode)"

If you don’t trust us (good on you), then do a dry run first:

pkgx dev integrate --dry-run

If you like, preview the shellcode: pkgx dev --shellcode.

Usage

$ cd my-project

my-project $ ls
package.json

my-project $ dev
+nodejs.org
# ^^ installs node to ~/.pkgx/nodejs.org/v22.12.0 if not already installed

my-project $ node --version
v22.12.0

$ which node
~/.pkgx/nodejs.org/v22.12.0/bin/node

$ cd ..
-nodejs.org

$ node
command not found: node

Tip

Try Before You vi

Modifying your shell.rc can be… intimidating. If you just want to temporarily try dev out before you :wq—we got you:

$ cd my-project
$ eval "$(pkgx dev)"

The devenv will only exist for the duration of your shell session.

How Packages are Determined

  • We look at the files you have and figure out the packages you need.
  • Where possible we also determine the versions you need if such things can be determined by looking at configuration files.

Specifying Versions

We allow you to add YAML front matter to all files to specify versions more precisely:

# pkgx:
#   openssl.org: 1.1.1n

[package]
name = "my cargo project"
# snip…

We allow more terse expressions including eg:

# pkgx: [email protected] deno^2 npm

The major exception being json since it doesn’t support comments, in this case we read a special pkgx node:

{
  "pkgx": {
    "openssl.org": "1.1.1n",
    "deno": "^2",
    "npm": null
  }
}

You can also make a pkgx.yaml file.

Adding Custom Environment Variables

You can add your own environment variables if you like:

# pkgx:
#   openssl.org: 1.1.1n
# env:
#   MY_VAR: my-value

Caution

The assignment of these variables are run through the shell, so you can do stuff like $(pwd) if you like. Obviously, be careful with that—we don’t sanitize the input. We will accept a PR to escape this by default or something ∵ we agree this is maybe a bit insane.

GitHub Actions

- uses: pkgxdev/dev@v1

Installs needed packages and sets up the environment the same as dev does in your terminal.

Contributing

We use deno, so either install that or—you know—type dev.

Edit ./src/sniff.ts to add new dev types.