packages/nixpak: use fonts module

This commit is contained in:
Max Headroom 2022-12-05 16:55:13 +01:00
parent 6516e2a36c
commit 925bec76c9

View file

@ -1,40 +1,5 @@
{ config, lib, pkgs, ... }:
let
fonts = with pkgs; [
cantarell-fonts
dejavu_fonts
liberation_ttf
gyre-fonts
source-sans
source-code-pro
];
fontCache = pkgs.makeFontsCache {
inherit (pkgs) fontconfig;
fontDirectories = fonts;
};
fontConfigFile = pkgs.writeTextDir "etc/fonts/conf.d/00-nixpak-fonts.conf" ''
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'urn:fontconfig:fonts.dtd'>
<fontconfig>
<!-- Font directories -->
${lib.concatStringsSep "\n" (map (font: "<dir>${font}</dir>") fonts)}
${lib.optionalString (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) ''
<!-- Pre-generated font caches -->
<cachedir>${fontCache}</cachedir>
''}
</fontconfig>
'';
fc = pkgs.buildEnv {
name = "nixpak-font-env";
paths = [
fontConfigFile
pkgs.fontconfig.out
];
pathsToLink = "/etc/fonts";
};
in
{
config = {
dbus.policies = {
@ -48,6 +13,7 @@ in
};
gpu.enable = lib.mkDefault true;
gpu.provider = "bundle";
fonts.enable = true;
locale.enable = true;
bubblewrap = {
network = lib.mkDefault false;
@ -60,7 +26,6 @@ in
"$XDG_RUNTIME_DIR/pulse"
];
bind.ro = [
[ "${fc}/etc/fonts" "/etc/fonts" ]
"$XDG_RUNTIME_DIR/doc"
"$HOME/.config/gtk-2.0"
"$HOME/.config/gtk-3.0"