How do I configure discourse as service with custom options?

I’m working on running discourse, which is conveniently bundled in nixpkgs. I’ve run it elsewhere, manually building a docker container and running the install processes.

It seems that in widely prevailing nix installation patterns, you would add this to a configuration.nix file to define a server’s configuration.nix.

I’m running nix on debian 11, as a standalone package manager, in a multi-user installation. I’m standing up the service on a machine I administrate with several other users, and I would like a general way of standing up nix-provided services and ensuring that other users have visibility—at least into starting and stopping them, but also permission to modify configuration. I plan to host other services with this as well, including at least MediaWiki.

I’ve been unable to find how nixpkgs search - discourse the strong conventions that this package uses, are expected to be invoked. I frequently run into this inferential gap in nix. I have gone through Nix Pills 7 & 8, reviewing in more detail how to make a derivation in practice, and now I know more precise words for the things I don’t know, as well as more of the structure of how it’s evaluated.

Evidently I need some root, system-base configuration, or else e.g. home-manager.

It’s unclear to me:

  • what to pass in, in the services or security “sets”
  • or else, how they are called, or with what [function / definition].

I learned much about how to specify configuration options in the manual.

services.discourse = {
  enable = true;
  hostname = "";
  admin = {
    email = "";
    username = "admin";
    fullName = "Administrator";
    passwordFile = "/path/to/password_file";
  secretKeyBaseFile = "/path/to/secret_key_base_file";
}; = "";
security.acme.acceptTerms = true;

However, I’m unclear how to generate a base configuration that I would plug this into, especially a base configuration that would appropriately use and set up the content of the services and security Nix-lang sets.

The description of the options does not make it clearer how to invoke them, and mostly seems to contain English descriptions of fairly evocatively named “configuration paths”.

In summary:

  • How do I define a base system that this would fit into? (And please restate this question in more nix-specific language)
  • What invokes and applies the services and security configurations for the whole system?
  • Where, or how, can i define a system that makes it easy for other admins to understand, use, and update? (A link to a good example, of nix services configured (on a non-NixOS-base) system, might suffice to answer this whole question).

It looks like I should indeed put this in configuration.nix, in /etc/nix, IIUC.

What are the ways (the best ways, but any, to start) to test a service’s configuration without a complete deployment. I guess I can follow the flake packaging advice?

You can try using system-manager to get nixos like configuration on non nixos systems.

I doubt though that discourse is already supported, you probably would need to write your own module, or adjust the nixOS module, such that it works with system-manager.

1 Like