Suppose, like, me, you are a NixOS girlthing 1. Suppose then, (tragedy of tragedies) that you are forced by grave and terrible extenuating circumstances to use a non-deterministic, impure, imperative (gasp) operating system (i.e. not NixOS) on your trusty ThinkPad.
"Never fear!" you declare 2, "I'll just run Nix on something
else". Hmm, but what something else? Perhaps Fedora, you think
to yourself, since that has an actually-up-to-date kernel 3. So, you go to
install Fedora, find yourself face-to-face
with a delightful installer partitioning tool, and have some fun
with partitions, putting the Nix store on a shiny separate LVM volume 4 so
you can resize it later if you
install 17 versions of Haskell need more
You boot Fedora, install Nix, set up home-manager, and are off to the races. "Wonderful! Superb!", you declare, and, your work for the day done, you shut down your laptop. Unbeknownst to you, however, you've just made a grave mistake.
See, when nix installs itself on non-NixOS systems, it sets up a pair of
systemd unit files (
nix-daemon.socket) that manage
the daemon. Unfortunately, init systems 5. Particularly, systemd is in
charge of managing both unit files and mounts. To do this, it reads its unit
files 6, including mounts, and then starts stuff. This means we have an
ordering issue: it'll try to read our
nix-daemon unit file before
mounted, and find yourself with a case of missing services.
The fix, then, is to mount
/nix before systemd starts, but since systemd is
normally in charge of mounts, we've gotta do a little trickery. In particular,
we'll use the initrd. The initrd is normally in charge of mounting the root
partition so we can actually boot off of it, plus some other tidbits of early
Thankfully, Fedora's initrd system, Dracut78 is pretty
flexible, so we can ask it to mount extra volumes by adding relevant entries to
/etc/fstab.sys, which is almost exactly like normal
/etc/fstab but gets processed sooner 9. You may need to create
the file, but you can just copy the relevant line from
/etc/fstab, since they
have the same format.
We'll also need to tell the kernel it's allowed to process the volume we want
to mount -- by default, Fedora is set up using
which restricts the initrd to working with only the lvs listed 10. Add an
extra kernel flag in
/etc/defaults/grub (grub2) or
Once you've done those, regenerate dracut 12 as well as grub
or systemd-boot 13, then reboot. You should fine that systemd
the Nix demon starts nix-daemon automatically and you can run
nix run nixpkgs#hello and
nix develop to your heart's content.
or any other NixOS-loving entity, of any genders or none at all
it's important to speak like you're in a 4-color comic at all times
the kernel, of course, you need because you have made the Grave Mistake ™ of using a laptop with a discrete graphics card 14, which is made by the the folks over at nvidia 15, and, having the frankly absurd requirement of needing to use external monitors, so you'll need working nouveau for your system 16.
with luks2 underneath your lvm pv, of course
a traditional cause of much woe and teeth gnashing amongst linux folks
/etc/fstab, which turns into a set of virutal units, so that
systemd has a single source of what it's supposed to do when
yes, that's the Gentoo wiki. Still one of the best sources
also, yes, half the stuff for Fedora is named after towns in MA. It's a thing
specifically, partway-through-Dracut sooner.
normally, this is just the root and swap volumes,
if your vg is named primary, and the lv is nix, you should end
up with a piece of kernel command line that looks something like
rd.lvm.lv=primary/root rd.lvm.lv=primary/swap rd.lvm.lv=primary/nix
dracut --regenerate-all --force
kernel-install is a way do this, not sure if there's a less cumbersome way
"why,", you might ask yourself, "do I need working nouveau for external monitors?". Well, self, laptop manufacturers hate you. More specifically, they frequently wire things up so that the integrated graphics drive the laptop monitor, and the discrete graphics drive any and all external connections (HDMI, displayport, thunderbolt).
"That's not so bad...", you might think. "Anyway, I can just use the shiny new (kinda) open-source nvidia drivers" 17 But! wait just a darned minute! there's more! You see, self, nvidia often hates standards. Specifically, the standards that a lot of the smaller wlroots-compositors 18 use to draw things to the screen via wayland 19.
So, unless we want weird graphical artifacts, disappearing cursors, and passive- agressive command line flags, we'll need nouveau, which actually works here, but only recent kernels and such support a bunch of the newer-ish graphics cards from the past couple years.
hey Fedora folks, did you finally have that "nvidia open source driver release party"?
well, it's not entirely nvidia's fault, the wlroots folks are a bit curmudgeonly, too
oh yeah, I forgot to mention, we're using wayland