Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] znc: more flexible module #41467

Closed
wants to merge 16 commits into from

Conversation

infinisil
Copy link
Member

@infinisil infinisil commented Jun 4, 2018

This commit adds one major new option to the znc module:
services.znc.config. It can represents the full ZNC configuration as a
Nix value, see its description for more info. It acts as a more
flexible alternative for the older services.znc.confOptions.* options.
Effectively this also allows the user to change previously fixed options. Along
with this comes a nicely generated config file with proper indentation.

Unless I made a mistake, these changes are 100% backwards compatible.

Other changes:

  • Proper escaping in start script -> allows for special directory/file
    names
  • All znc modules packaged in nixpkgs are added to the
    services.znc.modulePackages option by default, because they are very
    small (<100KB each)
  • Clean up the module in general and split the old options into a
    separate file.
  • Correct network.service -> network.target

It's now possible to:

  • Have multiple users
  • Set channels as detached
  • Define QuitMsg
  • And everything else that wasn't previously possible

The new configuration style is a direct translation of the xml-like znc config file syntax, all the options are described in the official ZNC wiki. It looks like this:

{
  services.znc = {
    enable = true;
    openFirewall = true;
    mutable = false;
    config = {
      LoadModule = [ "playback" ];
      Listener.l = {
        Port = 5000;
        IPv4 = true;
        IPv6 = true;
        SSL = true;
      };
      User.infinisil = {
        Admin = true;
        LoadModule = [ "push" ];
        QuitMsg = "Configuring ZNC, sorry for the joins/quits!";
        Nick = "infinisil";
        AltNick = "infinisi1";
        Ident = "infinisil";

        Network.freenode = {
          Server = "chat.freenode.net +6697";
          Chan = {
            "#nixos" = { Detached = true; };
            "#zfsonlinux" = { Disabled = true; };
          };
        };
      };
    };
  };
}

If you don't define the new config option, the legacy confOptions option will be used for it.

My better-znc-module branch contains the unsquashed version of this PR. It would probably have been nicer to have multiple commits because of the many changes.

Pinging the people who have toched the module in the past: @layus @mbrgm @vaibhavsagar @nocoolnametom @schneefux @lethalman

And pinging the maintainers of the package: @viric @schneefux @LnL7

Todo

  • Test it some more
  • Minimize the znc config in the example, might not need everything there
  • I think in the old options there is one that's not used at all, remove it or deprecate it in case anybody set it in the hopes of it doing something?
  • Maybe add a section in the docs regarding this. The services.znc.config description explains it pretty well already though.
  • Fine tune option descriptions
  • What to do with the bitlebee thing? -> Ain't gonna do anything!

@nocoolnametom
Copy link
Contributor

nocoolnametom commented Jun 5, 2018

Yeah, the Bitlbee thing sucks and I am embarrassed that it will forever stand in this repo's history as my first change to Nixpkgs. I didn't really understand Nix-language and that was my workaround for how to implement a channel that doesn't begin with a hash into the generated ZNC confs.

Would it make more sense to do something more along these lines, and just make it that channels that start with an ampersand don't get a leading hash? (Or should we be enforcing the leading hash at all? Maybe leave that to the user to add to their configuration options explicitly?)

#nixos/modules/services/networking/znc/opts.nix:255
Chan = listToAttrs (map (n: nameValuePair ((if lib.hasPrefix "&" n then "" else "#") + n) {}) net.channels);

That's a breaking change, however, so I'm not sure that's the right way to go, either. I like the backward compatibility in your changes so it allows people to upgrade nicely. Fixing/Removing the Bitlbee flag is probably something that should wait until later.

@infinisil
Copy link
Member Author

@nocoolnametom I'm actually not sure why I added the "What to do about the bitlebee thing" to the Todo list now. This previous option can just stay as it is. And if somebody needs additional channels not starting with "#" they can use the new config style which doesn't have this restriction.

- Will make it easy to add support for any additional znc config file
options
- Will provide a way to override default config file options
- Generates a nicer config file without unnecessary newlines and proper
tabs
- Put extraConfig at bottom
- Allow null to unset values
- Add options for semantic config and config file by default being
generated by the semantic config
- Fix network.service -> network.target
- Make start script work with dataDir's that contain space
- Add passblock comment, now support semantic and string version
- Split legacy options into other file
- Fix start script syntax error
- Open all ports in the semantic config
- Use import instead of submodule to be able to put all legacy stuff
into own file
- Don't ignore old zncConf string, properly set default priorities
@infinisil infinisil force-pushed the better-znc-module-squashed branch 2 times, most recently from fb61464 to c09bdea Compare July 4, 2018 02:30
@infinisil infinisil mentioned this pull request Jul 11, 2018
9 tasks
@infinisil
Copy link
Member Author

I am working on a new version of this PR with lots of cleanups on this branch: https://github.com/Infinisil/nixpkgs/tree/znc-config

I'll open a new PR when I'm done with it

@infinisil infinisil closed this Aug 22, 2018
infinisil added a commit to infinisil/nixpkgs that referenced this pull request Aug 24, 2018
@infinisil infinisil deleted the better-znc-module-squashed branch October 12, 2018 13:30
infinisil added a commit to infinisil/nixpkgs that referenced this pull request Oct 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants