{ config, lib, pkgs, ... }:

let
  cfg = config.sydnix.users.crumb.mumble;
in {
  options.sydnix.users.crumb.mumble.enable
    = lib.mkEnableOption "Mumble, à la crumb";

  config = lib.mkIf cfg.enable {
    sydnix.impermanence.directories =
      let
        xdg-config-home =
          lib.removePrefix "${config.home.homeDirectory}"
            (lib.removePrefix "~"
              (config.xdg.configHome));
        xdg-data-home =
          lib.removePrefix "${config.home.homeDirectory}"
            (lib.removePrefix "~"
              (config.xdg.dataHome));
      in [
        # Mutable config.
        "${xdg-config-home}/Mumble"
        # Persist Mumble's database, plugins, themes, etc.
        "${xdg-data-home}/Mumble"
      ];

    home.packages = [ pkgs.mumble ];
  };
}

