The manuals for nix, nixops, etc show how to configure the Http server. But I want to use Tomcat.
The nixops manual tells me that I can enable the http server by
services.httpd.enable = true;
services.httpd.documentRoot = “/data”;
I can’t find any documentation that says, for some particular package, how to configure it in nixops.
I downloaded the nixpkgs scripts, thinking that they would tell me, but they don’t. The httpd server
is called apache-httpd so I am not even sure how nixops decides that the service name is httpd instead
of apache-httpd. There must be some way of seeing how to configure a package other than just looking
at examples in the manual, but I can’t find one. In addition to Tomcat, I will want to configure kafka, zookeeper, samba, nginx and openvpn, so I am looking for a general solution, not just trying to learn about Tomcat.
nixops uses basically the same configuration system as NixOS. Whenever I want to start using a new service, I go to the NixOS options search. Here’s the search for tomcat:
It’s important to realize that unlike many Linux distributions (for example, Debian/Ubuntu), NixOS has a clear distinction between a package (a piece of software: executables, data files, man pages, whatever) and a service (a unit that is run and managed by the OS and offers some functionality locally or across the network). So, you can have a package installed, you can even have it in $PATH to run the executables manually, but it will not run by itself.
For a user/administrator, a service is "something that is configured via NixOS options under services.<servicename>. In terms of nixpkgs code, services are defined in “modules” which can be found in nixos/modules; for example, services.httpd is defined in nixos/modules/services/web-servers/apache-httpd/default.nix. A service takes care of ensuring the corresponding package(s) exists in the system, prepares the environment (data files, etc.) and provides a systemd unit (or other mechanism) that runs the necessary executables.