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: Use API to merge / override configurations #230182

Closed
wants to merge 1 commit into from

Conversation

doronbehar
Copy link
Contributor

@doronbehar doronbehar commented May 5, 2023

Description of changes

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 a Bash for loop the devices and folders IDs and merges the keys using upstream's curl -X PATCH support, and support for setting settings per individual folders and devices via ID in the URL.

Hence this commit fixes #230146.

Things done

I tested this via running manually the merge-syncthing-config script generated with overrideFolders and overrideDevices set to false and true.

  • 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.

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 NixOS#230146. This PR makes the script iterate
via a Bash for loop the devices and folders IDs and merges the keys
using upstream's `curl -X PATCH` support, and support for setting
settings per individual folders and devices via ID in the URL.

Hence this commit fixes NixOS#230146.
@doronbehar
Copy link
Contributor Author

nixosTests.syncthing-init fails now from some reason :/...

@doronbehar
Copy link
Contributor Author

Aish... Syncthing can't add folders or devices via curl -X PUT .../rest/folders/*id*... Too bad.

@doronbehar doronbehar closed this May 5, 2023
@doronbehar
Copy link
Contributor Author

Although upstream seems to have strived to make it possible in https://github.com/syncthing/syncthing/pull/7001/files#r496121513 ... It works now! Tests pass.

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.

Syncthing NixOS module jq based config script doesn't merge folders correctly
1 participant