User Tools

Site Tools


howto:languages

5. Installing new packages

If you want to run some code you wrote, you probably need some language or runtime to do so - eg Python, GCC, Haskell. It might happen to be installed system wide, but when it's not, we use a tool called Nix to install packages per-user without having version conflicts.

Nix is able to do a lot more things, but for most cases you can use it like so:

# install 'hello' from nixpkgs
$ nix-env -iA nixpkgs.hello 
installing 'hello-2.12.1'
$ hello 
Hello, world!
# it works!

# see everything installed for the current user
$ nix-env -q 
hello-2.12.1

# uninstall 'hello'. note no 'nixpkgs.' this time
$ nix-env --uninstall hello

To search for packages, go here.

We're using a super small subset of what Nix can do here. It's also able to do things like per-project environments, building your projects, and generating docker images. For more info, see:

  • How Nix works, the official explanation of the core concepts
  • nix.dev - tutorials and recipes for common tasks
  • Zero to Nix, a more up-to-date but slightly incomplete resource

Alternatives

The language versions that Nix can install might not be the ones you want, or it might be missing a package you need. In this case, you might want to try an alternative:

  • Rust has rustup
  • Node.JS has NVM
  • Ruby has RVM
  • asdf supports many other languages
  • You can just compile it from source and install it somewhere in your home directory.

If you're having problems, feel free to ask an admin.

howto/languages.txt · Last modified: 2023/09/14 17:10 by andrewferguson