Commit Graph

77 Commits

Author SHA1 Message Date
Ben Wolsieffer
ded5462398 nixos/syncthing: add databaseDir option
#264753 mistakenly used the dataDir option to set the -data argument.
This broke existing configurations because -data used to be set to
configDir (implicitly, using the -home option, which is equivalent to
setting -config and -data to the same value).

Fix this by introducing a new databaseDir option sets -data and defaults
to configDir. This maintains the existing behavior by default while
still allowing users to specify separate config and database
directories.
2023-12-11 20:52:37 -05:00
h7x4
0a37316d6c
treewide: use mkPackageOption
This commit replaces a lot of usages of `mkOption` with the package
type, to be `mkPackageOption`, in order to reduce the amount of code.
2023-11-27 01:28:36 +01:00
William McKinnon
869fb56797 nixos/syncthing: respect the dataDir option
The previous -home argument worked as such:
"Set common configuration and data directory. The default configuration directory is $HOME/.config/syncthing (Unix-like), $HOME/Library/Application Support/Syncthing (Mac) and %LOCALAPPDATA%\Syncthing (Windows)"

This resulted in syncthing not respecting different home and data dirs
declared in its config. The default behaviour will remain the same, as
we set the datadir default value to homeDir + .config/syncthing.
2023-11-17 22:58:46 +01:00
digital
a6253e6b12
nixos/syncthing: support syncthing gui and api over unix sockets (#247343) 2023-10-25 09:18:42 +02:00
Doron Behar
79c78d68c6 nixos/syncthing: get API key for every curl request
Fixes #260262.
2023-10-15 02:04:52 +03:00
lassulus
82b59a8fb2 nixos/syncthing: match stale ids by subtracting in jq 2023-10-05 23:08:05 +02:00
Doron Behar
047fa8dbdf nixos/syncthing: Use API to merge / override configurations
If one sets either of `override{Device,folder}s` to false, the jq `*`
operator doesn't merge well the devices and folders, creating duplicate
IDs for folders as observed in #230146. This PR makes the script iterate
via Nix / Bash loop the devices and folders IDs and merges the keys
using upstream's `curl -X POST` support for single objects.

Hence this commit fixes #230146.
2023-07-23 18:22:33 +03:00
lassulus
345745b6da nixos/syncthing: fix syncthing-init running by default
also remove empty values from the config
2023-06-29 17:57:11 +03:00
lassulus
c42a7b668c Revert "Merge pull request #233377 from ncfavier/revert-226088"
This reverts commit 7b28ea6783, reversing
changes made to 3009b12817.
2023-06-29 17:56:30 +03:00
Naïm Favier
9a9ded1675
nixos/syncthing: fix escaping 2023-06-23 20:19:51 +02:00
Naïm Favier
d5e090d2d8
Revert "nixos/syncthing: use rfc42 style settings"
This reverts commit 32866f8d58.
This reverts commit 40a2df0fb0.
This reverts commit 4762932601.
2023-05-22 10:29:52 +02:00
lassulus
4762932601 nixos/syncthing: fix disabled folders 2023-05-18 11:06:57 +02:00
Naïm Favier
40a2df0fb0
nixos/syncthing: fixup #226088 2023-05-17 16:53:01 +02:00
Xyz00777
32866f8d58 nixos/syncthing: use rfc42 style settings 2023-05-15 14:38:56 +02:00
maifel-maifel
4dbc2fe873
nixos/syncthing: point out pitfalls with extraOptions (#210208)
Co-authored-by: digital <git-voopaipa@dinid.net>
2023-01-16 13:12:12 +01:00
Robert Schütz
257ec177c8 nixos/syncthing: disallow relative paths
Relative paths are interpreted relative to the working directory, which
is currently unset and thus defaults to `/`. However we want to change
the working directory in a future release such that relative paths are
interpreted relative to `/var/lib/syncthing`.
2022-11-12 11:37:23 -08:00
Andrew Barchuk
43bc09e037
nixos/syncthing: keep manually added dirs/devices
If folders and devices are not configured explicitly, do not wipe the
changes done via the web GUI. Currently the list of devices or folders
will be reset unless overrideFolders/overrideDevices is disabled.
2022-10-30 00:22:00 +02:00
Christian Kögler
11bafe6b5b nixos/syncthing: remove exit code 2 from exit status success
Fix #181713
2022-09-11 16:21:07 +02:00
Christian Kögler
4b6b03f99c
Merge pull request #185782 from e1mo/e1mo/syncthing-receiveencrypted
nixos/syncthing: Add receiveencrypted folder type
2022-09-09 17:30:45 +02:00
pennae
3bddcf5f90
Merge branch 'master' into option-docs-md 2022-09-01 16:10:09 +02:00
pennae
ef176dcf7e nixos/*: automatically convert option descriptions
conversions were done using https://github.com/pennae/nix-doc-munge
using (probably) rev f34e145 running

    nix-doc-munge nixos/**/*.nix
    nix-doc-munge --import nixos/**/*.nix

the tool ensures that only changes that could affect the generated
manual *but don't* are committed, other changes require manual review
and are discarded.
2022-08-31 16:32:53 +02:00
KFears
7f22740983 nixos/syncthing: fix path setting for versioning
Syncthing config XML uses `fsPath` setting for specifying the path to the versioning folder. This commit adds `services.syncthing.folders.<name>.versioning.fsPath` option to enable this functionality declaratively. Previously, `versioning.params.versionsPath` was used, which doesn't work.
2022-08-28 17:27:51 +04:00
Moritz 'e1mo' Fromm
79ae88a100
nixos/syncthing: Add receiveencrypted folder type
This folder type is available in syncthing, but could not be set in
NixOS.
See <https://docs.syncthing.net/users/untrusted.html> for reference.
2022-08-09 15:03:14 +02:00
pennae
2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00
Bjørn Forsman
65399c4742 nixos/syncthing: don't leak the secret API key in process listings 2022-07-23 13:59:11 +02:00
Greizgh
ac1e34f0fe
nixos/syncthing: fix services.syncthing.folders description
It was improperly referencing overrideDevices instead of overrideFolders.
2022-06-23 20:44:59 +02:00
pennae
320aa2a791 treewide: attempt at markdown option docs 2022-06-12 12:44:38 +02:00
Zane van Iperen
f533a6d2bd
nixos/modules/syncthing: add 22000/udp to firewall 2022-01-18 11:40:06 +10:00
pennae
2d564521c0 treewide: add literalDocBook text to options with complex defaults
some options have default that are best described in prose, such as
defaults that depend on the system stateVersion, defaults that are
derivations specific to the surrounding context, or those where the
expression is much longer and harder to understand than a simple text
snippet.
2021-12-09 01:38:24 +01:00
Naïm Favier
2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
Robin Stumm
1dd3bd8728 nixos/syncthing: fix declarative init crash on HTTPS
A previous config may be present that has HTTPS for the REST API enabled.
2021-08-31 11:27:51 +02:00
Robin Stumm
ead3028db0 nixos/syncthing: fix escapes interpreted in config
Dash `echo` interprets backslash escapes. This causes two consecutive backslashes in JSON to turn into a single one before the string is passed to jq, resulting in a parsing error.
2021-08-30 17:34:34 +02:00
Jakub Sokołowski
972a365488
syncthing: add extraFlags option that adjust service
This is useful for situations in which you might want to reset certain
things using `--reset-database` or `--reset-deltas` or debug certain
things using any of the debug options like `--debug-perf-stats`.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2021-08-29 12:26:06 +02:00
Jakub Sokołowski
b991f1e448
syncthing: add autoAcceptFolders to devices config
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2021-08-29 12:22:44 +02:00
Naïm Favier
12bbb0fd7b
nixos/syncthing: fix curl not retrying on network errors 2021-08-01 15:03:41 +02:00
Naïm Favier
f114215b14
nixos/syncthing: clean up option descriptions 2021-07-29 15:20:30 +02:00
Naïm Favier
e9b01c5c8e
nixos/syncthing: move declarative options to the top level 2021-07-28 11:30:30 +02:00
Naïm Favier
6416b3a941
nixos/syncthing: add declarative.extraOptions
Allows setting arbitrary config options through the REST API.

Also switches to the [new](https://docs.syncthing.net/rest/config.html)
config endpoints.
2021-07-28 10:56:06 +02:00
Doron Behar
5789ffc509 nixos/syncthing: add ignoreDelete folder option 2020-08-30 10:55:03 +03:00
Silvan Mosberger
1d0fc9729d
nixos/treewide: Fix incorrectly rendered examples
Many options define their example to be a Nix value without using
literalExample. This sometimes gets rendered incorrectly in the manual,
causing confusion like in https://github.com/NixOS/nixpkgs/issues/25516

This fixes it by using literalExample for such options. The list of
option to fix was determined with this expression:

  let
    nixos = import ./nixos { configuration = {}; };
    lib = import ./lib;
    valid = d: {
      # escapeNixIdentifier from https://github.com/NixOS/nixpkgs/pull/82461
      set = lib.all (n: lib.strings.escapeNixIdentifier n == n) (lib.attrNames d) && lib.all (v: valid v) (lib.attrValues d);
      list = lib.all (v: valid v) d;
    }.${builtins.typeOf d} or true;

    optionList = lib.optionAttrSetToDocList nixos.options;

  in map (opt: {
    file = lib.elemAt opt.declarations 0;
    loc = lib.options.showOption opt.loc;
  }) (lib.filter (opt: if opt ? example then ! valid opt.example else false) optionList)

which when evaluated will output all options that use a Nix identifier
that would need escaping as an attribute name.
2020-04-02 07:49:25 +02:00
Félix Baylac-Jacqué
ff8f2928ee
nixos/syncthing.nix: Sandbox the systemd service.
Using systemd sandboxing features to harden the syncthing service.
2020-01-20 21:48:48 +01:00
Silvan Mosberger
bc42515736
nixos/syncthing: Fix submodule name usage
Module arguments should be taken from the arguments directly. This
allows evalModule's specialArgs to override them if necessary
2020-01-02 09:59:35 +01:00
Ingolf Wagner
dcdf4cec3a nixos/syncthing: add versioning 2019-11-19 20:31:30 +01:00
Frederik Rietdijk
17b9054320 Revert "nixos/syncthing: simple versioning"
Descriptions are missing for params and type, blocking channels
from advancing.

https://nix-cache.s3.amazonaws.com/log/nkclpxwm91qhw0v1jg5dvzzckb7zh23s-nixpkgs-metrics.drv

This reverts commit 69493cc67a.
2019-11-13 12:25:52 +01:00
Ingolf Wagner
69493cc67a nixos/syncthing: simple versioning
add simple versioning. I did not add the other versioning
types because I did not understand most of them.
2019-11-12 19:29:18 +01:00
volth
35d68ef143 treewide: remove redundant quotes 2019-08-26 21:40:19 +00:00
Alexey Shmalko
e50539f7b5
syncthing: create default group if not overridden
The following configuration generates a systemd unit that doesn't
start.
```nix
{
  services.syncthing = {
    enable = true;
    user = "my-user";
  };
}
```

It fails with
```
systemd[1]: Started Syncthing service.
systemd[6745]: syncthing.service: Failed to determine group credentials: No such process
systemd[6745]: syncthing.service: Failed at step GROUP spawning /nix/store/n1ydz3i08nqp1ajc50ycy1zribmphqc9-syncthing-1.1.4-bin/bin/syncthing: No such process
systemd[1]: syncthing.service: Main process exited, code=exited, status=216/GROUP
systemd[1]: syncthing.service: Failed with result 'exit-code'.
```

This is due to the fact that `syncthing` group (default) is not
created if the user is overridden.

Add a separate check for setting up the default group, so that
user/group are created independently.
2019-07-29 21:56:12 +03:00
Peter Hoeg
8317663b94 nixos/syncthing: do not use nogroup
We were already creating a group for the user under which to run syncthing but
we were defaulting to running as `nogroup`.

Additionally, use `install` instead of multiple calls to mkdir/cp/chown.
2019-07-10 21:29:25 +08:00
Matthew Bauer
0a2b9719fd
Merge pull request #62157 from Lassulus/syncthing-fix
nixos/syncthing: run init only if a devices or folders are set
2019-05-29 21:02:18 -04:00
lassulus
87e9e65b6f nixos/syncthing: run init only if devices or folders are set 2019-05-29 13:57:39 +02:00