sketchybar-app-font: build from source

This commit is contained in:
Austin Horstman 2024-06-23 13:30:33 -05:00
parent e0ba5d6aaf
commit da53b161f2
No known key found for this signature in database

View File

@ -1,90 +1,62 @@
let
artifacts = [ "shell" "lua" "font" ];
in
{ lib
, stdenvNoCC
, fetchurl
, common-updater-scripts
, curl
, jq
, writeShellScript
, artifactList ? artifacts
{
fetchFromGitHub,
lib,
pnpm,
stdenvNoCC,
nodejs,
nix-update-script,
}:
lib.checkListOfEnum "sketchybar-app-font: artifacts" artifacts artifactList
stdenvNoCC.mkDerivation
(finalAttrs:
let
selectedSources = map (artifact: builtins.getAttr artifact finalAttrs.passthru.sources) artifactList;
in
{
pname = "sketchybar-app-font";
version = "2.0.19";
srcs = selectedSources;
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "sketchybar-app-font";
version = "2.0.19";
unpackPhase = ''
runHook preUnpack
src = fetchFromGitHub {
owner = "kvndrsslr";
repo = "sketchybar-app-font";
rev = "v2.0.19";
hash = "sha256-4D3ONeGSvFYdeD3alzXlDxyLh6EyIC+lr4A6t7YWBaw=";
};
for s in $selectedSources; do
b=$(basename $s)
cp $s ''${b#*-}
done
pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-u0Rr086p6gotS+p9365+P8uKEqxDNGnWCsZDCaj8eEE=";
};
runHook postUnpack
nativeBuildInputs = [
nodejs
pnpm.configHook
];
buildPhase = ''
runHook preBuild
pnpm i
pnpm run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm644 dist/sketchybar-app-font.ttf "$out/share/fonts/truetype/sketchybar-app-font.ttf"
install -Dm755 dist/icon_map.sh "$out/bin/icon_map.sh"
install -Dm644 dist/icon_map.lua "$out/lib/sketchybar-app-font/icon_map.lua"
runHook postInstall
'';
passthru.updateScript = nix-update-script { };
meta = {
description = "Ligature-based symbol font and a mapping function for sketchybar";
longDescription = ''
A ligature-based symbol font and a mapping function for sketchybar, inspired by simple-bar's usage of community-contributed minimalistic app icons.
'';
installPhase = ''
runHook preInstall
'' + lib.optionalString (lib.elem "font" artifactList) ''
install -Dm644 ${finalAttrs.passthru.sources.font} "$out/share/fonts/truetype/sketchybar-app-font.ttf"
'' + lib.optionalString (lib.elem "shell" artifactList) ''
install -Dm755 ${finalAttrs.passthru.sources.shell} "$out/bin/icon_map.sh"
'' + lib.optionalString (lib.elem "lua" artifactList) ''
install -Dm644 ${finalAttrs.passthru.sources.lua} "$out/lib/sketchybar-app-font/icon_map.lua"
runHook postInstall
'';
passthru = {
sources = {
font = fetchurl {
url = "https://github.com/kvndrsslr/sketchybar-app-font/releases/download/v${finalAttrs.version}/sketchybar-app-font.ttf";
hash = "sha256-AH4Zkaccms1gNt7ZHZRHYPOx/iLpbcA4MiyBStHRDfU=";
};
lua = fetchurl {
url = "https://github.com/kvndrsslr/sketchybar-app-font/releases/download/v${finalAttrs.version}/icon_map.lua";
hash = "sha256-AGcHBgOZY2EBR0WEfaQhEsTRdo8QfEawx6Q2rdBuKIg=";
};
shell = fetchurl {
url = "https://github.com/kvndrsslr/sketchybar-app-font/releases/download/v${finalAttrs.version}/icon_map.sh";
hash = "sha256-fdKnweYF92zCLVBVXTjLWK9vdzMD8FvOHjEo2vqPbhQ=";
};
};
updateScript = writeShellScript "update-sketchybar-app-font" ''
set -o errexit
export PATH="${lib.makeBinPath [ curl jq common-updater-scripts ]}"
NEW_VERSION=$(curl --silent https://api.github.com/repos/kvndrsslr/sketchybar-app-font/releases/latest | jq '.tag_name | ltrimstr("v")' --raw-output)
if [[ "${finalAttrs.version}" = "$NEW_VERSION" ]]; then
echo "The new version same as the old version."
exit 0
fi
for artifact in ${lib.escapeShellArgs (lib.mapAttrsToList(a: _: a) finalAttrs.passthru.sources)}; do
update-source-version "sketchybar-app-font" "$NEW_VERSION" --ignore-same-version --source-key="sources.$artifact"
done
'';
};
meta = {
description = "Ligature-based symbol font and a mapping function for sketchybar";
longDescription = ''
A ligature-based symbol font and a mapping function for sketchybar, inspired by simple-bar's usage of community-contributed minimalistic app icons.
'';
homepage = "https://github.com/kvndrsslr/sketchybar-app-font";
license = lib.licenses.cc0;
maintainers = with lib.maintainers; [ khaneliman ];
};
})
homepage = "https://github.com/kvndrsslr/sketchybar-app-font";
license = lib.licenses.cc0;
maintainers = with lib.maintainers; [ khaneliman ];
platforms = lib.platforms.all;
};
})