Clonix: declarative rsync deployments

It works a lot like syncthing but in your nixos/home-manager configuration instead of a standalone program (and it also uses rsync in the backend by default).

This project most likely is quite redundant considering that syncthing already has NixOS options, but I made this project before I knew that, but at least it was my first nix-related project and it was a wonderful learning experience!

You can check it out on its github page if you want to!

12 Likes

Very nice.

I saw that you are building the command by concatenating strings. nixpkgs has lib.escapeShellArgs that deals with escaping a list of arguments to a string.

That way you can concat the lists conditionally using lb.optional or lib.optionals then in the end join the arguments using lib.escapeShellArgs.

Also, if the rsync source ends with / it will strip the root folder and copy the contents inside directly.

Also, to get the main binary from the packages you can use lib.getExe instead of "${pkgs.something}/bin/something"

3 Likes

I don’t think I would consider this redundant at all. We can’t really assume that everybody wants to use syncthing for one reason or the other. Nothing wrong with having options.

1 Like

Oh! I didnt know those functions / types existed! Ill mess around with them and implement them on clonix and my other projects. Thank you! - That lib.getExe tip was also awesome!

I guess it makes sense! I usually stop making projects when I see that I could do whatever I was trying to do with something that already exists. But I guess that makes sense! Nothing wrong with more options!