In the outputs section of your flake.nix. write something like fhs_env = pkgs.buildFHSUserEnv {...};. Then you can run it with nix run .#fhs_env. If your runScript is a shell, you’ll enter the shell where you can explore the environment to determine what to adjust. See the wiki page on Flakes for details on the structure of flake.nix. Remember that flake.nix and flake.lock must be part of a git repo to use the flake.
Thanks, that works! The Wiki page only mentions “apps…” attributes in conjunction with nix run which expects a store path. I didn’t understand how to specify it for an environment. I missed that there is a link to the nix run reference page with an example that, together with your explanation, clarifies it.
I tried apps.fhs_env = { type = "app"; program = pkgs.buildFHSUserEnv {...}; };, but I’m getting error: 'apps.x86_64-linux.fhs_env.program' is not a string but a set.