Seting envvars in singularity-tools.buildImage

There appears to be no documentation whatsoever describing nixpkgs.singularity-tools.

I have managed to build a toy container (with pkgs.hello) using singularity-tools.buildImage and run the utility inside it. But when I try to expand this to a real-world use case, I fail, because the application I want to run requires some environment variables to be set.

The Singularity documentation describes how to set environment variables in a definition file, but I cannot see anything in singularity-tools that caters for setting envvars.

What can I do to get around this problem?

I’m wondering whether this might be addressed by placing a flake-output-app in the container.

The logic being that, in order for it to be possible to nix run the app, it must have its environment properly configured. But perhaps the environment-setting magic is more in nix run than in the app itself.

I don’t know

  • how to place a flake app in the container (if it is possible)
  • how the app’s environment is ensured. (I did write a couple of these a long time ago, but don’t remember any details)