I setup my new install using ZFS but no where did I see any mention of a Swap partition in the user guide or wiki (beside not to use compression). For those of you using ZFS on Nixos, do you have a swap partition? Did you create a swap data set in your ZFS pool? What should I do to add swap?
I really don’t have any data on my system yet that is important, so reinstalling is not out of the question.
You can create a zvol and mount swap on it. Instructions for that are here. In most cases, it should work fine. I did it that way for a long time. However, be careful to read the warning at the bottom of the page. In certain cases, it can cause lockups. For this reason, I now usually use dedicated swap partition.
I can confirm reproducible lockups with swap on a zvol even though all parameters have been tuned for swap usage as mentioned on the page @dalto linked. Note that we encountered this only with workloads that allocated lots of memory very quickly, in this case evaluating lots of NixOS configurations (more than 10GB in a few seconds).
I appreciate the help! So, it seems best to use a dedicated swap partition. Thank you, I want to make sure I get this right because I am nearing completion on a “Beginners Guide to installing Nixos using ZFS” and I don’t want to say something really dumb. I will post the blog post here first and get some feedback. The guide is literally every step a user would take to set this up, making no assumptions on their previous knowledge.