NixOS for the confused – Part V

Ahoy, cola gangsters! Previously… We were doing a little messing around with rc.lua, and I remember that I did promise you we were going to take this thing from this…

…to something better. So, let’s go about that.

Listen, Awesome is awesome, but this is ugly. We need to beautify this thing, but we need to do it the Nix way®.

What do we need to do, then? Well, let us start by installing and configuring a terminal that is not xterm. Let's do Alacritty! For that to be extra dope, let's get some fonts, too!

In order to do that, we can write some modules that we can call from our home.nix file. It's not strictly necessary, but I think it helps keep things tidy. Cool! Enough faffing about. Let's just make sure we are working on the same shit. Clone/download/copy the Part 4 repo and head on to flakies/home-manager

You should have one file there: home.nix. Let's add some stuff to it: we'll add Nerd Fonts to make sure our terminal looks like we know what we're doing. We just need to add it to the home.packages section of our home.nix, thusly:

home.packages = with pkgs; [
		bat
		fzf
		ripgrep
		jq
		tree
		exa
              (nerdfonts.override { fonts = ["JetBrainsMono" "Inconsolata"]; })
		];

Quick note: See the override there? We are telling Nix that we want to install the Package Nerd Fonts, but we only want the Jet Brains Mono and Inconsolata fonts. If we don't specify this, every single fucking font will be installed. That's a lot. You can pick and choose which fonts you want, but let's go with these for the time being.

With that being said, let's get Alacritty installed. We're going to use imports for that. As the name seems to indicate, we're importing a piece of nix code into the home.nix file. Our home.nix should look something like this:

nixpkgs = {
		config = {
			allowUnfree = true;
			allowUnfreePredicate = (_: true);
		};
	};
  imports = [
	./alacritty.nix
     ];

We could just add Alacritty to the home.packages section like we did with Nerd Fonts, but what's the fun in that? It just so happens that Home Manager can handle Alacritty directly. Right! Our alacritty.nix will look like this:

{pkgs, ... }:
{
programs.alacritty = {
		enable = true;
		settings = {
			env.TERM = "xterm-256color";
			window.padding = {
				x = 10;
				y=10;
			};
			window.decorations = "none";
			window.opacity = 0.7;
			scrolling.history = 1000;
			font = {
				normal = {
					family = "JetBrains Mono Nerd Font";
					style = "Regular";
				};
				bold = {
					family = "JetBrains Mono Nerd Font";
					style = "Bold";
				};
				italic = {
					family = "JetBrains Mono Nerd Font";
					style = "Italic";
				};
				size = 14;
			};
		};
	};
}

Nothing fancy, just defining borders, opacity, fonts, etc. Swell! Our repo now should have a file alacritty.nix under the home-manager directory. We don't have to fuck with configuration.nix or anything like that: this is completely handled by Home Manager. Let's get this thing going, then!

Sidebar: Inside your flakies directory, run nix flake update. This will update our stuff.

Run the now classic home-manager switch --flake .#monkeyd@luffy, and your Nerd Fonts & Alacritty should be good to go.

OR ARE THEY?

They are not! We need to change the rc.lua and tell Awesome that we want Alacritty to be the default terminal. Head over to our dots directory, and change terminal = "xterm" to terminal = "alacritty". That should do the trick. Restart Awesome (default is Shift + Super + R), and the default keybinding for the terminal is Super + Enter. What's Super? Come on. The default Super is the Windows key. Ok. This is getting pretty long, so next time we will add a theme to this bitch. Promise!

As usual, look down there  for the link to our Codeberg repo, my mastodon, that kind of jazz.