How can I declare the API key for Syncthing?

I’m trying to declare the API key for Syncthing:

      extraOptions = [ "--gui-apikey=12345" ];
      extraOptions.gui = {
        user = "foo";
        password = "bar";
      };

, but it doesn’t seem to allow me to specify both extraOptions and extraOption.gui. Probably just an understanding of the language problem;)

I get:

error: attribute 'extraOptions.gui' already defined at /etc/nixos/configuration.nix:434:7

I’m not sure if you just want an answer that uses the home-manager sync module, but I do what you want using home.file:

home.file."./.config/syncthing/" = { source = ../configs/syncthing; recursive = true; };

That’s assuming also you can use home-manager.

If not, then you need to make changes to your syntax because extraOptions must be a JSON value. You can see how to declare it correctly in the search-nixos example.

Looks like you have declared extraOptions.gui in two places. Maybe it is on two different lines in configuration.nix or you are importing another .nix which contains another extraOptions.gui declaration.

Right, but I don’t understand how the syntax is supposed to be.

No, I have not declared extraOptions.gui in two places; it’s just that I have to put something in extraOptions and I have to put something else in extraOptions.gui.

Ah, ok, it’s like this:

      extraOptions.gui =
        {
          user = "foo";
          password = "bar";
          apikey = "12345";
        };