How to add fonts to program running in container using arion or docker?

Hey everyone,

I need to use “NewComputerModern” font packaged in nixpkgs as cm-unicode in a python program I am running in a container using arion compose. The arion-compose.nix file looks like this:

{ pkgs, ... }:
{
  config.project.name = "jupyter-arion";
  config.services = {
    jupyter= {
      service.image = "jupyter/datascience-notebook:latest";
      service.environment = {
        JUPYTER_ENABLE_LAB = "yes";
        JUPYTER_TOKEN =  "docker";
      };
      service.ports = [
        "8888:8888" # host:container
      ];
      service.volumes = [ "${builtins.toString ( builtins.getEnv "HOME" )}/Documents/project:/home/jovyan/project"];
      service.stop_signal = "SIGINT";
    };
  };
}

I need to run this on NixOS machines, as well as non-NixOS machines (mostly linux). As I was looking around I found this solution to a similar problem, but I am not sure how to use in my case. Is there any standard way to add packages to containers in general?

Thanks in advance for any help!

I figured it out. Somehow I thought, that a NixOS system was being used for the container. The container used in this case was a Ubuntu/Debian container. The solution was to use a Dockerfile which contained instructions for installing all necessary fonts, and build the image using arion build. Later when the container was started, the font cache needed to be updated inside of the running container. Thereafter, the fonts could be used.

At the end I switched to using nix-shell, as all the necessary programs and fonts were packaged and easy to use in my case.