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 ddclient: support multiple domains and run via systemd timer #36864

Merged
merged 1 commit into from Apr 19, 2018

Conversation

peterhoeg
Copy link
Member

Motivation for this change

Some providers can handle multiple domains so add support for that.

Additionally, ddclient will by default run all the time and then do its thing at an interval. The interval is quite short by default (10 minutes) but if someone was increase that to half a day (as an example) it would be pointless to leave the ddclient running for the entire time. Instead we just let systemd handle the timing.

Running with this set-up here - so far it looks good.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: ddclient

Partial log (click to expand)

no Makefile, doing nothing
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/3gwki8430q4shzkqqy5zqmfl19c9sim0-perl-ddclient-3.8.3
strip is /nix/store/b0zlxla7dmy1iwc3g459rjznx59797xy-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/3gwki8430q4shzkqqy5zqmfl19c9sim0-perl-ddclient-3.8.3/bin 
patching script interpreter paths in /nix/store/3gwki8430q4shzkqqy5zqmfl19c9sim0-perl-ddclient-3.8.3
/nix/store/3gwki8430q4shzkqqy5zqmfl19c9sim0-perl-ddclient-3.8.3/bin/ddclient: interpreter directive changed from "/usr/bin/perl -w -I/nix/store/k4pbpl837wbsdzhvqj5a2khz9idmqwzi-perl-IO-Socket-SSL-2.050/lib/perl5/site_perl -I/nix/store/iahqmdckx09v1ipqry1lrq0ki8d1qsxf-perl-Net-SSLeay-1.77/lib/perl5/site_perl -I/nix/store/qc04jc17k17h2xfl4v7iq865qidgcq8q-perl-URI-1.73/lib/perl5/site_perl -I/nix/store/m8xsir8lnx6jz9h7n5lrnk26vf3g3hdd-perl-Digest-SHA1-2.13/lib/perl5/site_perl -I/nix/store/s029gmjpgvm776wfb56naqny9qja9339-perl-5.24.3/lib/perl5/site_perl -I/nix/store/k4pbpl837wbsdzhvqj5a2khz9idmqwzi-perl-IO-Socket-SSL-2.050/lib/perl5/site_perl -I/nix/store/iahqmdckx09v1ipqry1lrq0ki8d1qsxf-perl-Net-SSLeay-1.77/lib/perl5/site_perl -I/nix/store/qc04jc17k17h2xfl4v7iq865qidgcq8q-perl-URI-1.73/lib/perl5/site_perl -I/nix/store/m8xsir8lnx6jz9h7n5lrnk26vf3g3hdd-perl-Digest-SHA1-2.13/lib/perl5/site_perl -I/nix/store/s029gmjpgvm776wfb56naqny9qja9339-perl-5.24.3/lib/perl5/site_perl -I/nix/store/3gwki8430q4shzkqqy5zqmfl19c9sim0-perl-ddclient-3.8.3/lib/perl5/site_perl" to "/nix/store/s029gmjpgvm776wfb56naqny9qja9339-perl-5.24.3/bin/perl -w -I/nix/store/k4pbpl837wbsdzhvqj5a2khz9idmqwzi-perl-IO-Socket-SSL-2.050/lib/perl5/site_perl -I/nix/store/iahqmdckx09v1ipqry1lrq0ki8d1qsxf-perl-Net-SSLeay-1.77/lib/perl5/site_perl -I/nix/store/qc04jc17k17h2xfl4v7iq865qidgcq8q-perl-URI-1.73/lib/perl5/site_perl -I/nix/store/m8xsir8lnx6jz9h7n5lrnk26vf3g3hdd-perl-Digest-SHA1-2.13/lib/perl5/site_perl -I/nix/store/s029gmjpgvm776wfb56naqny9qja9339-perl-5.24.3/lib/perl5/site_perl -I/nix/store/k4pbpl837wbsdzhvqj5a2khz9idmqwzi-perl-IO-Socket-SSL-2.050/lib/perl5/site_perl -I/nix/store/iahqmdckx09v1ipqry1lrq0ki8d1qsxf-perl-Net-SSLeay-1.77/lib/perl5/site_perl -I/nix/store/qc04jc17k17h2xfl4v7iq865qidgcq8q-perl-URI-1.73/lib/perl5/site_perl -I/nix/store/m8xsir8lnx6jz9h7n5lrnk26vf3g3hdd-perl-Digest-SHA1-2.13/lib/perl5/site_perl -I/nix/store/s029gmjpgvm776wfb56naqny9qja9339-perl-5.24.3/lib/perl5/site_perl -I/nix/store/3gwki8430q4shzkqqy5zqmfl19c9sim0-perl-ddclient-3.8.3/lib/perl5/site_perl"
checking for references to /tmp/nix-build-perl-ddclient-3.8.3.drv-0 in /nix/store/3gwki8430q4shzkqqy5zqmfl19c9sim0-perl-ddclient-3.8.3...
/nix/store/3gwki8430q4shzkqqy5zqmfl19c9sim0-perl-ddclient-3.8.3

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: ddclient

Partial log (click to expand)

no Makefile, doing nothing
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/ql4mgjirzgj48ni303xgcqkshd7gclcs-perl-ddclient-3.8.3
strip is /nix/store/lvx1acn1ig1j2km8jds5x3ggh3f2wa8v-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/ql4mgjirzgj48ni303xgcqkshd7gclcs-perl-ddclient-3.8.3/bin
patching script interpreter paths in /nix/store/ql4mgjirzgj48ni303xgcqkshd7gclcs-perl-ddclient-3.8.3
/nix/store/ql4mgjirzgj48ni303xgcqkshd7gclcs-perl-ddclient-3.8.3/bin/ddclient: interpreter directive changed from "/usr/bin/perl -w -I/nix/store/b2wwx668bc8a7bk9gq5jbqjk59xr9417-perl-IO-Socket-SSL-2.050/lib/perl5/site_perl -I/nix/store/qfrbfri1rn8nnnljfqxshzglmcmrng9f-perl-Net-SSLeay-1.77/lib/perl5/site_perl -I/nix/store/fjshgnp4vngscn8i3sv5jvgrd9lr7yz2-perl-URI-1.73/lib/perl5/site_perl -I/nix/store/v0qg83spj5kjxqjpmnhnlbvifrzci7rc-perl-Digest-SHA1-2.13/lib/perl5/site_perl -I/nix/store/g1naqig0jxakwmf8688d95xfm8xch4dm-perl-5.24.3/lib/perl5/site_perl -I/nix/store/b2wwx668bc8a7bk9gq5jbqjk59xr9417-perl-IO-Socket-SSL-2.050/lib/perl5/site_perl -I/nix/store/qfrbfri1rn8nnnljfqxshzglmcmrng9f-perl-Net-SSLeay-1.77/lib/perl5/site_perl -I/nix/store/fjshgnp4vngscn8i3sv5jvgrd9lr7yz2-perl-URI-1.73/lib/perl5/site_perl -I/nix/store/v0qg83spj5kjxqjpmnhnlbvifrzci7rc-perl-Digest-SHA1-2.13/lib/perl5/site_perl -I/nix/store/g1naqig0jxakwmf8688d95xfm8xch4dm-perl-5.24.3/lib/perl5/site_perl -I/nix/store/ql4mgjirzgj48ni303xgcqkshd7gclcs-perl-ddclient-3.8.3/lib/perl5/site_perl" to "/nix/store/g1naqig0jxakwmf8688d95xfm8xch4dm-perl-5.24.3/bin/perl -w -I/nix/store/b2wwx668bc8a7bk9gq5jbqjk59xr9417-perl-IO-Socket-SSL-2.050/lib/perl5/site_perl -I/nix/store/qfrbfri1rn8nnnljfqxshzglmcmrng9f-perl-Net-SSLeay-1.77/lib/perl5/site_perl -I/nix/store/fjshgnp4vngscn8i3sv5jvgrd9lr7yz2-perl-URI-1.73/lib/perl5/site_perl -I/nix/store/v0qg83spj5kjxqjpmnhnlbvifrzci7rc-perl-Digest-SHA1-2.13/lib/perl5/site_perl -I/nix/store/g1naqig0jxakwmf8688d95xfm8xch4dm-perl-5.24.3/lib/perl5/site_perl -I/nix/store/b2wwx668bc8a7bk9gq5jbqjk59xr9417-perl-IO-Socket-SSL-2.050/lib/perl5/site_perl -I/nix/store/qfrbfri1rn8nnnljfqxshzglmcmrng9f-perl-Net-SSLeay-1.77/lib/perl5/site_perl -I/nix/store/fjshgnp4vngscn8i3sv5jvgrd9lr7yz2-perl-URI-1.73/lib/perl5/site_perl -I/nix/store/v0qg83spj5kjxqjpmnhnlbvifrzci7rc-perl-Digest-SHA1-2.13/lib/perl5/site_perl -I/nix/store/g1naqig0jxakwmf8688d95xfm8xch4dm-perl-5.24.3/lib/perl5/site_perl -I/nix/store/ql4mgjirzgj48ni303xgcqkshd7gclcs-perl-ddclient-3.8.3/lib/perl5/site_perl"
checking for references to /build in /nix/store/ql4mgjirzgj48ni303xgcqkshd7gclcs-perl-ddclient-3.8.3...
/nix/store/ql4mgjirzgj48ni303xgcqkshd7gclcs-perl-ddclient-3.8.3

@peterhoeg peterhoeg changed the title nixos ddclient: support multiple domains and run via systemd timer nixos ddclient: support multiple domains and run via systemd timer [WIP] Mar 13, 2018
@@ -25,7 +26,12 @@ buildPerlPackage rec {
'';

installPhase = ''
runHook preInstall
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's better to change installPhase to postInstall, so the hooks don't have to be invoked manually?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how this is more explicit - everything that happens for the install happens here.

Is there a "recommended pattern"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's written down, but I think it's recommended to not override the phases directly, but rather add stuff to pre/post. It's easy to forget to invoke the hooks. (As evidenced by this expression that you're fixing now.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is, this is the installation phase. From the perspective of "least surprising behaviour" I would assume installation is done in the installPhase. If we do this in postInstall instead, somebody cannot override that phase without not having anything installed.

I fully understand where you're coming from though - when people start messing with phases directly there is a high chance of someone breaking things or accidentally leaving out phases that should be run. But in this case this is actually doing the right thing (IMHO).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

type = str;
description = ''
The interval at which to run the check and update.
See <command>man 7 systemd.time</command> for the format.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of

See <command>man 7 systemd.time</command> for the format.

it is nicer to directly reference the document:

See
<citerefentry>
  <refentrytitle>systemd.time</refentrytitle>
  <manvolnum>7</manvolnum>
</citerefentry>
for the format.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

a) Some providers can update multiple domains - support that.

b) Make "zone" and "script" configurable. Some providers require these.

c) Instead of leaving the ddclient daemon running all the time, use a systemd
timer to kick it off.

d) Don't use a predefined user - run everything via DynamicUser

e) Add documentation
@peterhoeg
Copy link
Member Author

Been running with this for a month or so.

@peterhoeg peterhoeg merged commit 740bafa into NixOS:master Apr 19, 2018
@peterhoeg peterhoeg deleted the f/ddclient branch April 19, 2018 05:12
@peterhoeg peterhoeg changed the title nixos ddclient: support multiple domains and run via systemd timer [WIP] nixos ddclient: support multiple domains and run via systemd timer Apr 19, 2018
@peterhoeg peterhoeg restored the f/ddclient branch April 19, 2018 06:44
@peterhoeg peterhoeg deleted the f/ddclient branch October 8, 2018 01:24
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.

None yet

5 participants