installFonts: init hook (also migrate fonts as proof of concept) (#484477)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
# Setup hook that installs font files to their respective locations.
|
||||
#
|
||||
# Example usage in a derivation:
|
||||
#
|
||||
# { …, installFonts, … }:
|
||||
#
|
||||
# stdenvNoCC.mkDerivation {
|
||||
# …
|
||||
# outputs = [
|
||||
# "out"
|
||||
# "webfont" # If .woff or .woff2 output is desired
|
||||
# ];
|
||||
#
|
||||
# nativeBuildInputs = [ installFonts ];
|
||||
# …
|
||||
# }
|
||||
#
|
||||
# This hook also provides an `installFont` function that can be used to install
|
||||
# additional fonts of a particular extension into their respective folder.
|
||||
#
|
||||
postInstallHooks+=(installFonts)
|
||||
|
||||
installFont() {
|
||||
if (($# != 2)); then
|
||||
nixErrorLog "expected 2 arguments!"
|
||||
nixErrorLog "usage: installFont fontExt outDir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find -iname "*.$1" -print0 | xargs -0 -r install -m644 -D -t "$2"
|
||||
}
|
||||
|
||||
installFonts() {
|
||||
if [ "${dontInstallFonts-}" == 1 ]; then return; fi
|
||||
|
||||
installFont 'ttf' "$out/share/fonts/truetype"
|
||||
installFont 'ttc' "$out/share/fonts/truetype"
|
||||
installFont 'otf' "$out/share/fonts/opentype"
|
||||
installFont 'bdf' "$out/share/fonts/misc"
|
||||
installFont 'otb' "$out/share/fonts/misc"
|
||||
installFont 'psf' "$out/share/consolefonts"
|
||||
|
||||
if [ -n "${webfont-}" ]; then
|
||||
installFont 'woff' "$webfont/share/fonts/woff"
|
||||
installFont 'woff2' "$webfont/share/fonts/woff2"
|
||||
fi
|
||||
|
||||
}
|
||||
@@ -2,30 +2,26 @@
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
fetchFromGitHub,
|
||||
installFonts,
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation rec {
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
pname = "barlow";
|
||||
version = "1.422";
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"webfont"
|
||||
];
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "jpt";
|
||||
repo = "barlow";
|
||||
tag = version;
|
||||
tag = finalAttrs.version;
|
||||
hash = "sha256-FG68o6qN/296RhSNDHFXYXbkhlXSZJgGhVjzlJqsksY=";
|
||||
};
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm644 fonts/otf/*.otf -t $out/share/fonts/opentype
|
||||
install -Dm644 fonts/ttf/*.ttf fonts/gx/*.ttf -t $out/share/fonts/truetype
|
||||
install -Dm644 fonts/eot/*.eot -t $out/share/fonts/eot
|
||||
install -Dm644 fonts/woff/*.woff -t $out/share/fonts/woff
|
||||
install -Dm644 fonts/woff2/*.woff2 -t $out/share/fonts/woff2
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
nativeBuildInputs = [ installFonts ];
|
||||
|
||||
meta = {
|
||||
description = "Grotesk variable font superfamily";
|
||||
@@ -34,4 +30,4 @@ stdenvNoCC.mkDerivation rec {
|
||||
maintainers = [ ];
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
@@ -710,6 +710,10 @@ with pkgs;
|
||||
|
||||
makeDesktopItem = callPackage ../build-support/make-desktopitem { };
|
||||
|
||||
installFonts = makeSetupHook {
|
||||
name = "install-fonts-hook";
|
||||
} ../build-support/setup-hooks/install-fonts.sh;
|
||||
|
||||
copyPkgconfigItems = makeSetupHook {
|
||||
name = "copy-pkg-config-items-hook";
|
||||
} ../build-support/setup-hooks/copy-pkgconfig-items.sh;
|
||||
|
||||
Reference in New Issue
Block a user