1
0
Fork 0
mirror of https://github.com/ryanccn/flake.git synced 2026-01-26 19:56:29 +01:00

treewide: refactor, nix, overlays -> packages

This commit is contained in:
Ryan Cao 2024-11-12 13:56:54 +08:00
parent d6238e12af
commit eb6b664802
Signed by: ryanccn
GPG key ID: 48C96B2057D71CB1
23 changed files with 240 additions and 308 deletions

4
packages/default.nix Normal file
View file

@ -0,0 +1,4 @@
pkgs: {
ibm-plex-compat = pkgs.callPackage ./ibm-plex-compat.nix { };
ryan-mono-bin = pkgs.callPackage ./ryan-mono-bin.nix { };
}

View file

@ -0,0 +1,46 @@
{
ibm-plex,
fd,
python312Packages,
}:
ibm-plex.overrideAttrs (_: {
pname = "ibm-plex-compat";
postInstall = ''
set -eo pipefail
PATH="${fd}/bin:${python312Packages.fonttools}/bin:$PATH"
cd "$out/share/fonts/opentype"
ansi_green="\033[32m"
ansi_reset="\033[0m"
medium_fonts=$(fd --extension=otf Medium)
for medium_font in $medium_fonts; do
echo -e "''${ansi_green}Patching''${ansi_reset} $medium_font (Medm -> Medium)"
ttx_path="''${medium_font%.*}.ttx"
ttx "$medium_font"
substituteInPlace "$ttx_path" --replace-fail 'Medm' 'Medium'
ttx -f "$ttx_path"
rm "$ttx_path"
done
semibold_fonts=$(fd --extension=otf SemiBold)
for semibold_font in $semibold_fonts; do
echo -e "''${ansi_green}Patching''${ansi_reset} $semibold_font (SmBld -> Semibold)"
ttx_path="''${semibold_font%.*}.ttx"
ttx "$semibold_font"
substituteInPlace "$ttx_path" --replace-fail 'SmBld' 'Semibold'
ttx -f "$ttx_path"
rm "$ttx_path"
done
echo -e "''${ansi_green}Done!''${ansi_reset}"
'';
})

View file

@ -0,0 +1,63 @@
{
callPackage,
symlinkJoin,
}:
let
version = "2024.05.26";
mkFontVariant =
{ variant, hash }:
callPackage (
{
lib,
fetchzip,
stdenvNoCC,
}:
stdenvNoCC.mkDerivation {
pname = variant;
inherit version;
src = fetchzip {
url = "https://github.com/ryanccn/ryan-mono/releases/download/v${version}/${variant}.tar.xz";
inherit hash;
};
installPhase = ''
runHook preInstall
install -Dm644 *.ttf -t $out/share/fonts/truetype
runHook postInstall
'';
meta = with lib; {
homepage = "https://github.com/ryanccn/ryan-mono";
platforms = platforms.all;
license = licenses.ofl;
};
}
) { };
in
symlinkJoin {
name = "ryan-mono-bin-${version}";
paths = [
(mkFontVariant {
variant = "RyanMono";
hash = "sha256-smlvBfpwVoD0qfmmHcJjsLdiblXjy5eevZfK4qDc9x8=";
})
(mkFontVariant {
variant = "RyanTerm";
hash = "sha256-12xaJqgR5R6SZnZ7vJeD5zg2TZbWEiUrdyK+ljekMvc=";
})
(mkFontVariant {
variant = "RyanMonoNerdFont";
hash = "sha256-n2d9K1rJuWCF2NgkRLQQCNCAxYfiBVv/jpn+BzqBvAI=";
})
(mkFontVariant {
variant = "RyanTermNerdFont";
hash = "sha256-yrzgNRD560FhHLSK1neHVSnB+ZiHP2bmKzD1pGTu9Ro=";
})
];
}