mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-19 16:09:19 +03:00

Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase
).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
87 lines
2 KiB
Nix
87 lines
2 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 = { };
|
|
|
|
};
|
|
|
|
}
|