# This file has been initially generated by node2nix 1.9.0.

{ pkgs, stdenv, lib, nodejs, ttfautohint-nox }:

let
  nodeEnv = import ./node-env.nix {
    inherit (pkgs) stdenv lib python2 runCommand writeTextFile;
    inherit pkgs nodejs;
    libtool = null;
  };
  nodePackages = import ./node-packages.nix {
    inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
    inherit nodeEnv;
  };
  nodeIosevka = nodePackages.package;
in
stdenv.mkDerivation rec {
  pname = "iosevka-custom";
  inherit (nodeIosevka) version src;

  nativeBuildInputs = [ nodejs nodeIosevka ttfautohint-nox ];

  buildPlan = builtins.readFile ../../../iosevka/private-build-plans.toml;
  passAsFile = [ "buildPlan" ];

  configurePhase = ''
    runHook preConfigure
    cp "$buildPlanPath" private-build-plans.toml
    ln -s ${nodeIosevka}/lib/node_modules/iosevka/node_modules .
    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild
    npm run build --no-update-notifier -- --jCmd=$NIX_BUILD_CORES ttf::$pname
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall
    fontdir="$out/share/fonts/truetype"
    install -d "$fontdir"
    install "dist/$pname/ttf"/* "$fontdir"
    runHook postInstall
  '';

  meta = with lib; {
    description = ''
      Slender monospace sans-serif and slab-serif typeface inspired by Pragmata
      Pro, M+ and PF DIN Mono, designed to be the ideal font for programming.
    '';
    homepage = "https://be5invis.github.io/Iosevka";
    license = licenses.ofl;
    maintainers = with maintainers; [ vyp ];
    platforms = platforms.linux;
  };
}
