nixpkgs/nixos/modules/services/networking/rdnssd.nix
stuebinm 6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00

82 lines
2.0 KiB
Nix

# Module for rdnssd, a daemon that configures DNS servers in
# /etc/resolv/conf from IPv6 RDNSS advertisements.
{ config, lib, pkgs, ... }:
with lib;
let
mergeHook = pkgs.writeScript "rdnssd-merge-hook" ''
#! ${pkgs.runtimeShell} -e
${pkgs.openresolv}/bin/resolvconf -u
'';
in
{
###### interface
options = {
services.rdnssd.enable = mkOption {
type = types.bool;
default = false;
#default = config.networking.enableIPv6;
description = ''
Whether to enable the RDNSS daemon
({command}`rdnssd`), which configures DNS servers in
{file}`/etc/resolv.conf` from RDNSS
advertisements sent by IPv6 routers.
'';
};
};
###### implementation
config = mkIf config.services.rdnssd.enable {
assertions = [{
assertion = config.networking.resolvconf.enable;
message = "rdnssd needs resolvconf to work (probably something sets up a static resolv.conf)";
}];
systemd.services.rdnssd = {
description = "RDNSS daemon";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
preStart = ''
# Create the proper run directory
mkdir -p /run/rdnssd
touch /run/rdnssd/resolv.conf
chown -R rdnssd /run/rdnssd
# Link the resolvconf interfaces to rdnssd
rm -f /run/resolvconf/interfaces/rdnssd
ln -s /run/rdnssd/resolv.conf /run/resolvconf/interfaces/rdnssd
${mergeHook}
'';
postStop = ''
rm -f /run/resolvconf/interfaces/rdnssd
${mergeHook}
'';
serviceConfig = {
ExecStart = "@${pkgs.ndisc6}/bin/rdnssd rdnssd -p /run/rdnssd/rdnssd.pid -r /run/rdnssd/resolv.conf -u rdnssd -H ${mergeHook}";
Type = "forking";
PIDFile = "/run/rdnssd/rdnssd.pid";
};
};
users.users.rdnssd = {
description = "RDNSSD Daemon User";
isSystemUser = true;
group = "rdnssd";
};
users.groups.rdnssd = {};
};
}