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

bug: syncthing configuration not applied after switch in macOS #6542

Open
2 tasks done
jpalharini opened this issue Feb 27, 2025 · 4 comments
Open
2 tasks done

bug: syncthing configuration not applied after switch in macOS #6542

jpalharini opened this issue Feb 27, 2025 · 4 comments
Assignees
Labels
bug triage Issues or feature request that have not been triaged yet

Comments

@jpalharini
Copy link

jpalharini commented Feb 27, 2025

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

I have recently started using Syncthing with home-manager, and while it works just fine in my x86_64-linux NixOS install, it doesn't seem to refresh the configuration on my aarch64-darwin machine with nix-darwin and home-manager.

My setup is entirely on a flake.nix file, and home-manager is split from nix-darwin and NixOS modules.

Maintainer CC

@rycee @pitkling @khaneliman

System information

- system: `"aarch64-darwin"`
- host os: `Darwin 24.3.0, macOS 15.3.1`
- multi-user?: `yes`
- sandbox: `no`
- version: `nix-env (Nix) 2.24.12`
- channels(root): `"nixpkgs"`
- nixpkgs: `/Users/joao.palharini/.nix-defexpr/channels/nixpkgs`
@jpalharini jpalharini added bug triage Issues or feature request that have not been triaged yet labels Feb 27, 2025
@pitkling
Copy link
Contributor

pitkling commented Feb 27, 2025

@jpalharini: Can you please run

launchctl print gui/501/org.nix-community.home.syncthing-init | grep runs

and check its output? If it's runs = 0 then it seems the syncthing-init launch agent did not run (it is responsible for updating the syncthing configuration).

You can also try to trigger it manually via

touch ~/Library/Application\ Support/Syncthing/.launchd_update_config

If you then again check the runs via the first command, the run count should increase.

@347Online
Copy link

I experience this same issue, Syncthing configuration is not applied on darwin-rebuild. Some settings I couldn't seem to get to take effect even with a full reboot e.g. the gui user / authentication.

@pitkling I ran the commands you suggested just to see and I did see runs=1 and then runs=2. Let me know if this tells you anything.

@pitkling
Copy link
Contributor

pitkling commented Feb 28, 2025

[…] @pitkling I ran the commands you suggested just to see and I did see runs=1 and then runs=2. Let me know if this tells you anything.

Thanks @347Online: That seems to indicate that at least the agent responsible for triggering the config update is running and working. You can confirm that by running again

touch ~/Library/Application\ Support/Syncthing/.launchd_update_config

and then check after a few seconds via

ls -l ~/Library/Application\ Support/Syncthing/{config.xml,.launchd_update_config}

that the config file (config.xml) has a later modification date than .launchd_update_config. Maybe also check whether the actual changes you did in your nix configurations end up in config.xml.


Now, I did some tests on my Linux/Darwin systems and for me both behaved basically the same. Can you elaborate what setting updates seem to work on Linux but not on Darwin, @jpalharini?

Anyway, there do seem to be a few potential issues for both Linux and Darwin I stumbled upon during my tests:

  • darwin-rebuild switch … and nixos-rebuild switch … will not update the syncthing config if syncthing was already enabled in the previous generation. A reboot is currently required. The reason seems to be that switching to new generations does not reload the launch agents (on Darwin) or systemd services (on Linux) if they were active in the previous generation.
  • Since @347Online explicitly mentioned gui user / authentication: For me, updating this works on both Darwin (after a manual touch ~/Library/Application\ Support/Syncthing/.launchd_update_config or reboot) and Linux (after a reboot). But note that if you had
    services.syncthing.settings.gui = {
      user = "foo";
      password = "bar";
    };
    
    in your config and then remove it, this will not be reflected in the config, even after a reboot. I think this is a problem with the code we took from the NixOS module. It seems only to update options that are set explicitly in nix but not to remove options that are not set or set to null. Maybe @karaolidis, who ported the config update code from NixOS to Home Manager, can confirm this?

@karaolidis
Copy link
Contributor

Indeed, after having a quick look I am fairly sure this is the case. I hadn't ran into this issue as I am currently on an impermanence setup, so the config was getting wiped on boot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Issues or feature request that have not been triaged yet
Projects
None yet
Development

No branches or pull requests

7 participants