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 profile install nixpkgs#hello 
$ hello 
Hello, world!
# it works!

# see everything installed for the current user
$ nix profile list
0 flake:nixpkgs#legacyPackages.x86_64-linux.hello github:NixOS/nixpkgs/98b00b6947a9214381112bdb6f89c25498db4959#legacyPackages.x86_64-linux.hello /nix/store/63l345l7dgcfz789w1y93j1540czafqh-hello-2.12.1

# uninstall 'hello'. note no 'nixpkgs.' this time
$ nix profile remove 0
removing 'flake:nixpkgs#legacyPackages.x86_64-linux.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: 2024/02/23 11:05 by tcmal