nix-git/hosts/yodaNas/host-specific.nix

106 lines
2.7 KiB
Nix
Raw Normal View History

{ 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";
version = "0.2.0";
# https://nixos.wiki/wiki/Packaging/Python#Fix_Missing_setup.py
format = "pyproject";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-tZKPe02tHrTelyw30BQsJhdZpmDsggZ0rr4ag0eHtng=";
};
propagatedBuildInputs = [
# Dependencies
pkgs.python3Packages.requests
pkgs.python3Packages.nc-dnsapi
# Build dependencies
build
twine
];
}
)
];
in
{
2023-11-14 18:54:13 +01:00
# Install netcup-dns Python packages.
environment.systemPackages = [
(pkgs.python3.withPackages my-python-packages)
];
2023-10-05 19:59:40 +02:00
# Configure netcup-dns.
# Create file `/etc/netcup-dns/netcup-dns-95191.json`.
deployment.keys."netcup-dns-95191.json" = {
keyFile = ../../secrets/netcup-dns.json;
destDir = "/etc/netcup-dns";
user = "netcup-dns";
group = "netcup-dns";
};
# Create netcup-dns daemon user.
2023-10-08 16:35:02 +02:00
users.users."netcup-dns" = {
isSystemUser = true;
group = "netcup-dns";
description = "netcup-dns daemon";
};
2023-10-08 16:35:02 +02:00
users.groups."netcup-dns" = {};
# Create netcup-dns timer.
systemd.timers."netcup-dns" = {
wantedBy = [ "timers.target" ];
2023-10-02 21:23:13 +02:00
partOf = [ "netcup-dns.service" ];
timerConfig = {
2023-10-02 16:13:17 +02:00
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";
};
};
# Update and start Jinja-Compose project
# during boot and after every 30 minutes.
# To view the log, run
# journalctl -b -u Jinja-Compose -f
#
systemd.timers."Jinja-Compose" = {
wantedBy = [ "timers.target" ];
partOf = [ "Jinja-Compose.service" ];
timerConfig = {
OnBootSec = "0m";
OnUnitInactiveSec = "30m";
AccuracySec = "1m";
RandomizedDelaySec = "1m";
};
};
systemd.services."Jinja-Compose" = {
description = "Update and start Jinja-Compose project";
serviceConfig = {
Type = "oneshot";
PrivateTmp = true;
User = "root";
};
path = with pkgs; [
# The `docker-compose` helper script is written in `bash` (!)
bash
docker
];
script = ''
2023-10-08 15:38:44 +02:00
set -eu -o pipefail
2023-10-09 19:02:16 +02:00
/jc-config/docker-compose pull
/jc-config/docker-compose up -d --wait
'';
};
}