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

nixos/syncthing: add options for declarative device/folder config #59985

Merged
merged 1 commit into from May 20, 2019

Conversation

Lassulus
Copy link
Member

Motivation for this change

configure syncthing declaratively in configuration.nix (the true way ;) )

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@davidak
Copy link
Member

davidak commented Apr 23, 2019

It would be nice to be able to add a device as Introducer, so it can add the other devices from the network automatically.

@Lassulus
Copy link
Member Author

It would be nice to be able to add a device as Introducer, so it can add the other devices from the network automatically.

Sure, I will add the option in the device submodule.
I have not represented all options from the syncthing API, just the ones I'm using. If you want more: just request it here while this is open.

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Apr 26, 2019

Nice! I have really wanted something like this, I thought it wasn't possible.
I'll try the PR when I have the chance.

@Lassulus Lassulus force-pushed the syncthing branch 5 times, most recently from 7df682e to d97c3d6 Compare April 26, 2019 10:55
@Lassulus Lassulus changed the title WIP: nixos/syncthing: add options for declarative device/folder config nixos/syncthing: add options for declarative device/folder config Apr 26, 2019
@Lassulus Lassulus force-pushed the syncthing branch 2 times, most recently from 4133e86 to c0e4c12 Compare April 26, 2019 13:02
@mrVanDalo
Copy link
Contributor

This piece of configuration ends up in the following naming.

      folders = {
        podcasts = {
          path = "/home/palo/test-podcasts";
          id = "yvzmx-hcomd";
          devices = [ "workhorse" "schasch" "kruck" ];
        };
      };

image

I would be great if the attribute name would become the folder name (like it is for devices).

@mrVanDalo
Copy link
Contributor

But apart from the folding naming the whole things works just fine.

There are a few things I would add, for example an enable flag for every device and folder entry,
this way I it's easier for me to define all my folder setups, and enable/disable them on specific computers. But I will create a pull-request once this PR is through (focus on the important parts first).

so it is a 👍

@mrVanDalo
Copy link
Contributor

This seems to create problems.

      cert = toString <secrets/syncthing/cert.pem>;
      key = toString <secrets/syncthing/key.pem>;
error: cannot coerce a set to a string, at /var/src/nixpkgs/nixos/modules/system/boot/systemd-lib.nix:102:10
(use '--show-trace' to show detailed location information)

Copy link
Contributor

@mrVanDalo mrVanDalo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cert and key argument need to be fixed

nixos/modules/services/networking/syncthing.nix Outdated Show resolved Hide resolved
@Lassulus Lassulus force-pushed the syncthing branch 2 times, most recently from 9532ff1 to 445cb3c Compare May 5, 2019 14:17
@Lassulus Lassulus merged commit a3e7e1b into NixOS:master May 20, 2019
@jabranham
Copy link
Contributor

A recent syncthing change (I'm assuming this one) made it so that config changes made in the web interface (e.g. adding a device) don't persist across reboots. Is that intended behavior now that declarative config is possible, or should I open an issue?

@Lassulus
Copy link
Member Author

Uhm, If you haven't enabled anything with a declarative option that is indeed a bug and I would be happy to fix it. there are 2 options (overrideFolder, overrideDevice) which should only be needed if any device/folder is declarative configured.
For now as a workaround you could try setting:

services.syncting.declarative = {
  overrideDevice = false;
  overrideFolder = false;
};

@jabranham
Copy link
Contributor

jabranham commented May 28, 2019

If you haven't enabled anything with a declarative option

I didn't change anything in the syncthing config. This happened after a nixos-rebuild switch --upgrade and then reboot.

Thanks for the workaround, I'll have to try it out. Or, perhaps even better, just move to this (awesome) new declarative config.

EDIT: Not sure if it's relevant, but here's the syncthing config I had been using:

  services.syncthing = {
    enable = true;
    user = "alex";
    openDefaultPorts = true;
    dataDir = "/home/alex/.config/syncthing";
  };

@Lassulus
Copy link
Member Author

Alright, I made a PR for the fix:
#62157
sorry for the bug!

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

6 participants