Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fonts cache #520

Closed
wedens opened this issue Dec 31, 2018 · 6 comments · Fixed by #682
Closed

Update fonts cache #520

wedens opened this issue Dec 31, 2018 · 6 comments · Fixed by #682

Comments

@wedens
Copy link

wedens commented Dec 31, 2018

When fonts.fonts = [ ]; list is modified in nixos, it causes fonts cache update. It'd be handy to have such option for fonts installed via home-manager so that you don't need to execute fc-cache -f manually.

@wedens
Copy link
Author

wedens commented Jan 6, 2019

Currently I use the following hack:

{config, pkgs, lib, ...}:

let
  cfg = config.fonts;
in

with lib;

{
  options = {
    fonts.fonts = mkOption {
      type = types.listOf types.package;
      default = [];
      example = literalExample "[ pkgs.dejavu_fonts ]";
      description = "List of fonts.";
    };
  };

  config = {
    home.packages = cfg.fonts;

    home.file."${config.xdg.cacheHome}/hm-fonts" = let
      getHash = drv: builtins.elemAt (builtins.match "${builtins.storeDir}/([a-z0-9]{32})-.*.drv" drv.drvPath) 0;
    in {
      text = concatMapStringsSep "\n" getHash cfg.fonts;
      onChange = ''
        echo "Caching fonts"
        $DRY_RUN_CMD fc-cache -f
      '';
    };
  };
}

It just saves a list of hashes of fonts derivations in a file and updates cache when the list changes.

@rycee Do you think it'll be useful to include it in some form in home-manager?

@Jomik
Copy link
Contributor

Jomik commented Mar 2, 2019

This looks like a good idea to me 👍
Why fonts.fonts though? Maybe just a rootlevel fonts or do home.fonts?
I realize that NixOS uses fonts.fonts, i find the attribute name choice weird though.

@wedens
Copy link
Author

wedens commented Mar 3, 2019

Why fonts.fonts though? Maybe just a rootlevel fonts or do home.fonts?

There is already fonts.fontconfig, so it can't be just fonts. fonts.fonts is at least known from nixos.

@Jomik
Copy link
Contributor

Jomik commented Mar 3, 2019

Oh, there is. Makes sense to follow NixOS then. I'd probably have chosen fonts.packages, but yours makes sense due to NixOS's choice 😃

@leotaku
Copy link
Contributor

leotaku commented Mar 29, 2019

@rycee, @wedens are you still interested in having this added to home-manager?

rycee added a commit that referenced this issue Apr 20, 2019
Also deprecates the `fonts.fontconfig.enableProfileFonts` option. The
configuration is now always generated if `fonts.fontconfig.enable` is
set.

Fixes #520
rycee added a commit that referenced this issue Apr 21, 2019
Also deprecates the `fonts.fontconfig.enableProfileFonts` option. The
configuration is now always generated if `fonts.fontconfig.enable` is
set.

Fixes #520
rycee added a commit that referenced this issue Apr 21, 2019
Also deprecates the `fonts.fontconfig.enableProfileFonts` option. The
configuration is now always generated if `fonts.fontconfig.enable` is
set.

Fixes #520
rycee added a commit that referenced this issue Apr 21, 2019
Also deprecates the `fonts.fontconfig.enableProfileFonts` option. The
configuration is now always generated if `fonts.fontconfig.enable` is
set.

Fixes #520
@rycee
Copy link
Member

rycee commented Apr 21, 2019

If anybody is able to try it out then please have a look at #682, which I believe will resolve this issue. Note, you will have to add

fonts.fontconfig.enable = true;

to your configuration for it it take effect.

rycee added a commit that referenced this issue Apr 29, 2019
Also deprecates the `fonts.fontconfig.enableProfileFonts` option. The
configuration is now always generated if `fonts.fontconfig.enable` is
set.

Fixes #520
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants