Wednesday | 04 DEC 2024
[ previous ]
[ next ]

Thoughts on Nix

Title:
Date: 2024-02-11
Tags:  nix

I love the idea of being able to declaratively defining my environment and being able to use utilities without cluttering up my system. These are the two largest draws of Nix and NixOS but I think there is some useability issues. This is a known issue but I think more than useability, I don't get why it's so complex or requires it's own special language. I think I'm not getting something. The idea of having a paper written about something that sounds simple is strange to me.

Author's Note
12FEB2024
While thinking about how to make pacmanfile better, I slowly came up with nixlang and configuration.nix. The idea naturally falls out of wanting to be declarative about your system. I can see now why nixlang is needed. I wanted to have a list of packages to install and I wanted to group them up as well. I also wanted to specify services that needed to be enabled on boot. This explained why the services object exists in the configuration.nix file. It was a eye-opening moment when I realized that while trying to think of a better way to declare my packages and system, I realized that all this stuff was already in nix. Now I'm wondering if there is a simple parser I could write that would let me use something akin to configuration.nix under Arch with pacman as the backend.

I was sort of able to get declarative packages by using pacmanfile under Arch. There is a file that I can add or remove packages to and then my system will reflect that file. I'm sure it's not as deep as Nix but it seems to be doing an okay job for now. I would love to be able to pin specific versions of programs which I think is available using flakes on nix but not possible in pacmanfile at all.

I like the idea of home-manager which is a nix utility to manage environments and the user's home directory. You can install userspace applications with home-manager which is pretty great and rollback and forth between versions easily. I fell out of it because you can't use home-manager for everything. It's only for user level applications. This meant that I would need to install sway and x11 with pacman while relying on home-manager for firefox. I want these to be unified. This is where pacmanfile worked because I could keep both system level stuff and user level stuff in the same file. Albeit that now everything is a system level install.

home-manager also looks really heavy for managing dotfiles and the nix-lang isn't a language that I'm super into learning. It's like learning yaml for ansible, I'm doing it because I have to. I did learn about stow and that is way more speed. I create the dotfile hierarchy and then use stow to symlink it out.

This combination of stow and pacmanfile is getting me 80% towards what I want from a reproducible environment. I can quickly get working with a comfortable environment just by installing arch, getting my dotfile directory and running a sync command. This is largely what I was looking for from nixos.

I am still missing the ability to run and use applications without clutttering my environment. I think this could be solved by using nix under arch with the nix shell stuff but I haven't tested that out yet.

I would really like to know what is in those nix papers and why it looks so mathy for something that sounds like it should be relatively straightforward.