Use more consistency in return/exit codes.

0: Success.
1: General error.
2: Incorrect invocation.
3: Bad configuration of nixd.
127: Command not implemented (for use in optional package commands).
Add optional pretest subcommand.
Inspect exit codes consistently.