-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nerd-fonts: add individual font packages
- Loading branch information
Showing
6 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
lib, | ||
stdenvNoCC, | ||
fetchzip, | ||
}: | ||
|
||
let | ||
releaseVersion = lib.trivial.importJSON ./release-version.json; | ||
makeNerdFont = | ||
{ | ||
pname, | ||
version, | ||
description, | ||
license, | ||
url, | ||
sha256, | ||
}: | ||
stdenvNoCC.mkDerivation { | ||
inherit pname version; | ||
|
||
src = fetchzip { | ||
inherit url sha256; | ||
stripRoot = false; | ||
}; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
dst_opentype=$out/share/fonts/opentype/${pname} | ||
dst_truetype=$out/share/fonts/truetype/${pname} | ||
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.updateScript = ./update.sh; | ||
|
||
meta = { | ||
inherit description license; | ||
homepage = "https://nerdfonts.com/"; | ||
changelog = "https://github.com/ryanoasis/nerd-fonts/blob/v${releaseVersion}/changelog.md"; | ||
maintainers = with lib.maintainers; [ rc-zb ]; | ||
}; | ||
}; | ||
in | ||
|
||
builtins.listToAttrs ( | ||
map (font: lib.attrsets.nameValuePair font.pname (makeNerdFont font)) ( | ||
lib.trivial.importJSON ./fonts.json | ||
) | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"3.2.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const FORMER_RELEASE_VERSION = JSON.parse(std.in.getline()); | ||
const RELEASE_INFO_URL = "https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest"; | ||
const PKGS_INFO_FILENAME = "fonts.json"; | ||
|
||
const getFontsInfoUrl = (tag) => `https://raw.githubusercontent.com/ryanoasis/nerd-fonts/refs/tags/${tag}/bin/scripts/lib/fonts.json`; | ||
|
||
const fetchJSON = (url) => JSON.parse(std.urlGet(url).split("\r\n").at(-1)); | ||
|
||
const convertFontName = (formerName) => { | ||
if (/^\d/u.test(formerName)) { | ||
return "_" + formerName; | ||
} else { | ||
return formerName; | ||
} | ||
}; | ||
|
||
const convertFontVersion = (formerVersion, dateString) => { | ||
if (/^\d/u.test(formerVersion)) { | ||
return formerVersion; | ||
} else { | ||
return "0-unstable-" + dateString; | ||
} | ||
}; | ||
|
||
let releaseInfo = fetchJSON(RELEASE_INFO_URL); | ||
let tag = releaseInfo.tag_name; | ||
let releaseVersion = tag.split("v")[1]; | ||
|
||
if (releaseVersion === FORMER_RELEASE_VERSION) { | ||
std.exit(1); | ||
} else { | ||
let fonts = fetchJSON(getFontsInfoUrl(tag)).fonts; | ||
let pkgsInfo = fonts.map(font => { | ||
let url = releaseInfo.assets | ||
.find(asset => asset.name === font.folderName + ".tar.xz") | ||
.browser_download_url; | ||
|
||
let sha256 = (() => { | ||
let f = std.popen(`nix-prefetch-url ${url} --unpack`, "r"); | ||
let result = f.getline(); | ||
f.close(); | ||
return result; | ||
})(); | ||
|
||
return ({ | ||
pname: convertFontName(font.caskName), | ||
version: convertFontVersion(font.version, releaseInfo.published_at.split("T")[0]), | ||
description: font.description, | ||
license: font.licenseId, | ||
url: url, | ||
sha256: sha256, | ||
}); | ||
}); | ||
|
||
(() => { | ||
let f = std.open(PKGS_INFO_FILENAME, "w"); | ||
f.puts(JSON.stringify(pkgsInfo)); | ||
f.close(); | ||
})() | ||
print(JSON.stringify(releaseVersion)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#! /usr/bin/env bash | ||
set -eu -o pipefail | ||
dir_name="$(dirname "$0")" | ||
update_script_filename=update.js | ||
release_version_filename=release-version.json | ||
|
||
cd "$dir_name" | ||
cat $release_version_filename | qjs --script --std $update_script_filename | tail -n 1 > $release_version_filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters