danth / stylix

System-wide colorscheming and typography for NixOS
https://stylix.danth.me/
MIT License
1.16k stars 143 forks source link

fonts.drv causing link errors #87

Closed duckpuppy closed 1 year ago

duckpuppy commented 1 year ago
error: builder for '/nix/store/wlrrlqfmyzkvdarm90dx83kg41a6sv55-fonts.drv' failed with exit code 1;
       last 1 log lines:
       > ln: failed to create symbolic link '/nix/store/5jgyddi839rx80rpv79p65p2lgmr1icy-fonts/Library/Fonts/Caskaydia Cove Nerd Font Complete ExtraLight Italic.otf': File exists
       For full logs, run 'nix log /nix/store/wlrrlqfmyzkvdarm90dx83kg41a6sv55-fonts.drv'.

Whenever I try to build my flake (nix-darwin config) I get an error about linking a font where the link already exists. I get this even if I don't specify a font configuration - in that case, the error refers to one of the default DejaVu fonts.

I've tried nix-store --delete /nix/store/5jgyddi839rx80rpv79p65p2lgmr1icy-fonts, which completes successfully. The error will still occur, though.

I'm at a loss as to how to debug this issue, but I do not otherwise specify any font options (nix-darwin or home-manager) anywhere in my config.

duckpuppy commented 1 year ago

If I remove stylix from my config, it builds without error.

duckpuppy commented 1 year ago

I can reproduce this with this simplified flake (placing an image named imperial_black.jpg in the same folder as this flake is all that's needed):

{
  description = "System and Home Manager configs";

  inputs = rec {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    darwin = {
      url = "github:lnl7/nix-darwin";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    stylix.url = "github:danth/stylix";
  };

  outputs = inputs @ { self, nixpkgs, home-manager, darwin, ... }:
    {
      darwinConfigurations = {
        dantooine = darwin.lib.darwinSystem {
          modules = [
            inputs.home-manager.darwinModules.home-manager
            inputs.stylix.darwinModules.stylix
            {
              stylix.image = ./imperial_black.jpg;
            }
          ];
          system = "x86_64-darwin";
        };
      };
    };
}

Running darwin-rebuild build --verbose --flake .#dantooine --show-trace results in:

these 2 derivations will be built:
  /nix/store/08s1lhry6j5fvsx2w8m1l8z2cjinllc6-fonts.drv
  /nix/store/j17xbpfj1w0jy7966gjkqh0i33srd47r-darwin-system-23.05.20230417.f00994e+darwin4.0259125.drv
building '/nix/store/08s1lhry6j5fvsx2w8m1l8z2cjinllc6-fonts.drv'...
error: builder for '/nix/store/08s1lhry6j5fvsx2w8m1l8z2cjinllc6-fonts.drv' failed with exit code 1;
       last 1 log lines:
       > ln: failed to create symbolic link '/nix/store/ysnw31q0qm90ljkz8cx23xv5ddlvlvv5-fonts/Library/Fonts/DejaVuSerifCondensed-Bold.ttf': File exists
       For full logs, run 'nix-store -l /nix/store/08s1lhry6j5fvsx2w8m1l8z2cjinllc6-fonts.drv'.
error: 1 dependencies of derivation '/nix/store/j17xbpfj1w0jy7966gjkqh0i33srd47r-darwin-system-23.05.20230417.f00994e+darwin4.0259125.drv' failed to build
duckpuppy commented 1 year ago

@lovesegfault I see that you filed the issue that ended with creation of the Darwin module - Are you seeing this error, and if so did you get past it?

lovesegfault commented 1 year ago

Yeah, this error will happen on Darwin and it's really unfortunate. I have a PR upstream that fixes it: https://github.com/LnL7/nix-darwin/pull/624

For now: Do whatever you can to avoid having repeated fonts. You can see how I had to just remove some fonts from my config for the time being: https://github.com/lovesegfault/nix-config/blob/61a81d2f68a3de3efeeb6eebca4714182f3f6cc5/graphical/fonts.nix#L5-L7

duckpuppy commented 1 year ago

@lovesegfault Thanks, that at least gives me somewhere to start... though my simple example above does nothing with fonts at all and still exhibits the problem.

duckpuppy commented 1 year ago

I'm closing this issue here as it's an upstream bug with nix-darwin.

lovesegfault commented 1 year ago

That's because they default to dejavu_fonts for all the fonts, which means it ends up repeated, and causes the issue.