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: applied rfc42 and added some additional options #226088

Merged
merged 1 commit into from
May 16, 2023

Conversation

Xyz00777
Copy link
Contributor

@Xyz00777 Xyz00777 commented Apr 13, 2023

Description of changes

try to implement options who are not available as nixos options at the moment, e.g. copyOwnershipFromParent who is a suboptions of folders and can not be implemented at the moment with the extraoptions option.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

its my first commit and merge request for nixos, so i sadly have absolut no plan how to test the new config.
I tried to implement all options i found beside of <minDiskFree unit="%">1</minDiskFree> in options and folders because i didnt know how to implement that and also not <encryptionPassword></encryptionPassword> under folders.device.
If someone could help me i would really like to see that :)

Greetings

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Apr 13, 2023
@Xyz00777
Copy link
Contributor Author

i have seen a moment ago that encyptionPassword will already get implemented by #205653.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Apr 13, 2023
@bjornfor
Copy link
Contributor

Can we use a generic settings* option (NixOS/rfcs#42) instead of having to duplicate every upstream option in downstream nixos?

@Xyz00777
Copy link
Contributor Author

Xyz00777 commented Apr 15, 2023

i have no problems with that @bjornfor . we could do that with the change to 23.05 but not in 22.11 atm because that could be breaking for some users

@Xyz00777
Copy link
Contributor Author

tested together with @Lassulus and the tests worked

@Lassulus
Copy link
Member

ok, after spending an hour looking at the code, this would be my plan to move forward:

rename the extraOptions to settings. move the devices & folders to settings and make them into freeformTypes (like extraOptions is now). Then we don't need to serialize all the possibe options for device, folder and global separately and only document the most important ones.

@Lassulus Lassulus force-pushed the master branch 2 times, most recently from 2f2ccdf to 3d77d9d Compare April 28, 2023 21:02
@Lassulus
Copy link
Member

alright and I spend another hour doing that refactor, although it's not finished yet. I guess we don't need to document all the options (for example startBrowser, releasesUrl, ...)

@Xyz00777
Copy link
Contributor Author

i just done the aditional like them because i had time :D

@Lassulus Lassulus force-pushed the master branch 2 times, most recently from df123d4 to 3498b5b Compare April 28, 2023 22:40
@Xyz00777 Xyz00777 changed the title nixos/syncthing: included new options who are not available at the moment nixos/syncthing: applied rfc42 Apr 29, 2023
@Xyz00777 Xyz00777 changed the title nixos/syncthing: applied rfc42 nixos/syncthing: applied rfc42 and added some additional options Apr 29, 2023
@zarelit
Copy link
Member

zarelit commented Apr 30, 2023

Related to #144575, too

Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

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

Looks great to me! That's my only comment.

@@ -530,6 +520,10 @@ in {
This option was removed because Syncthing now has the inotify functionality included under the name "fswatcher".
It can be enabled on a per-folder basis through the web interface.
'')
(mkRenamedOptionModule [ "services" "syncthing" "extraOptions" ] [ "services" "syncthing" "settings" ])
(mkRenamedOptionModule [ "services" "syncthing" "folders" ] [ "services" "syncthing" "settings" "folders" ])
Copy link
Contributor

Choose a reason for hiding this comment

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

Something like this (along with the other options):

Suggested change
(mkRenamedOptionModule [ "services" "syncthing" "folders" ] [ "services" "syncthing" "settings" "folders" ])
(mkRenamedOptionModule [ "services" "syncthing" "folders" ] [ "services" "syncthing" "settings" "folders" ])
(mkRenamedOptionModule [ "services" "syncthing" "folders" "rescanIntervalS" ] [ "services" "syncthing" "settings" "folders" "rescanInterval" ])

Copy link
Member

Choose a reason for hiding this comment

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

hmm, this gives me an eval error. not sure how we can fix that

Copy link
Contributor

Choose a reason for hiding this comment

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

Because the folder's path is supposed to be in between the "folders" and the rescanIntervalS... I'm not sure how to do that, as the path can be anything of course.

Copy link
Contributor

Choose a reason for hiding this comment

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

I tend to think it's impossible to perform such a 'variable' rename. If indeed we won't find a way to do it, I think it'd be OK to give up on this, as anyway we rename an module option a level higher, which might trigger hopefully a second look on the documentation anyway..

Also, in anycase, it'd be nice to mention all of the changes here in the release notes.. (@Xyz00777 )

Copy link
Member

Choose a reason for hiding this comment

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

...so the solution we went with here is really "silently ignore the problem and hope the user will read the release notes"? How is this acceptable?

We should either reintroduce the mapping or add an assertion.

Copy link
Contributor

Choose a reason for hiding this comment

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

...so the solution we went with here is really "silently ignore the problem and hope the user will read the release notes"? How is this acceptable?

We should either reintroduce the mapping or add an assertion.

Indeed I forgot about the release notes entry... If you know how to create that mapping, or add an assertion, I'd be happy to review and test it. I am not sure it's possible to do it TBH. I also asked for help on discourse and got no response.

Copy link
Member

Choose a reason for hiding this comment

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

I've added an assertion in #232439. We can't use the module system for this because of #96006.

Could you open a PR for the release note entry?

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/rename-a-module-option-when-one-components-in-the-option-path-is-a-variable/27946/1

@doronbehar
Copy link
Contributor

@Xyz00777 could you please also perform the proper renames in:

nixos/tests/syncthing-init.nix
nixos/tests/syncthing.nix

@doronbehar
Copy link
Contributor

Friendly ping @Xyz00777 . Could you help us with the nixos/tests/syncthing{,-init}.nix files?

@doronbehar doronbehar merged commit 9b0a03f into NixOS:master May 16, 2023
@Xyz00777
Copy link
Contributor Author

Hi sorry for my delay, I forgot to answer. I had question @Lassulus because I didn't know how to add them and he mean that he already answered an question like that somewhere.

Thanks for the merge! :)

I will try to get better with nix for doing it myself

@azahi
Copy link
Member

azahi commented May 17, 2023

Looks like this introduced a regression in configuration. Setting for example services.syncthing.settings.options.autoUpgradeIntervalH or services.syncthing.settings.folders.${name}.versioning.params doesn't work anymore for me.

@doronbehar
Copy link
Contributor

doronbehar commented May 17, 2023 via email

Comment on lines -619 to +613
cfg.devices != {} || cfg.folders != {} || cfg.extraOptions != {}
cfg.settings.devices != {} || cfg.folders != {} || cfg.extraOptions != {}
Copy link
Member

Choose a reason for hiding this comment

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

This looks suspicious

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed this looks bad. What do you think about simplify it to:

diff --git i/nixos/modules/services/networking/syncthing.nix w/nixos/modules/services/networking/syncthing.nix
index b5ebda6da04..d5531409428 100644
--- i/nixos/modules/services/networking/syncthing.nix
+++ w/nixos/modules/services/networking/syncthing.nix
@@ -610,7 +610,7 @@ in {
         };
       };
       syncthing-init = mkIf (
-        cfg.settings.devices != {} || cfg.folders != {} || cfg.extraOptions != {}
+        cfg.settings != {}
       ) {
         description = "Syncthing configuration updater";
         requisite = [ "syncthing.service" ];

Copy link
Member

Choose a reason for hiding this comment

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

sure

Copy link
Contributor

Choose a reason for hiding this comment

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

That condition hasn't prevented the syncthing-init.service from being generated, and this is not the issue @azahi is experiencing. It is still worth fixing though.

@azahi
Copy link
Member

azahi commented May 17, 2023

What do you mean by "doesn't work"? Do you mean that it is essentially ignored?

error: The option `services.syncthing.settings.folders.share.versioning.params' does not exist. Definition values:
       - In `/nix/store/4waix1crf1vadmk5dc1yqsbn7zxkdr4x-source/modules/nixos/syncthing.nix':
           {
             cleanoutDays = "7";
           }
error: A definition for option `services.syncthing.settings.options.crashReportingEnabled' is not of type `JSON value'. Definition values:
       - In `/nix/store/l7165dvk51aahr3bglq8pi6idgh9qwj2-source/modules/nixos/syncthing.nix': false

@azahi
Copy link
Member

azahi commented May 17, 2023

Could this be some kind of an attribute name collision with nixpkgs module system? settings.gui.bar = "baz" or settings.foo.bar = "baz" works fine, only settings.options.bar = "baz" breaks. Or maybe it's something with toJSON?

Comment on lines -307 to 322
fsPath = mkOption {
default = "";
type = either str path;

id = mkOption {
type = types.str;
description = mdDoc ''
Path to the versioning folder.
See <https://docs.syncthing.net/users/versioning.html>.
The device ID. See <https://docs.syncthing.net/dev/device-ids.html>.
'';
};
params = mkOption {
type = attrsOf (either str path);

autoAcceptFolders = mkOption {
type = types.bool;
default = false;
description = mdDoc ''
The parameters for versioning. Structure depends on
[versioning.type](#opt-services.syncthing.folders._name_.versioning.type).
See <https://docs.syncthing.net/users/versioning.html>.
Automatically create or share folders that this device advertises at the default path.
See <https://docs.syncthing.net/users/config.html?highlight=autoaccept#config-file-format>.
'';
};
Copy link
Member

Choose a reason for hiding this comment

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

First error @azahi reports is due to these options being removed without a corresponding freeformType added.

'';
};
type = types.attrsOf (types.submodule ({ name, ... }: {
Copy link
Member

Choose a reason for hiding this comment

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

Second issue @azahi reports is due to the extra attrsOf here.

@ncfavier ncfavier mentioned this pull request May 17, 2023
12 tasks
@ncfavier
Copy link
Member

#232439 should fix both issues, please double-check.

ncfavier added a commit to ncfavier/nixpkgs that referenced this pull request May 17, 2023
ncfavier added a commit that referenced this pull request May 17, 2023
@doronbehar
Copy link
Contributor

doronbehar commented May 17, 2023 via email

@RaitoBezarius
Copy link
Member

It seems like this PR caused more damage than expected and everyone seems to continue moving forward on this.

Breaking changes were RESTRICTED since a while. I was affected too, please tell me what's your plan forward regarding the blast area caused by those changes? If not, please consider a mass revert of those changes and wait for branch-off which is supposed to take place in 4 days if you cannot stabilize those changes.

@ncfavier
Copy link
Member

I am proposing to revert this in #233377. Sorry @Xyz00777, bad timing.

@Xyz00777
Copy link
Contributor Author

Sad but absolutely okay and understandable for me @Lassulus how far is the fix you wanted to make? I didn't tracked all the changes and messages everyone done here...

@ncfavier
Copy link
Member

I think the main problem is that it's not clear any longer how to detect whether the user intends to manage their configuration declaratively. Previously we could test each of folders, devices and extraOptions, but with this PR extraOptions gets moved into settings which has default values so we can't just check that settings != {}. Maybe we could check options.services.syncthing.settings.isDefined or something but I'm not sure and I don't have time to check.

This check is important to avoid destroying users' imperatively configured folders and devices (see the original motivation for #62157).

Beyond that, as mentioned in #232679 (comment), I am not convinced we need to move folders and devices at all. Putting them inside settings seems to just complicate things for users and developers. I don't think anything prevents us from adding freeformTypes to the existing options.

mart-w added a commit to mart-w/nixpkgs that referenced this pull request Jun 2, 2023
The breaking change in this patch note has been reverted for now, see NixOS#226088.
github-actions bot pushed a commit that referenced this pull request Jun 3, 2023
The breaking change in this patch note has been reverted for now, see #226088.

(cherry picked from commit 2251304)
@Janik-Haag Janik-Haag added the 12. first-time contribution This PR is the author's first one; please be gentle! label Jun 13, 2023
Jayman2000 added a commit to Jayman2000/jasons-nixos-config that referenced this pull request Jun 30, 2024
Ever since this PR [1], some of the Syncthing options that I’ve been
using have new names. The old names are deprecated. This commit makes it
so that I don’t use the deprecated names anymore.

Fixes <mid:bu4dbznoivldxaxkdyzkd472vryl7wqzcvjunrg5pqe7ta5bu4@6pic33ncld5n>.

[1]: <NixOS/nixpkgs#226088>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 12. first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.