Custom font install problem

I was trying to add a custom font from my local drive (which is not available in NixOS packages).

Here is my font nix file content

{ pkgs }:

pkgs.stdenv.mkDerivation {
  pname = "Operator-caska";
  version = "1.0";
  src = /home/dihan/System/Fonts/operator_caska;

  installPhase = ''
    mkdir -p $out/share/fonts/truetype/
    cp -r $src/*.{ttf,otf} $out/share/fonts/truetype/
  '';
 
  meta = with lib; {
    description = "Operator Caska";
    homepage = "https://github.com/Anant-mishra1729/Operator-caska-Font";
    platforms = platforms.all;
  };
}

and this is part of my configuration file where I added the font

let

 operator-caska-typeface = pkgs.callPackage ./operator_caska.nix {inherit pkgs};

in

fonts = {
    fontDir.enable = true;
    enableDefaultPackages = false;
    packages = with pkgs; [
      corefonts
      nerd-fonts.noto
      noto-fonts
      noto-fonts-cjk-sans
      noto-fonts-cjk-serif
      noto-fonts-color-emoji
      noto-fonts-lgc-plus
      operator-caska-typeface
    ];
}

according to documentation and some blogs it is okay. But when I rebuild it shows a problem like this

if I remove {inherit pkgs} it shows this error

It’s a syntax error, you missed a semicolon.
But you’re using callPackage, the whole purpose is to not need to pass attributes of pkgs in manually. So just remove the inherit pkgs there.

@waffle8946 Here is another problem after removing {inherit pkgs} (btw i am updating my topic with this image)

Please use text, not images. And can you please share the code after you made the change?

By the way, I said to remove the inherit pkgs, not remove the {} around it.
callPackage takes two args.

Again, see Package parameters and overrides with callPackage — nix.dev documentation.

1 Like

@waffle8946
Solved.
Your guess was right. I deleted {}. Thank you for your suggestions.