5aba99242e
Made with
```shell
git restore .
fd '\.nix$' pkgs/ --type f -j1 -x bash -xc "$(cat <<"EOF"
typos --no-check-filenames --write-changes "$1"
git diff --exit-code "$1" && exit
#( git diff "$1" | grep -qE "^\+ +[^# ]") && git restore "$1"
count1="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> ' | wc -l )"
count2="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> (<span style="color:#f8f8f2;"> *</span>)?<span style="color:#75715e;">.*</span>$' | wc -l )"
[[ $count1 -ne $count2 ]] && git restore "$1"
EOF
)" -- {}
```
and filtered with `GIT_DIFF_OPTS='--unified=15' git -c interactive.singleKey=true add --patch`
I initially tried using the tree-sitter cli, python bindings and even ast-grep through various means, but this is what I ended up with.
104 lines
2.8 KiB
Nix
104 lines
2.8 KiB
Nix
{
|
|
lib,
|
|
stdenvNoCC,
|
|
fetchurl,
|
|
}:
|
|
|
|
let
|
|
releaseInfo = lib.trivial.importJSON ./manifests/release.json;
|
|
fontsInfo = lib.trivial.importJSON ./manifests/fonts.json;
|
|
checksums = lib.trivial.importJSON ./manifests/checksums.json;
|
|
|
|
releaseVersion = lib.removePrefix "v" releaseInfo.tag_name;
|
|
|
|
convertAttrName =
|
|
name:
|
|
let
|
|
lowerName = lib.strings.toLower name;
|
|
in
|
|
if builtins.match "^[[:digit:]].*" lowerName != null then "_" + lowerName else lowerName;
|
|
|
|
convertVersion =
|
|
version: if builtins.match "^[[:digit:]].*" version != null then "+" + version else "";
|
|
|
|
convertLicense = import ./convert-license.nix lib;
|
|
|
|
makeNerdFont =
|
|
{
|
|
caskName,
|
|
description,
|
|
folderName,
|
|
licenseId,
|
|
patchedName,
|
|
version,
|
|
...
|
|
}:
|
|
stdenvNoCC.mkDerivation {
|
|
pname = "nerd-fonts-" + lib.strings.toLower caskName;
|
|
version = releaseVersion + convertVersion version;
|
|
|
|
src =
|
|
let
|
|
filename = folderName + ".tar.xz";
|
|
url = "https://github.com/ryanoasis/nerd-fonts/releases/download/${releaseInfo.tag_name}/${filename}";
|
|
sha256 = checksums.${filename};
|
|
in
|
|
fetchurl {
|
|
inherit url sha256;
|
|
};
|
|
|
|
sourceRoot = ".";
|
|
|
|
installPhase =
|
|
let
|
|
dirName = lib.strings.concatStrings (lib.strings.splitString " " patchedName);
|
|
in
|
|
''
|
|
runHook preInstall
|
|
|
|
dst_opentype=$out/share/fonts/opentype/NerdFonts/${dirName}
|
|
dst_truetype=$out/share/fonts/truetype/NerdFonts/${dirName}
|
|
|
|
find -name \*.otf -exec mkdir -p $dst_opentype \; -exec cp -p {} $dst_opentype \;
|
|
find -name \*.ttf -exec mkdir -p $dst_truetype \; -exec cp -p {} $dst_truetype \;
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
passthru = {
|
|
inherit releaseVersion;
|
|
updateScript = {
|
|
command = ./update.py;
|
|
supportedFeatures = [ "commit" ];
|
|
};
|
|
};
|
|
|
|
meta = {
|
|
description = "Nerd Fonts: " + description;
|
|
license = lib.unique (
|
|
(with lib.licenses; [
|
|
# > Nerd Fonts source fonts, patched fonts, and folders with explicit OFL SIL files
|
|
ofl
|
|
# > Nerd Fonts original source code files (such as `.sh`, `.py`, `font-patcher` and others)
|
|
mit
|
|
])
|
|
++ lib.toList (convertLicense licenseId)
|
|
);
|
|
homepage = "https://nerdfonts.com/";
|
|
changelog = "https://github.com/ryanoasis/nerd-fonts/blob/${releaseInfo.tag_name}/changelog.md";
|
|
platforms = lib.platforms.all;
|
|
maintainers = with lib.maintainers; [
|
|
doronbehar
|
|
rc-zb
|
|
];
|
|
};
|
|
};
|
|
|
|
nerdFonts = lib.trivial.pipe fontsInfo [
|
|
(map (font: lib.nameValuePair (convertAttrName font.caskName) (makeNerdFont font)))
|
|
builtins.listToAttrs
|
|
];
|
|
in
|
|
|
|
nerdFonts
|