-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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 #230196
Conversation
If that's the only problem, why not just fix the jq script to use |
I tried to modify the |
there is a small refactor happening in #226088 so maybe we merge that and you could rebase the PR? |
I totally understand, and I can at least add more comments, let's see what can we do after #226088 is merged. |
fcf7549
to
c562b96
Compare
@ofborg test syncthing-init syncthing |
c562b96
to
05f9a73
Compare
The tests work. I updated the commit to include many more comments. Your review is welcome @Lassulus . |
#230196 (comment) still holds. |
@ncfavier I am not sure we want to use It can't really differentiate (in our case) between the array object that was created by the Nix configuration, vs the object that was further expanded by Syncthing. I think we want to be sure that the folder / device we add via the API have the same other attributes as those of the Nix configuration. This adds up to the readability advantage I find in the current script: The difference between If you find some sophisticated way of performing this logic via jq, I'd be willing to review it, but personally it proved to be much harder then it seemed to me, especially in comparison to the solution currently implemented. |
44036d4
to
44c831d
Compare
I tested these changes as part of trying to reproduce #232679 - with and without my patch, and it works for me (had to fix small Bash issue). |
I think this PR can probably wait until 23.05 is released. |
Personally I won't mind, as I always use In anycase, I'd be glad to reach some kind of agreement regarding the issues mentioned earlier - Bash / Nix mixing readability, and using more |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
7e143bd
to
a5ff056
Compare
I'm a bit unhappy that we are no longer atomic if we do multiple curl requests |
Why is a single, atomic curl request better? If there's a single, minor problem with it, it completely fails, and it's hard to debug why. This is exactly what happened in #230146, and what took me hours to debug. |
9b5f283
to
33a8f1c
Compare
I improved the comments, and used |
33a8f1c
to
794be08
Compare
Ah indeed. then we had no atomic behavior before also. So it's not a regression but an improvement |
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 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 NixOS#230146.
794be08
to
047fa8d
Compare
I just amended a bit the commit message, no real change besides that. |
If you know someone who has the time and interest to review it would be cool, otherwise I would merge it in the next week |
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'scurl -X PATCH
support for single objects.Hence this commit fixes #230146.
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)