Codex is a command-line tool that lets you easily create isolated shells for development. You start by defining the list of packages required by your development environment, and codex uses that definition to create an isolated environment just for your application.
In practice, Codex works similar to a package manager like yarn
– except the packages it manages are at the operating-system level (the sort of thing you would normally install with brew
or apt-get
). With Codex, you can install over 400,000 package versions from the Nix Package Registry
Codex was originally developed by Khulnasoft and is internally powered by nix
.
You can try out Codex in your browser using the button below:
The example below creates a development environment with python 2.7
and go 1.18
, even though those packages are not installed in the underlying machine:
Use the following install script to get the latest version of Codex:
curl -fsSL https://raw.githubusercontent.com/khulnasoft/CodeX/master/codex | bash
Read more on the Codex docs.
Declare the list of tools needed by your project via a codex.json
file and run codex shell
. Everyone working on the project gets a shell environment with the exact same version of those tools.
Development environments created by Codex are isolated from everything else in your laptop. Is there a tool you want to try without making a mess? Add it to a Codex shell, and remove it when you don't want it anymore – all while keeping your laptop pristine.
Codex can create isolated environments right on your laptop, without an extra-layer of virtualization slowing your file system or every command. When you're ready to ship, it'll turn it into an equivalent container – but not before.
Are you working on multiple projects, all of which need different versions of the same binary? Instead of attempting to install conflicting versions of the same binary on your laptop, create an isolated environment for each project, and use whatever version you want for each.
Codex's dev environments are portable. We make it possible to declare your environment exactly once, and use that single definition in several different ways, including:
- A local shell created through
codex shell
- A devcontainer you can use with VSCode
- A Dockerfile so you can build a production image with the exact same tools you used for development.
- A remote development environment in the cloud that mirrors your local environment.
In this quickstart we’ll create a development shell with specific tools installed. These tools will only be available when using this Codex shell, ensuring we don’t pollute your machine.
-
Open a terminal in a new empty folder.
-
Initialize Codex:
codex init
This creates a
codex.json
file in the current directory. You should commit it to source control. -
Add command-line tools from Nix. For example, to add Python 3.10:
codex add python@3.10
Search for more packages on Nixhub.io
-
Your
codex.json
file keeps track of the packages you've added, it should now look like this:{ "packages": [ "python@3.10" ] }
-
Start a new shell that has these tools installed:
codex shell
You can tell you’re in a Codex shell (and not your regular terminal) because the shell prompt changed.
-
Use your favorite tools.
In this example we installed Python 3.10, so let’s use it.
python --version
-
Your regular tools are also available including environment variables and config settings.
git config --get user.name
-
To exit the Codex shell and return to your regular shell:
exit
Read more on the Codex docs Quickstart.
codex help
- see all commands
See the CLI Reference for the full list of commands.
- Chat with us by joining the Khulnasoft Discord Server – we have a #codex channel dedicated to this project.
- File bug reports and feature requests using Github Issues
- Follow us on Khulnasoft's Twitter for product updates
Codex is an opensource project so contributions are always welcome. Please read our contributing guide before submitting pull requests.
Thanks to Nix for providing isolated shells.
This project is proudly open-source under the Apache 2.0 License