{ pkgs
, lib
, config
, ... }: with lib; let
  cfg = config.home.libreoffice;
  persist = [ ".config/libreoffice" ];
in {
  options.home.libreoffice = {
    enable = mkEnableOption "open source office suite";
    allUsers = mkEnableOption "set up for all users";
  };

  config = {
    users.homeModules = [
      # this module passes minecraft configuration to home-manager
      { passthrough.libreoffice = cfg; }
    ];

    users.home.persist.directories = with cfg; mkIf (enable && allUsers) persist;
    users.home.persistApp.directories = with cfg; mkIf (enable && !allUsers) persist;
  };
}