{ pkgs
, lib
, config
, ... }: with lib; let
  cfg = config.global.fs;
in {
  options.global.fs.btrfs = {
    options = mkOption {
      type = with types; listOf str;
      default = [ "noatime" "compress=zstd" ];
      description = "btrfs mount options";
    };
  };

  config = mkIf (cfg.type == "btrfs") {
    fileSystems."/nix" =
    { inherit (cfg.btrfs) options;
      device = "/dev/disk/by-uuid/${cfg.store}";
      fsType = "btrfs";
    };
  };
}
