I have been looking at this for the last couple of days and now I think I see what is happening at least partially.
After reading through the code, I don’t think you can change the defaults globally.
So, here is what I found about that. I have a bunch of btrfs mounts. If I specify options for some of them, the result is inconsistent. Let me demonstrate with a sample.
Here is an excerpt from hardware-configuration.nix
fileSystems."/" =
{ device = "/dev/disk/by-uuid/d44aea1d-f740-46a0-9174-48fe9cb3888f";
fsType = "btrfs";
options = [ "subvol=nixos-root" "compress=zstd:1" ];
};
fileSystems."/nix" =
{ device = "/dev/disk/by-uuid/d44aea1d-f740-46a0-9174-48fe9cb3888f";
fsType = "btrfs";
options = [ "subvol=nixos-nix" ];
};
fileSystems."/var/log" =
{ device = "/dev/disk/by-uuid/d44aea1d-f740-46a0-9174-48fe9cb3888f";
fsType = "btrfs";
options = [ "subvol=nixos-varlog" ];
};
fileSystems."/home" =
{ device = "/dev/disk/by-uuid/d44aea1d-f740-46a0-9174-48fe9cb3888f";
fsType = "btrfs";
options = [ "subvol=nixos-home" "compress=lzo" ];
};
They get correctly converted to /etc/fstab
/dev/disk/by-uuid/d44aea1d-f740-46a0-9174-48fe9cb3888f / btrfs subvol=nixos-root,compress=zstd:1 0 0
/dev/disk/by-uuid/d44aea1d-f740-46a0-9174-48fe9cb3888f /home btrfs subvol=nixos-home,compress=lzo 0 0
/dev/disk/by-uuid/d44aea1d-f740-46a0-9174-48fe9cb3888f /nix btrfs subvol=nixos-nix 0 0
/dev/disk/by-uuid/d44aea1d-f740-46a0-9174-48fe9cb3888f /var/log btrfs subvol=nixos-varlog 0 0
The generated mount files are also correct.
However, here is what mount
, findmnt
and /proc/mounts
all show.
/dev/mapper/luks-sda2 on / type btrfs (rw,relatime,compress=lzo,space_cache,subvolid=299,subvol=/nixos-root)
/dev/mapper/luks-sda2 on /nix type btrfs (rw,relatime,compress=lzo,space_cache,subvolid=302,subvol=/nixos-nix)
/dev/mapper/luks-sda2 on /var/log type btrfs (rw,relatime,compress=lzo,space_cache,subvolid=301,subvol=/nixos-varlog)
/dev/mapper/luks-sda2 on /home type btrfs (rw,relatime,compress=lzo,space_cache,subvolid=300,subvol=/nixos-home)
Essentially, they all end up with the same options. I tested this on Fedora and I don’t see this behavior there. 
That is a good idea. Thanks!