wiki/content/en/guides/pkgman.md

2.0 KiB

title
How to do Package Management on the Pubnix

Pubnix, the virtual machine where users SSH into, runs on NixOS despite constant protests from the Guix clan. Nix has a weird way of installing software, which has several pros and several cons. We are not gonna focus on these but one of the pros is that you can install software in your own local user without needing root access.

This guide focuses on some rather basic functions that Nix can do. We won't go over anything advanced.

Searching for Packages

To search for packages, you would run nix --extra-experimental-features "nix-command flakes" search nixpkgs <packagename> (replacing <packagename> with your package of choice)

Note: This command takes a while to download the index (around 40 seconds), but this is only an issue the first time.

You could also put this into a bash alias, so you don't have to type it all the time, one such alias would be:

alias nix-search="nix --extra-experimental-features "nix-command flakes" search nixpkgs $1"

And with that alias, you could run nix-search <packagename> instead!

Checking what package owns a specific file

To search for a specific file in a package, you would run nix-locate 'bin/filename'

Note: this uses our global file database in /var/lib/nix-index which is updated weekly with a cronjob.

Installing packages into your current environment

To install a package into your current environment, you would run nix-env -iA nixos.<package name minus legacyPackages.x86_64-linux>

Note: packages installed by this method exist only as long as the user environment does

"Installing" a package but in a temporary shell

This is a quite useful feature for when you only need a command once and never again.

To install a package in a temporary shell, you would run nix-shell -p <package name minus legacyPackages.x86_64-linux>

Note: As soon as the shell is closed, the package will be gone from your path, though its cached so you can use it later easily.