Synergy (Synergy - Share One Mouse & Keyboard Across Computers) is a very useful software to me. And I’m trying to add it’s configuration into my configuration.nix, I have read the doc(Appendix A. Configuration Options) , and the nix code (nixpkgs/synergy.nix at ad3234b7d68d65e5d1ccfc6ddfb4cea267441255 · NixOS/nixpkgs · GitHub), but I find that it need my IP, and I don’t know how to get it from nix script (I don’t want to hard code it) , is there any example configuration.nix about it’s configuration?
you can use hostnames too in case your ip changes.
Do you have a static IP address that you set in your configuration.nix
file, or are you using DHCP? If you set a static IP address on your machine you can create a let
statement and pass the IP to synergy
, but if you are using DHCP then your IP address is dynamic and can change, something you can’t account for in the nix
language. As @teto mentioned using a hostname would be a good solution in this case.
Thanks, that helps. But I want my configuration.nix
portable between machines, so is there any way to get current ip or hostname in the nix script?
nix configuration is static while network configuration is dynamic so either you generate the nix configuration either you use the hostname or some network indirection like DNS.