NixOS for the confused – Part IV
In Part III, we got rid of Hyprland, and installed AwesomeWM. It worked, but it was not looking good at all: we've got the default look and feel, and that's most definitely not what we want. We want to customize this thing, and make it look nice. More importantly, though: we want to Nixify it because we want to be able to clone the repo on a new computer, and get everything installed in 3 minutes flat. What we won't do is call the customization of graphical environments what people usually call it. That shit's racist.
Anyway, let's start getting our AwesomeWM a little bit better. Baby steps. First, we'll need to figure out where the main config file is. AwesomeWM is configured via a Lua file called rc.lua
, so let's see how we can go about messing with that.
The NixOS wiki tells us that the install will generate a default rc.lua
we can use as a stepping stone:
Awesome provides a default config file rc.lua which is generated at /run/current-system/sw/etc/xdg/awesome/rc.lua. Copy the file > to ~/.config/awesome/ and make changes.
It also tells us to copy the file to ~/.config/awesome/
, and make changes there. That's definitely one option, but that's not what we want. If we go down this road, our plan of having one repo kinda goes to shit. There are ways around it, but they are convoluted, and it's way easier to use the home-manager
built-in xdg.configFile.<name>.source
.
Ok, what does that even mean? Well, reader, it means that we can write our rc.lua
, add it to a subdirectory in our repo, and tell home-manager
to write the rc.lua
file to ~/.config/awesome/
when we run home-manager rebuild
. Still confused? Let's break it down.
If we go the route of copying the rc.lua
file to ~/.config/awesome/
by hand, it won't be managed by home-manager
, and we will have to, perhaps, have another repo to hold our ~/.config/
files. AwesomeWM is not the only thing that will drop config files there.
On the other hand, if we go the xdg.configFile.<name>.source
route, we can just add, say, a dots
directory to our flakies
repo, and handle everything there. home-manager
will take care of moving the rc.lua
config file to the right place.
Why one over the other? Well, using xdg.configFile.<name>.source
will make this thing more portable and reproducible. HOWEVER... every single change to the rc.lua
you want to make will need a home-manager rebuild
. So, best approach would be to mess with rc.lua
manually at first, and, when you're happy with the config, move it to xdg.configFile.<name>.source
. This way you can change the rc.lua
quickly, experiment with the configs, etc.
Anyway, for the sake of this exercise, let's assume we're ok with the rc.lua
, and run with xdg.configFile.<name>.source
. Obviously, our xdg.configFile.<name>.source
will be actually xdg.configFile."awesome/rc.lua".source
. Here's what we need to do to prepare the terrain:
- Go to the directory containing our flakes
- Create the
dots
directory - Copy the default
rc.lua
to thedots
directory
In other words...
cd ~/flakies
mkdir dots
cp /run/current-system/sw/etc/xdg/awesome/rc.lua ~/flakies/dots/
Now we have a fresh rc.lua
in the ~/flakies/dots/
directory to play with. We just need to tell home-manager
what we want to do with it. Let's add the following line to our ~/flakies/home-manager/home.nix
:
xdg.configFile."awesome/rc.lua".source = ../dots/rc.lua;
cd ~/flakies
and run home-manager switch --flake .#monkeyd@luffy
, and you should see a link to our rc.lua
appear over at ~/.configs/awesome/
. Neat! Now we can mess around with the ~/flakies/dots/rc.lua
, rebuild with home-manager switch --flake .#monkeyd@luffy
, and everything will fall into place. We do not make changes to the ~/.config/awesome/rc.lua
. That's a symlink to ~/flakies/dots/rc.lua
, which is the file we work on. I mean, you can mess with ~/.config/awesome/rc.lua
directly, but that is going to fuck shit up at some point.
Right on, Cola Gangsters! What's the lesson here, though? The lesson is: even when NixOS and/or Home Manager have no idea how to handle config files for your stuff (as opposed to, say, i3), you can still benefit from our little git+flakes+home-manager setup. If we didn't use xdg.configFile.<name>.source
, our rc.lua
would have to be handled manually, or you'd need another git repo, or you'd need some other hacky way of doing that. Using xdg.configFile.<name>.source
allows us to keep things neatly in one place.
That's it for now, gangsters. Next time we'll add a theme to this thing.