The mount command won't work when activating a swap partition/file, so we should call swapon instead.
This idea kind of makes sense, because swap partitions in /etc/fstab
get swaponed at boot.
But, the implementation doesn't take the types into account. The mounted
property takes a FilePath for the mountpoint, but for swap that
needs to be "none", which is not really a file-path. Also, the fstabbed
property has a separate SwapPartition type, so making mount support
swap partitions without using that type feels wrong.
It might be simpler all round to treat swap partitions being able to
be specified in /etc/fstab as a historical accident, which it kind of
is (increasingly so, since eg systemd has other ways to accomplish
that), and instead of shoehorning this into the mounted property,
add a new swaponed property.
Yes, perhaps if it took an Option FilePath (am I saying this correctly in Haskellese?) it would be nicer.
I don't mind much how it's structured; this was just the smallest obvious change, since it was failing to mount it. Perhaps breaking it up into smaller, more primitive, pieces would help. Fstab.mounted could = Fstab.fstabbed onChange Fstab.mounted, for instance, and then I could write Fstab.fstabbed onChange Swap.swapEnabled (oh, but Fstab.fstabbed already exists; I'm not using it because it replaces the whole file, which seems like an odd thing to do. Maybe call it Fstab.listed instead?).
Also, for maximum irony I was just perusing your most recent dozen commits or so, and saw you enable Apt.serviceInstalledRunning "swapspace" on one of your machines. That's amazing; I had no idea it existed! I am re-evaluating all of my life choices now.
I like the idea of composing smaller properties to build the current
property, and add flexability.
Renaming the existing fstabbed would probably be too much bother.
(Also, I think I picked that name because it kind of hints that the
existing fstab does not come out alive.)
(The swapspace package is great if you can eat the now tiny overhead of a
swap file compared to a swap partition.)
Merged. Have not tested it either.
On my Debian system, the swapon command does not support the
--no-headings that you used. It's --noheadings here. Is that a typo in
I've simply removed that option for now, since it probably won't
hurt if it treats the heading like another device that's swapped on.