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

let cfg = config.sydnix.users.msyds.fonts;
in {
  options.sydnix.users.msyds.fonts = {
    enable = lib.mkEnableOption "Fontconfig and some fonts";
  };

  config = lib.mkIf cfg.enable {
    fonts.fontconfig.enable = true;

    home.packages = [
      (pkgs.stdenv.mkDerivation rec {
        pname = "berkeley-mono";
        version = "2.002";
    
        src = pkgs.fetchzip {
          url = "https://deertopia.net/~msyds/berkeley-mono-${version}.zip";
          hash = "sha256-o/G9+IXTGrr0lMLiq13nhIKZ2NfXkR6wd72W+d7Stqw=";
          stripRoot = false;
        };
    
        installPhase = ''
          mkdir -p $out/share/fonts/truetype/berkeley-mono
          cp -r *.ttf $out/share/fonts/truetype/berkeley-mono
        '';
      })
      pkgs.source-han-serif-vf-otf
      pkgs.source-han-serif
      pkgs.source-han-sans
      pkgs.source-han-mono
      pkgs.noto-fonts-cjk-sans
    ];
  };
}
