Install system packages

Install system packages

For many modules or tools probably you'd like to install some packages. Unfortunately, due to security reasons in Projects you can’t run commands using sudo but you can use Nix as a drop in replacement. You can read about this more on the workspace limitations page. Actually, most of the packages are available in Nix as well so what you have to do is replace the sudo apt-get install or sudo apt install to nix-env -i, and that's all. You can check out the available packages in Nix on https://search.nixos.org/packages.

For example, you can install Google Chrome as you see below:

On Debian you can run: sudo apt install chromium

Inside CodeSandbox Projects just run nix-env -i chromium

Tip: Don't forget to add this command as a setup task so you don't have to run this command on every newly created branch, Projects will make it available for you immediately!

As an alternative apporach to install packages, you can define a file in the root of your project called csb.nix and configure which packages should be automatically installed from the nix package store. In order to use this configuration on every branch you have to commit this file back to your main branch.

An example configuration is this:

with import <nixpkgs> {};

stdenv.mkDerivation {
    name = "csb";
    buildInputs = [
    shellHook = ''
        export PATH="$PWD/node_modules/.bin/:$PATH"