4

I want to set up jetty on nixos. I can install it through system.systemPackages but I can't get it to autostart (services.jetty isn't defined)

I don't want to ask every option here, so I want to know if there is documentation or a way to print every option under services?

I looked here, and I can't find anything there either

1 Answer 1

3

To answer the title of your question; the NixOS nixos-option utility program will let you query what attributes of your configuration.nix evaluate to.

I don't know if NixOS explicitly provides a way to print the whole thing, but you could probably do it yourself fairly easily by using the same function NixOS uses internally to evaluate configuration.nix. IIRC you would need to call it with { modules = [ /etc/nixos/configuration.nix ]; }. You could then make use of Nix's built in toXML functionality to get the evaluated config to a printable string. builtins.toXML or the --xml flag to nix-instantiate are both possible ways to access that functionality.

I should say that if you do that there will be a lot of xml.

But I think that's not actually the body of your question. It sounds like you just want to check what all the available predefined NixOS services are? The configuration options appendix to the NixOS manual lists that info.

However if you're after a service unit for Jetty it appears there currently isn't one.

I don't know anything about Jetty but I imagine you could write your own pretty easily (I've written a few for myself and found it fairly straightforward). This entry on the NixOS wiki gives an example of a nixos systemd service unit. You can also look through all the other NixOS modules to follow how they're written. And of course consult the relevant systemd man pages also.

On a side note, if you do that you'll find you don't need to declare a module binary in systemPackages, because its path gets pulled into its systemd unit, so you just interact with it there instead.

4
  • Not the questioner but mine was what you answered in first part, thank you.
    – 0fnt
    Aug 6, 2019 at 3:06
  • I've tried the way mentioned in the first part of the answer and as of this comment, the toXML part fails with an error indicating that static enumeration of that expression is not possible.
    – 0fnt
    Aug 6, 2019 at 3:57
  • @0fnt there's likely something in your expression that can't be converted into an xml representation. You can use nix-repl to evaluate parts of your expressions and see which part is responsible.
    – brocking
    Aug 7, 2019 at 13:51
  • What about flake-based systems?
    – Winny
    Nov 25, 2022 at 10:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .