Hi, I’m trying to get the mighttpd2 CGI server to run my .cgi scripts.
But mighttpd2 already fails at the .cgi script’s first line #!/usr/bin/env bash saying ‘bash: no such file or directory’. For the user under which mighttpd2 runs, bash is available.
Any idea how I can share the global environment with the .cgi scripts?
systemd services run with a restricted environment normally. You can add to the .service file an option to set an environment variable, including PATH, or, for a quick workaround, you could also just use the static absolute path to the system-wide installed version, /run/current-system/sw/bin/bash.
You can see in the module that it’s setting options under systemd.services.mighttpd2 in order to create the service. You can thus set systemd.services.mighttpd2.environment.PATH = "whatever you want the PATH to be"; in order to set the PATH that the service runs with.
You may want to use lib.makeBinPath to create the string.
EDIT: Actually, you should use systemd.services.mighttpd2.path = [ pkgs.foo pkgs.bar ]; instead.