Thursday | 21 NOV 2024
[ previous ]
[ next ]

Playing with NixOS

Title:
Date: 2024-01-11
Tags:  nix, qemu

First thing, using nix under qemu is terrible and it's likely that it's my fault. I'm running the VM with 4 gigs of RAM but it is still extremely slow. Probably some virtualization setting isn't turned on or something. Luckily I wanted to just kick the tires so to speak so I powered through it.

With that out of the way, I installed a few things and it was an interesting moment. I knew that I was updating /etc/nixos/configuration.nix to make changes to the system but until I actually opened up that file and enabled X, I didn't really take it in.

Once I set up X11 and firefox, I realized how cool it was that I was able to declaritively set up my personal computer. That was neat. I'm not sure what the rules are about the configuration.nix file as it seems like there are a few ways to do things.

services.xserver.enable = true;
services.xserver.windowManager.i3.enable = true;

This is both cool but also weird in that the services function seems to know what xserver already is. It hints at a layer of magic underneath the configuration.

Another example of this magic is what makes an application a program vs something to be installed as a system package.

I first added fish to the list of system packages like how I added vim.

environment.systemPackages = with pkgs; [
   vim
   fish
];

I then found out the better way is to do:

programs.fish.enable = true;

I can then set the user's shell by doing:

users.users.<myusername> = {   
   shell = pkgs.fish;
};

The answer is probably that someone went to the trouble of updating the programs list and added support for fish. If I had my own custom shell, then I would install it the environment way.

This is very much like ansible. For ansible I know a bit more that someone wrote the python code for each specific application handling and I can feel it in the ansible script when using things. The configuration.nix file feels more generic and yet it is still super specific.

Maybe this weird disconnect would go away if it was something like:

programs.someRepo.fish.enable

or I would have preferred to install it to the environment.

Really I should read the configuration.nix manual.

Anyway! I installed a few different things like rofi and firefox. I did nixos-rebuild a few times and now I have 4-5 nix versions in my boot screen. Very cool.

I can already see how useful this is. I have thought about documenting my Arch installation so that I can duplicate it later. Now the configuration file is my documentation. That is insanely useful.

I can also see hints of why nix flakes might be useful. Currently the configuration.nix file doesn't have any version numbers. This means in 5 years if I use this configuration file to build my system, I have no idea what would actually get installed. I need to pin application version numbers and it should update over time. This way I can be sure that a specific configuration.nix file will be different at every point in time and it would work exactly like it did at that point in time.

This feels like a very powerful feature if it exists.