I don’t feel like I know enough about Nix to manage my own build dependencies with it, but I do feel like I know enough to use Nix as a simple package manager. I use Homebrew on my laptop, and at this point I definitely know more about Nix than I do about Homebrew.1 Why would I switch away from Homebrew? Mostly because I think it will be educational. I don’t really have anything against Homebrew. It works. It has a lot of the packages I want. It does break more often than I’d like – n...| ianthehenry.com
Oooookay. I said I was gonna read the manual, right? I’ll do it. I’ll read it. I already read all those functions, didn’t I? It’s time for Part VI: Command Reference.| ianthehenry.com
It’s been several days since I reinstalled a bunch of stuff with Nix instead of Homebrew, and so far everything has been fine. I mean, the software I installed, like, works the same. As far as I can tell. But I realize that I should probably update my packages, and see if there are any juicy new bytes to keep my hard drive entertained. I really didn’t expect that this would be worthy of a blog post but, well, here we are: my first upgrade. Attempt.| ianthehenry.com
We open on a chat conversation that I had with my good friend and former colleague “Doug,” in which we were discussing my experience reading through the Nix manual. ian: there were certain things that i wanted to learn how to do ian: and i still don't really know how to do them ian: like ian: it seems like ian: you should just have a file ian: called "ian.nix" ian: where you write down the things you want ian: and then there should be a way to say "install exactly this set of things" ian:...| ianthehenry.com
Note: I wrote the vast majority of this post on August 24, 2022, but I decided that it was a whiny rant that I didn’t want to publish. I came across the draft in January 2024, remembered that this entire series is a whiny rant, and decided to publish it anyway. I’ve been a happy Nix user for about 18 months now, and– well, not happy happy, but satisfied… no… not really satisfied either; perhaps it’s more of a resigned disgruntlement; a feeling that despite its many flaws, it’s s...| ianthehenry.com
The reason I discovered an ancient blog post the other day was that I had something new to say about Nix for the first time in over two years. The thing I want to say is this: nix-direnv is great. It fixes roughly every problem that I’ve had with nix-shell, and does so in a much nicer way than my previous ad-hoc solutions.| ianthehenry.com
I don’t know about the word “pills.” The word “pills” makes me think of medicine; it makes me think of the idiom “a bitter pill to swallow;” it makes me think of sweaters that just came out of the wash. It does not make me think of… documentation, or learning. I assume that the title is meant to evoke “bite-sized” or something like that. I don’t know. It’s weird a weird choice, for a series.| ianthehenry.com
So this isn’t great: $ nix-env -i python3 installing 'python3-3.10.0a5' Why isn’t this great? Well, because in the Python versioning scheme, python3-3.10.0a5 is short for “Python 3.10.0 alpha version 5.” The latest stable release of the Python reference implementation, right now, is actually 3.9.5. 3.10 is currently considered the “pre” branch, and 3.11 is currently the “dev” branch. I think; I’m not really a Python person. So it’s not great that a new Nix user might try t...| ianthehenry.com
Over the course of reading the Nix manual, reading the Nixpkgs manual, reading the Nix Pills, and performing my own experiments, I have accumulated quite a few “open questions.” I leave them at the bottom of each post, and they help ease my mind: writing them down allows me to forget them. They are not lurking in the darker corners of my brain, distracting me as I try to go about my day. They will be there for me when I need them, and that is a calming thought. Now, I’m not done learnin...| ianthehenry.com
I opened a PR a few days ago to try to fix the issue I ran into with nix-env -u trying to upgrade to a weird alpha pre-release version of Python. In my head, I was making the world a better place. It was an issue that bit me; it was an issue that bit someone who emailed me; it seemed like an issue worth fixing. But the maintainer of Python responded to that PR with: I don’t think we should be doing this. Yes, it resolves the issue for python3, but there are others out there as well. “It i...| ianthehenry.com
I’ve been using Nix for a few months now, and one of my largest outstanding pain points is that any time I’m in a nix-shell, none of my stuff works the way I want it to. On a scale from “uses the stock PS1” to “wrote their own shell,” I’m prettttty far to the right. I haven’t actually written my own shell, but, you know, I’ve started writing my own shell, and I have lots of aliases and a fancy custom fzf-based autocomplete thing and weird tmux integrations and strong feeling...| ianthehenry.com
Nix 2.4 came out on November 1, 2021, and that’s sort of a big deal. It’s been more than two years since the last major Nix release, and there are some pretty important changes. Including some breaking changes, which is why I have waited so long to upgrade. Because I think that, in order to keep using Nix, I’m finally going to have to learn what “flakes” are, and do a bunch of other stuff just to restore the functionality that I was enjoying before. Or maybe not. It might be painles...| ianthehenry.com
Okay. In the last post I got sort of an introduction to flakes, and I even wrote a flake, but I didn’t learn how to… do anything with flakes. My flake provided an overlay, but I have no idea how to make my Nixpkgs actually use that overlay. I have no idea what “my Nixpkgs” even means anymore. My channel? My flake? Everything I’ve learned about Nix has been turned upside down. But presumably if we keep reading, these blog posts will explain how to actually put them to use.| ianthehenry.com
Okay. So: so far I’ve managed to write a flake, but I have no idea how to… use it. And I’ve managed to restore nix search to functionality, basically, by pinning my nixpkgs flake… but now I am searching something different than I will be installing by using nix-env, or by referencing in my shell.nix files, and this bothers me. Which means I’m going to try the new flake-powered profiles, and figure out what the flake-equivalent version of a shell.nix is, and the new way to write nix-...| ianthehenry.com
When I was learning Nix for the first time, I never found myself frustrated with it. My brain was in learning mode: everything was strange and new and exciting. I was more interested in what Nix was than in how to actually use it; I was more interested in how it worked than what I could do with it. And more importantly: I expected it to be difficult to use. Nix has a reputation, after all, and it didn’t really bother me that it kept plunging me into a bash shell, or that it didn’t have a ...| ianthehenry.com
So a sort of crazy thing happened to the Nix UI between Nix 2.3 and 2.4. nix shell, the command that opens a shell, was renamed to nix develop. nix develop is not only more to type (no, nix dev does not work), but it’s also a… misleading name for this command. I publish and preview my blog from a Nix shell, which has dependencies like my static site generator and CSS prefixer and such. I do not think of this as “developing” my blog. I think of it as writing my blog within a Nix shell....| ianthehenry.com