The Best Way to Install Apps on Linux

Installing apps on Linux can be unnecessarily difficult. Here’s how to make it easy!

Just Use Nix #

Nix is an excellent package manager. Why? Because Nix has everything. Nix contains over 80,000 packages, and it’s growing daily.

If you use Ubuntu or Pop!_OS (like I do) then you’ve been disappointed by Ubuntu’s Advanced Packaging Tool (APT). There are so many apps that it seems like APT should have, but it doesn’t. And then you have to go to a website, find the instructions for your distro, and run a bunch of terminal commands that may or may not work. Not great.

Nix simplifies everything #

If Nix supports the app you’re trying to install, then it drastically simplifies this process.

A good example is my favorite text editor, Sublime Text. The first time I installed Sublime I had to go dig through their documentation, find my distro, and go through five distinct steps to install the app. The standard install process looks like this:

wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/sublimehq-archive.gpg
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text
sudo apt-get install apt-transport-https

Got that? Yeah, me neither.

Not only is this method impossible to remember, but it’s also fragile and unique to Sublime. You can’t use this same method for any other application.

Enter Nix #

Nix gives you a standardized process to install any application. If you want to install Sublime using Nix, you only have to run a single command:

nix-env -iA nixpkgs.sublime4

If you want Sublime Merge, the command is almost the same:

nix-env -iA nixpkgs.sublime-merge

Or, my current obsession, Obsidian:

nix-env -iA nixpkgs.obsidian

You get the idea. The command is a little tricky to remember, but it’s a single command to install anything, no questions asked.

Note: You may get an error when first running this command. Nix may say “Package … has an unfree license”. Nix will give you a great error message with instructions to fix this, but the easiest method is to run export NIXPKGS_ALLOW_UNFREE=1 before installing.

Other handy features #

Nix does a few other clever things in addition to simple app installations:

  • Nix keeps backups of all previous versions of your apps. So if you ever have an app break, you can easily rollback to a previous version. A very handy feature.
  • Nix works on Mac. If you use both Mac and Linux, you can run the same commands in both places.
  • If Nix is missing an app, you can add it yourself or request that someone else adds it.

Installing Nix #

Are you interested in trying it out? If so, installation is easy. At the time of writing, installing Nix takes a single command:

curl -L https://nixos.org/nix/install | sh

You can find more info on Github or in the manual.

Installing apps using Nix #

You can search for packages on Nix’s website. Click the “Unstable” button and type in the name of the app you’re looking for. Chances are, Nix will have it.

You can also find instructions for installation on that site, but usually, you can use a single command:

nix-env -iA nixpkgs.appname

Replace “appname” with the name of your app.

Fixing application shortcuts #

If you’re on Ubuntu or Pop!_OS, Nix apps may not show up in your typical application launcher (they didn’t for me). Unfortunately, the best fix I’ve found is running the below command, and restarting your computer. Both steps seem to be required for the OS to find Nix apps (if you know of a better solution, please LMK!)

ln -s /home/$USER/.nix-profile/share/applications/* /home/$USER/.local/share/applications/

Other useful Nix commands #

  • Updating apps: nix-env -u
  • Uninstall (erasing) apps: nix-env -e appname
  • List backups: nix-env --list-generations
  • Rollback to the last backup: nix-env --rollback
  • Rollback to a specific backup: nix-env --switch-generation #

Backstory #

When I initially started switching over to Linux full-time, I discovered fairly quickly that the Pop!_OS package manager (APT) doesn’t have a lot of the apps I use.

I created dotfiles for myself initially. But my dotfiles quickly fell into disrepair, and I’m not at all confident that they will work for me in the future. Individual installation processes are too complex on Linux, and it’s about time someone standardized this.

Nix is a brilliant attempt to do that.

I'll take a good package manager over fragile dotfiles any day.

(Thanks to Chris Titus for turning me onto this. Nix is a real game changer!)

← Home

Changelog
  • Publishes article about Nix