Commit Graph

49 Commits

Author SHA1 Message Date
Grimmauld
61e5a270ca nixos/resolved: filter null values from config
There is valid scenarios to NOT have certain keys in /etc/resolved.conf, e.g. WSL mDNS.
This was reported in https://github.com/NixOS/nixpkgs/pull/535649#issuecomment-5103574775.
Empty configs can still be achieved passing an empty list (`[]`) or empty string (`""`),
while passing `null` will now remove the key from the config file.
2026-07-28 21:30:17 +02:00
Martin Weinelt
4e2415b3c2 nixos/systemd-resolved: apply transformation to resolve section
In a previous change the transformSettings function was modified to look
at the Resolve section, but since it got a second consumer in the mean
time this regressed. We now target the resolved.conf explicitly instead.
2026-07-24 23:22:47 +02:00
Martin Weinelt
9f42db501a Revert "nixos/resolved: apply transformations to keys within resolved section"
This reverts commit 66353ca989.

In the meantime a new option was added that consumes the
`transformSettings` function, which broke by looking at just at the
Resolve section.
2026-07-24 23:01:22 +02:00
Martin Weinelt
9351f979e0 nixos/resolved: apply transformations to keys within resolved section (#535649) 2026-07-23 01:00:19 +00:00
Martin Weinelt
66353ca989 nixos/resolved: apply transformations to keys within resolved section
Because all options are below the [Resolve] section, and we nest them as
such below `settings.Resolve` we need to apply the transformations one
level down for it to match the relevant keys.
2026-06-26 15:06:21 +02:00
Raito Bezarius
13684b8470 nixos/systemd/resolved: add Varlink APIs
This adds:

- /run/systemd/resolve/io.systemd.Resolve (resolution)
- /run/systemd/resolve/io.systemd.Resolve.Monitor (monitoring)

Change-Id: I43f22be5c42757f3dad1e4a9d209b0a91f404a55
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-25 09:50:38 +02:00
Lucas Savva
b403014e4f nixos/resolvconf: Enable by default
Fixes #353225

The value of `networking.resolvconf.enable` was previously
predicated on the existence `environment.etc."resolv.conf"`.
This could lead to infinite recursion when an attribute defined
within the resolvconf module was also required to define
`environment.etc` (see example below).

Instead, set the default to an explicit true and set the value to
false where required in-tree. This turns out to only be two places:
systemd-resolved and tetrd.

Example infrec (from building .#nixosTests.containers-hosts):

```
       … while evaluating definitions from `/nix/store/5djjm1dipmdh82issrmpfjdplp7hk0pp-source/nixos/modules/services/logging/logrotate.nix':

       … while evaluating the option `containers.netmask.services.logrotate.enable':

       … while evaluating the option `containers.netmask.users.groups':

       … while evaluating definitions from `/nix/store/5djjm1dipmdh82issrmpfjdplp7hk0pp-source/nixos/modules/config/resolvconf.nix':

       … while evaluating the option `containers.netmask.networking.resolvconf.enable':

       … while evaluating the option `containers.netmask.environment.etc':

       … while evaluating definitions from `/nix/store/5djjm1dipmdh82issrmpfjdplp7hk0pp-source/nixos/modules/services/logging/logrotate.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: infinite recursion encountered
       at /nix/store/5djjm1dipmdh82issrmpfjdplp7hk0pp-source/lib/modules.nix:1512:13:
         1511|     _type = "if";
         1512|     inherit condition content;
             |             ^
         1513|   };
```
2026-04-27 21:53:27 +01:00
r-vdp
cfc8eb2d3c nixos/systemd-resolved: add support to generate dns-delegate files
See https://www.freedesktop.org/software/systemd/man/258/systemd.dns-delegate.html
2026-03-03 17:41:54 +01:00
Ramses
980461af44 nixos/resolvconf: use config.systemd.package instead of pkgs.systemd (#480663) 2026-01-19 09:03:30 +00:00
Martin Weinelt
d86e8d4da5 nixos/resolved: fix regressions after interface change
With the options being only set when `services.resolved.enable` was
enabled, they were only available if the host resolver was resolved. That
broke the resolved config used when initrd networking is enabled.

A good indicator that something is wrong is if the config section of
a module configures the options itself. That means non introspectable
settings are being put in place.

Additionally DNS= and Domains= need to be space-separated lists. The
manpage does not indicate that they can be set multiple times.

I decided not to port the LLMNR enablement over, since it never gained
widespread traction and is generally being phased out in favor of mDNS.

Fixes: #480964
2026-01-18 02:46:09 +01:00
r-vdp
75bba21f04 nixos/resolvconf: use config.systemd.package instead of pkgs.systemd 2026-01-16 11:48:06 +01:00
Darragh Elliott
ab385083dc nixos/resolved: move to systemd tooling, rename options 2026-01-11 00:18:01 +01:00
Janne Heß
dd9cc36cd0 nixos/resolved: Fix nix-daemon-firewall with resolved 2025-11-29 21:31:00 +01:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Andreas Fuchs
ad55e1a1ef Make systemd-resolved's config file a reload trigger
It is documented to re-read its configuration file upon reload, so
we can simply reload it instead of restarting the whole daemon.
2025-01-08 13:38:04 -05:00
Andreas Fuchs
0c5719fe0e Don't stop systemd-{networkd,resolved,udevd} on config switch
These daemons should not be stopped, as they're foundational to a
proper functioning of the system. When switching configurations, they
only need a restart instead of that stop/start cycle.
2025-01-08 13:05:27 -05:00
Silvan Mosberger
4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
r-vdp
d558554243 initrd: use the new tmpfiles options to create tmpfiles config
Otherwise we get a clash when generating the initrd since the initrd tmpfiles
options create a symlink at /etc/tmpfiles.d/ and any subsequent writes inside
this directory because of initrd.systemd.contents will cause a permission denied
error.
2024-09-04 14:39:03 +02:00
Will Fancher
072054ccb5 nixos/systemd-stage-1: Support systemd-resolved 2024-05-21 20:55:37 -04:00
Will Fancher
154459858f nixos/systemd-resolved: Should be wanted by sysinit.target
As per its [Install] section upstream
2024-05-21 02:41:22 -04:00
Will Fancher
146bffe5aa nixos/systemd-resolved: Re-indent 2024-05-21 02:41:22 -04:00
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
Jacob Moody
dfc87b9048 nixos/resolved: add dnsovertls option 2024-01-19 21:29:22 -06:00
benaryorg
57846d0cae nixos/resolved: Allow upstream fallback override
The previous code did not apply any changes to the upstream defaults on being presented with an empty list.
This changes the code to use the above behaviour on a `null` value while an empty list is passed through as normal which yields a systemd configuration line with empty value which resets it to an empty value.

Signed-off-by: benaryorg <binary@benary.org>
2023-12-15 13:07:05 +00:00
Raito Bezarius
4f461f7b77 nixos/modules/system/resolved: disable DNSSEC validation by default
Historically, we allowed downgrade of DNSSEC, but some folks argue
this may decrease actually the security posture to do opportunistic DNSSEC.

In addition, the current implementation of (opportunistic) DNSSEC validation
is broken against "in the wild" servers which are usually slightly non-compliant.

systemd upstream recommended to me (in personal communication surrounding
the All Systems Go 2023 conference) to disable DNSSEC validation until
they work on it in a significant capacity, ideally, by next year.
2023-09-13 11:49:16 +02:00
Robert Hensing
bcd2d49d85 nixos: Make services.resolved discoverable via "systemd-resolved" search
This query yielded no results on search.nixos.org.
I don't think I can make all options magically appear, but you can
the other options by reading the text.
2023-04-07 01:09:05 +02:00
pennae
7388711363 nixos/resolved: convert option docs to MD 2022-07-19 16:23:57 +02:00
Naïm Favier
203696f098 nixos/resolvconf: add package
Expose the package that provides the system-wide `resolvconf` command
(either openresolv or systemd) to allow implementation-agnostic modules.
2022-06-21 22:58:43 +02:00
pennae
2512455639 nixos/*: add trivial defaultText for options with simple defaults 2021-12-02 22:35:04 +01:00
Florian Klink
c1536f5c78 nixos/systemd: fix NSS database ordering
- The order of NSS (host) modules has been brought in line with upstream
  recommendations:

  - The `myhostname` module is placed before the `resolve` (optional) and `dns`
    entries, but after `file` (to allow overriding via `/etc/hosts` /
    `networking.extraHosts`, and prevent ISPs with catchall-DNS resolvers from
    hijacking `.localhost` domains)
  - The `mymachines` module, which provides hostname resolution for local
    containers (registered with `systemd-machined`) is placed to the front, to
    make sure its mappings are preferred over other resolvers.
  - If systemd-networkd is enabled, the `resolve` module is placed before
    `files` and `myhostname`, as it provides the same logic internally, with
    caching.
  - The `mdns(_minimal)` module has been updated to the new priorities.

  If you use your own NSS host modules, make sure to update your priorities
  according to these rules:

  - NSS modules which should be queried before `resolved` DNS resolution should
    use mkBefore.
  - NSS modules which should be queried after `resolved`, `files` and
    `myhostname`, but before `dns` should use the default priority
  - NSS modules which should come after `dns` should use mkAfter.
2021-07-17 23:55:35 +02:00
Konrad Borowski
66b2aaf2eb Revert "nixos/systemd: provide libidn2 for systemd-resolved"
This patch is no longer necessary with systemd v247.3.

This reverts commit c674a51382.
2021-04-12 18:37:18 +02:00
Florian Klink
c674a51382 nixos/systemd: provide libidn2 for systemd-resolved
systemd started using dlopen() for some of their "optional"
dependencies.

Apparently, `libidn2` isn't so optional, and systemd-resolved doesn't
work without libidn2 present, breaking DNS resolution.

Fixes https://github.com/NixOS/nixpkgs/issues/107537

Upstream bug: https://github.com/systemd/systemd/issues/18078
2020-12-25 13:45:25 +01:00
Peter Hoeg
13ed0cce2f nixos/systemd-resolved: fix incorrect user 2020-11-05 22:41:39 +08:00
Arian van Putten
0e18e5db99 nixos/resolved: Include dbus alias of resolved unit
This will make dbus socket activation for it work

When `systemd-resolved` is restarted; this would lead to unavailability
of DNS lookups.  You're supposed to use DBUS socket activation to buffer
resolved requests; such that restarts happen without downtime
2020-06-13 12:23:45 +02:00
Florian Klink
8325e0db11 Revert "nixos/resolved: Include dbus alias of resolved unit"
This reverts commit 7fe539f799.
2020-05-09 20:05:01 +02:00
Arian van Putten
7fe539f799 nixos/resolved: Include dbus alias of resolved unit
This will make dbus socket activation for it work

When `systemd-resolved` is restarted; this would lead to unavailability
of DNS lookups.  You're supposed to use DBUS socket activation to buffer
resolved requests; such that restarts happen without downtime
2020-05-08 14:21:25 +02:00
Florian Klink
7426bec45e nixos/systemd/resolved: add resolve to nss hosts database if enabled
We keep the "only add the nss module if nscd is enabled" logic for now.

The assertion never was triggered, so it can be removed.
2020-05-05 15:59:30 +02:00
WilliButz
2ffb2c0bd1 nixos/resolved: add user systemd-resolve to group systemd-resolve 2019-11-25 10:46:28 +01:00
Nikolay Amiantov
01b90dce78 resolvconf service: init
This is a refactor of how resolvconf is managed on NixOS. We split it
into a separate service which is enabled internally depending on whether
we want /etc/resolv.conf to be managed by it. Various services now take
advantage of those configuration options.

We also now use systemd instead of activation scripts to update
resolv.conf.

NetworkManager now uses the right option for rc-manager DNS
automatically, so the configuration option shouldn't be exposed.
2019-07-15 20:25:39 +03:00
Eelco Dolstra
de9e238469 FIx some malformed XML in option descriptions
E.g. these were using "<para>" at the *end* of a description. The real
WTF is that this is possible at all...
2019-05-13 09:15:17 +02:00
volth
2e979e8ceb [bot] nixos/*: remove unused arguments in lambdas 2018-07-20 20:56:59 +00:00
Benjamin Staffin
dca7e24a11 networkmanager: Expand dns description, integrate with other services (#41898)
Rather than special-casing the dns options in networkmanager.nix, use
the module system to let unbound and systemd-resolved contribute to
the newtorkmanager config.
2018-06-29 13:41:46 -04:00
Franz Pletz
eb862c48dd systemd: 234 -> 237
Co-Authored-By: Florian Klink <flokli@flokli.de>
Co-Authored-By: Andreas Rammhold <andreas@rammhold.de>
2018-02-13 01:24:24 +01:00
Robert Helgesson
c4088dd0af nixos/resolved: clean up option descriptions
Also change LLMNR RFC to the correct id 4795.
2017-10-17 10:11:19 +02:00
Robin Gloster
a38f1911d3 systemd: 231 -> 232
Includes adding some more upstream units and removing obsolete (-.slice) ones.
2017-01-26 17:52:52 +01:00
Alexander Ried
a31e07fc11 modules.resolved: Enhance by upstream options (#15897) 2016-06-26 22:58:04 +02:00
Eelco Dolstra
6bd4e0b8cd Create systemd-{network,resolve} user/group unconditionally
This shuts up this error from dbus:

May 11 13:52:16 machine dbus-daemon[259]: Unknown username "systemd-network" in message bus configuration file
May 11 13:52:16 machine dbus-daemon[259]: Unknown username "systemd-resolve" in message bus configuration file

which happens because the D-Bus config for networkd/resolved is
enabled unconditionally, and we don't have an easy way to turn it off.

(cherry picked from commit f19b58fb6a)
2015-07-22 12:23:45 +02:00
Eelco Dolstra
c87977e97d Don't include networkd units unless enabled
Otherwise, the enabled -> disabled transition won't be handled
correctly (switch-to-configuration currently assumes that if a unit is
running and exists, it should be restarted).
2015-04-19 22:06:45 +02:00
Eelco Dolstra
f8dbe5f376 systemd: Move networkd into separate modules
The systemd module was getting rather bloated.
2015-04-19 22:06:45 +02:00