Flake of custom build works on one machine, errs on another

Context:
I have 2 laptops, both running NixOS. I set up a folder I call “cuneiform-fonts”, which I call when I installed fonts:

  fonts.packages = with pkgs; [
    font-awesome
    noto-fonts
    noto-fonts-cjk-sans
    noto-fonts-emoji
    liberation_ttf
    fira-code
    fira-code-symbols
    mplus-outline-fonts.githubRelease
    dina-font
    proggyfonts
    ipafont # japanese
    kochi-substitute # japanese

    (callPackage ./cuneiform-fonts { })
  ];

Within the cuneiform-fonts folder, I have a flake.nix and default.nix:

### flake.nix 
{
  inputs.flake-utils = {
    url = "github:numtide/flake-utils";
    follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      {
        packages.default = nixpkgs.legacyPackages.${system}.callPackage ./default.nix {};
      }
    );
}
### default.nix
{ stdenv
, fetchzip
, fetchurl
, lib
}:

stdenv.mkDerivation rec {
  pname = "cuneiform-fonts";
  version = "2023.08.23-20:06pdt";

  base_url = "https://www.hethport.uni-wuerzburg.de/cuneifont/download";

  srcs = [
    # old babylonian
    (fetchzip {
      url = "${base_url}/Santakku.zip";
      sha256 = "sha256-eBmZT0rn6sew76Qgs+nOWJHQHehRcepLjeQDzS0gzqc=";
      stripRoot = false;
      #sha256 = lib.fakeSha256; stripRoot=false; # both needed
    })

    # hittite
    (fetchzip {
      url = "${base_url}/Ullikummi.zip";
      sha256 = "sha256-RdJ/UgOXLfBNsNMnWVsJqcNgOeOTdcCs+GrEyB6qvkg=";
      stripRoot = false;
    })

    # neo-assyrian
    (fetchzip {
      url = "${base_url}/Assurbanipal.zip";
      sha256 = "sha256-g7LXO9rnSsEd5cTRgaBlMGmt5pR7FcDi7u+sdEv+TlQ=";
      stripRoot = false;
    })

    # neo-babylonian
    (fetchurl {
      url = "${base_url}/Esagil.ttf";
      sha256 = "sha256-znFvi9KOqg9tJd8Cs3ENxBszmikiHV/wFNhTggH98YA=";
    })

    # old persian
    (fetchzip {
      url = "${base_url}/OldPersian.zip";
      sha256 = "sha256-0VlejElgsm/xDIFqF7LiQ/dOfTytDpXhFBOlo45wBw0=";
      stripRoot = false;
    })
  ];

  dontUnpack = true;

  installPhase = ''
    mkdir -p $out/usr/share/fonts/OTF $out/usr/share/fonts/TTF

    if find $srcs | grep 'otf' >&/dev/null; then
       find $srcs -name '*.otf' | grep -v MACOS | xargs -I{} cp {} $out/usr/share/fonts/TTF
    fi
    if find $srcs | grep 'ttf' >&/dev/null; then
       find $srcs -name '*.ttf' | grep -v MACOS | xargs -I{} cp {} $out/usr/share/fonts/TTF
    fi
  '';
}

This has installed successfully on machine 1 for a while now. I tried adding it on machine 2, which has nearly an identical system flake and imported files/modules. However, I get this error:

   error: function 'anonymous lambda' called with unexpected argument 'inputs'

I tried adding

        , ...

But end up with a recursion error:

 error: infinite recursion encountered

I have tried searching for similar situations but have come up empty.

IIRC callPackage only calls default.nix from the provided directory. Looks like the problem is in the second’s machine flake. Can you post your configs somewhere?

There is a technical difference between the layout now that you mention it.

On machine 1, everything is just in the same folder, e.g.

$ ls
cli.nix
cuneiform-fonts/
flake.lock
flake.nix
sway.nix

On machine 2, I moved all of the separate config into a modules folder:

$ ls
flake.lock
flake.nix
modules/

$ cd modules/
$ ls
cli.nix
cuneiform-fonts/
sway.nix

On machine 2, I do actually call it as

    (callPackage ./modules/cuneiform-fonts { })

I tried taking off the modules/ part and it seems to still find it, giving the same error.

Is my understanding correct – you have three separate flakes:

  • fonts one
  • one for machine 1
  • one for machine 2

? You’re free to keep using this schema of course, but flakes allow combining all of the machine configurations and packages into a single flake. This generally lowers wtfs/minute by reusing the code.

In your case I suspect the problem is with the code in flake.nix for machine 2 – can you post it?

While trying to sanitize my flake.nix, I realized I had the cuneiform-fonts/ dir under

modules = [

which was causing the recursion. I always forget to add new stuff there, so bad force of habit.
All is working now.

Thanks for the help @VTimofeenko!