I built my first overlay to add a font (scientifica) not found in nixpkgs. Even though the overlay is based off known-good configurations (e.g. Good examples > Add custom package), it seems to break vital Nix utilities like nix-env
and nix-shell
, which I use to install packages.
Troubleshooting
I looked through the top 10 Discourse threads for ‘infinite recursion’ in addition to other assorted resources, but haven’t seen or applied a measure which has fixed my problem so far. Additional troubleshooting steps are noted in “Configurations” below.
Configurations
Below is my entire overlays/scientifica/default.nix
function. Building the package without adding it to nixpkgs (nix-build -E 'with import <nixpkgs> { }; callPackage ./default.nix { }'
) has not caused any errors.
{ stdenv, fetchzip }:
stdenv.mkDerivation rec {
pname = "scientifica";
version = "v2.1";
src = fetchzip {
url = "https://github.com/NerdyPepper/scientifica/releases/latest/download/${pname}-${version}.tar";
sha256 = "1mji70h5qdplx0rlhijrdpbmvd0c6fvnr70sla032gfs5g6f78cn";
};
dontBuild = true;
installPhase = ''
mkdir -p $out/share/fonts/truetype/
mkdir -p $out/share/fonts/misc/
cp ttf/* -d $out/share/fonts/truetype/
cp otb/* -d $out/share/fonts/misc/
cp bdf/* -d $out/share/fonts/misc/
'';
# metadata
meta = with stdenv.lib; {
description = "Tall and condensed bitmap font for geeks";
homepage = "https://github.com/NerdyPepper/scientifica";
license = licenses.ofl;
platforms = platforms.all;
};
}
Below is the entirety of /overlays/default.nix
. Commenting all lines of the overlay results in a separate, “unexpected $END” type of error. If I remove the /overlays
directory and rebuild, Nix utilities work perfectly fine, so I suspect this is causing my problems.
self: super:
{
scientifica = super.callPackage ./scientifica { };
}
Below are the relevant lines from my /desktop/fonts.nix
file which imports the overlay. Removing ./
(current directory) before the overlay path fixed Nix utilities, until they spontaneously broke again. Commenting lines out has not resulted in any changes.
{ config, pkgs, ... }:
{
nixpkgs.overlays = [
(import ../overlays/default.nix)
];
[...]
fonts = {
[...]
fonts = with pkgs; [
scientifica
]
};
[...]
}''
Below are the relevant lines from configuration.nix
. Commenting lines out has not resulted in any changes.
{ config, pkgs, options, ... }:
{
imports =
[
[...]
./desktop/fonts.nix
];
[...]
nix.nixPath =
options.nix.nixPath.default ++
[ "nixpkgs-overlays=/etc/nixos/overlays/" ]
;
Errors
The following issues appear when signed in to either user or root. nix-info
returns the following error message. I know that system: 0, multi-user?: no
are not expected values, as seen in this similar thread.
error: infinite recursion encountered, at undefined position
system: 0, multi-user?: no, version: nix-env (Nix) 2.3.9, channels(user): "nixpkgs-21.03pre257784.253de1fcdb3", channels(root): "nixos-20.09.2190.78dc359abf8, nixos-hardware", nixpkgs: /home/user/.nix-defexpr/channels/nixpkgs
nix-channels
returns:
nixos https://nixos.org/channels/nixos-20.09
nixos-hardware https://github.com/NixOS/nixos-hardware/archive/master.tar.gz
nix-env -qa
and nix-env -iA nixos.pipes
both return:
error: infinite recursion encountered, at undefined position
nix-shell
returns:
error: getting status of '/home/user/default.nix': No such file or directory
Final notes
Any help would be much appreciated.