nix-git/modules/netcup-dns.nix

71 lines
1.8 KiB
Nix
Raw Normal View History

2023-11-14 19:04:58 +01:00
{ config, pkgs, ... }:
let
my-python-packages = ps: with ps; [
# netcup-dns is not (yet) packaged, thus we build it from PyPI
(
buildPythonPackage rec {
pname = "netcup-dns";
2023-12-08 22:49:05 +01:00
version = "0.2.2";
2023-11-14 19:04:58 +01:00
# https://nixos.wiki/wiki/Packaging/Python#Fix_Missing_setup.py
format = "pyproject";
src = fetchPypi {
inherit pname version;
2023-12-08 22:49:05 +01:00
sha256 = "sha256-/2dzrFkNrHDkVJd1witphlIXdHxJ573USzj6JwUscto=";
2023-11-14 19:04:58 +01:00
};
propagatedBuildInputs = [
# Dependencies
pkgs.python3Packages.requests
pkgs.python3Packages.nc-dnsapi
# Build dependencies
build
twine
];
}
)
];
in
{
# Install netcup-dns Python packages.
environment.systemPackages = [
(pkgs.python3.withPackages my-python-packages)
];
# Configure netcup-dns.
# Create file `/etc/netcup-dns/netcup-dns-95191.json`.
deployment.keys."netcup-dns-95191.json" = {
2023-11-14 19:21:10 +01:00
keyFile = ../secrets/netcup-dns.json;
2023-11-14 19:04:58 +01:00
destDir = "/etc/netcup-dns";
user = "netcup-dns";
group = "netcup-dns";
};
# Create netcup-dns daemon user.
users.users."netcup-dns" = {
isSystemUser = true;
group = "netcup-dns";
description = "netcup-dns daemon";
};
users.groups."netcup-dns" = {};
# Create netcup-dns timer.
systemd.timers."netcup-dns" = {
wantedBy = [ "timers.target" ];
partOf = [ "netcup-dns.service" ];
timerConfig = {
OnBootSec = "0m";
OnUnitInactiveSec = "3m";
AccuracySec = "15s";
RandomizedDelaySec = "15s";
};
};
systemd.services."netcup-dns" = {
serviceConfig = {
Type = "oneshot";
PrivateTmp = true;
User = "netcup-dns";
Nice = 19;
IOSchedulingClass = "idle";
ExecStart = "${pkgs.python3.withPackages my-python-packages}/bin/netcup-dns";
};
};
}