Commit graph

98 commits

Author SHA1 Message Date
Lukas Wurzinger 1f4c50ab81
lib/cli: deprecate toGNUCommandLine 2025-10-21 21:01:38 +02:00
zorrobert 7a223b2685 nixos/syncthing: add option for ignore patterns
Syncthing can be configured to ignore certain files and
directories via ignore patterns. This PR adds a new nix option to
set these patterns declaratively.
2025-10-21 12:57:28 +02:00
Kimberly Swanson 02795dee2c nixos/syncthing: add guiPasswordFile option 2025-10-03 04:43:24 -07:00
h7x4 58ef4b7ae2
nixos/syncthing: use types.port 2025-09-22 16:33:01 +02:00
isabel 063267b711
nixos/syncthing: fix flags against 2.0 release 2025-08-31 09:02:19 +01:00
Wolfgang Walther 5a0711127c
treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Jason Yundt de0be57ef7 nixos/syncthing: install syncthing command and man page
Before this change, setting services.syncthing.enable to true would
enable Syncthing, but it wouldn’t add Syncthing’s man page to your
system. This change ensures that the man page is available.

I tested this change using this Nix expression:

  let
    nixpkgsRepo = /path/to/nixpkgs/repo;
    pkgs = import nixpkgsRepo { };
  in pkgs.testers.runNixOSTest {
    name = "syncthing-man-page-test";
    nodes.machine = {
      services.syncthing.enable = true;
    };
    testScript = ''
      start_all()
      machine.succeed("man syncthing > log.txt")
      machine.copy_from_vm("log.txt", ".")
    '';
  }
2025-07-03 08:19:06 -04:00
Jason Yundt 816afcf9c0 nixos/syncthing: get systemd units from cfg.package
Before this change, the syncthing module used two potentially different
packages for Syncthing. Sometimes, it would use cfg.package and
sometimes it would use pkgs.syncthing. This change makes the syncthing
module more consistent by making it always use cfg.package.

The reference to pkgs.syncthing was added in
1026bebee6. I looked through that commit
message and the thread for the pull request that it came from [1], and I
couldn’t find anything that explained why pkgs.syncthing was used over
cfg.package. I’m guessing that using pkgs.syncthing over cfg.package was
a mistake, but I’m not sure.

[1]: <https://github.com/NixOS/nixpkgs/pull/18973>
2025-07-03 07:37:23 -04:00
Sveske_Juice 3303249ed2 nixos/syncthing: fix cert/key permission error 2025-05-19 11:51:47 +02:00
Jeremy Fleischman 1b7b89c4ef
Demonstration of an alternate way to embed secrets into syncthing config 2025-05-03 12:43:42 -07:00
Aurimas Blažulionis d8b850d88f
syncthing: expose encryptionPassword
- Change `folder.devices` type into `oneOf [(listOf str) (attrsOf
  (submodule { ... }))]`.
- Expose `encryptionPassord` within the attrSet of the devices option.

This allows the user to set the encrpyption password use to share the
folder's data with. We do this by file path, as opposed to string
literal, because we do not want to embed the encrpyption password into
the nix store.
2025-04-01 14:20:31 -05:00
Aurimas Blažulionis 848e754b81
syncthing: handle encryptionPassword secret
Rewrite the syncthing config update script to embed secrets into the
json request. Specifically, we handle the `encryptionPassword` secret.
With this code, the user can embed path to the encrpyption password for
a given device the folder is shared with, and have it loaded in, without
touching the nix store.
2025-04-01 14:20:31 -05:00
Silvan Mosberger 374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Bjørn Forsman d0e369e425 Revert "nixos/syncthing: missing --fail to curl"
This reverts commit a8b8f8f8c7.

It introduced a failure in the syncthing service, where it hangs at the
curl step, repeatedly printing this:

  l3ijkvb20h5nnffg5q25i4nmcsbf7glx-merge-syncthing-config[1458]: curl: (22) The requested URL returned error: 404
  l3ijkvb20h5nnffg5q25i4nmcsbf7glx-merge-syncthing-config[1458]: curl: (22) The requested URL returned error: 404
  l3ijkvb20h5nnffg5q25i4nmcsbf7glx-merge-syncthing-config[1458]: curl: (22) The requested URL returned error: 404
  [...]

This is unfortunately not detected by `nix-build -A syncthing.tests`.

Ref https://github.com/NixOS/nixpkgs/pull/390742
2025-03-22 20:05:16 +01:00
Dawid Ciężarkiewicz 07a3793105 nixos/syncthing: make it easier to debug incorrect IDs
In case of an incorrect ID, the behavior of this script
is quite tricky. See:

https://github.com/NixOS/nixpkgs/issues/326704#issuecomment-2730819822

for more info.
2025-03-18 19:10:10 +01:00
Dawid Ciężarkiewicz a8b8f8f8c7 nixos/syncthing: missing --fail to curl 2025-03-18 19:10:10 +01:00
Faye Duxovni 87806c913c
nixos/syncthing: prevent enabling overrideFolders and autoAcceptFolders simultaneously (#321872)
* syncthing: prevent enabling overrideFolders and autoAcceptFolders simultaneously

* Fix href in services.syncthing.overrideFolders default text
2025-03-01 14:36:50 +01:00
a-kenji fdbcd907e9 nixos/syncthing: Fix typos 2025-02-19 15:44:05 +07:00
r-vdp 94532d1530 nixos/syncthing: remove syncthing-resume service
It was removed upstream in https://github.com/syncthing/syncthing/pull/9611
and the stub generated by nixos now prints an error in the logs due to
it not having a ExecStart line.
2024-10-05 12:55:39 +02:00
Cat ed1b6699c0
nixos/syncthing: implement folder type (#308832)
* Syncthing: implemented folder type

* Syncthing: fix syntax (via @johnhamelink )

This commit should be rebased/squashed into the previous one if ofborg cleares it!

Co-authored-by: John Hamelink <me@johnhame.link>

---------

Co-authored-by: John Hamelink <me@johnhame.link>
2024-07-02 19:49:03 +08:00
stuebinm 6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
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