···130130 </listitem>
131131 <listitem>
132132 <para>
133133+ The <literal>dnsmasq</literal> service now takes configuration
134134+ via the <literal>services.dnsmasq.settings</literal> attribute
135135+ set. The option
136136+ <literal>services.dnsmasq.extraConfig</literal> will be
137137+ deprecated when NixOS 22.11 reaches end of life.
138138+ </para>
139139+ </listitem>
140140+ <listitem>
141141+ <para>
133142 A new <literal>virtualisation.rosetta</literal> module was
134143 added to allow running <literal>x86_64</literal> binaries
135144 through
+5
nixos/doc/manual/release-notes/rl-2305.section.md
···43434444- `services.mastodon` gained a tootctl wrapped named `mastodon-tootctl` similar to `nextcloud-occ` which can be executed from any user and switches to the configured mastodon user with sudo and sources the environment variables.
45454646+- The `dnsmasq` service now takes configuration via the
4747+ `services.dnsmasq.settings` attribute set. The option
4848+ `services.dnsmasq.extraConfig` will be deprecated when NixOS 22.11 reaches
4949+ end of life.
5050+4651- A new `virtualisation.rosetta` module was added to allow running `x86_64` binaries through [Rosetta](https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment) inside virtualised NixOS guests on Apple silicon. This feature works by default with the [UTM](https://docs.getutm.app/) virtualisation [package](https://search.nixos.org/packages?channel=unstable&show=utm&from=0&size=1&sort=relevance&type=packages&query=utm).
47524853- Resilio sync secret keys can now be provided using a secrets file at runtime, preventing these secrets from ending up in the Nix store.
+69-17
nixos/modules/services/networking/dnsmasq.nix
···77 dnsmasq = pkgs.dnsmasq;
88 stateDir = "/var/lib/dnsmasq";
991010+ # True values are just put as `name` instead of `name=true`, and false values
1111+ # are turned to comments (false values are expected to be overrides e.g.
1212+ # mkForce)
1313+ formatKeyValue =
1414+ name: value:
1515+ if value == true
1616+ then name
1717+ else if value == false
1818+ then "# setting `${name}` explicitly set to false"
1919+ else generators.mkKeyValueDefault { } "=" name value;
2020+2121+ settingsFormat = pkgs.formats.keyValue {
2222+ mkKeyValue = formatKeyValue;
2323+ listsAsDuplicateKeys = true;
2424+ };
2525+2626+ # Because formats.generate is outputting a file, we use of conf-file. Once
2727+ # `extraConfig` is deprecated we can just use
2828+ # `dnsmasqConf = format.generate "dnsmasq.conf" cfg.settings`
1029 dnsmasqConf = pkgs.writeText "dnsmasq.conf" ''
1111- dhcp-leasefile=${stateDir}/dnsmasq.leases
1212- ${optionalString cfg.resolveLocalQueries ''
1313- conf-file=/etc/dnsmasq-conf.conf
1414- resolv-file=/etc/dnsmasq-resolv.conf
1515- ''}
1616- ${flip concatMapStrings cfg.servers (server: ''
1717- server=${server}
1818- '')}
3030+ conf-file=${settingsFormat.generate "dnsmasq.conf" cfg.settings}
1931 ${cfg.extraConfig}
2032 '';
21332234in
23352436{
3737+3838+ imports = [
3939+ (mkRenamedOptionModule [ "services" "dnsmasq" "servers" ] [ "services" "dnsmasq" "settings" "server" ])
4040+ ];
25412642 ###### interface
2743···4662 '';
4763 };
48644949- servers = mkOption {
5050- type = types.listOf types.str;
5151- default = [];
5252- example = [ "8.8.8.8" "8.8.4.4" ];
5353- description = lib.mdDoc ''
5454- The DNS servers which dnsmasq should query.
5555- '';
5656- };
5757-5865 alwaysKeepRunning = mkOption {
5966 type = types.bool;
6067 default = false;
···6370 '';
6471 };
65727373+ settings = mkOption {
7474+ type = types.submodule {
7575+7676+ freeformType = settingsFormat.type;
7777+7878+ options.server = mkOption {
7979+ type = types.listOf types.str;
8080+ default = [ ];
8181+ example = [ "8.8.8.8" "8.8.4.4" ];
8282+ description = lib.mdDoc ''
8383+ The DNS servers which dnsmasq should query.
8484+ '';
8585+ };
8686+8787+ };
8888+ default = { };
8989+ description = lib.mdDoc ''
9090+ Configuration of dnsmasq. Lists get added one value per line (empty
9191+ lists and false values don't get added, though false values get
9292+ turned to comments). Gets merged with
9393+9494+ {
9595+ dhcp-leasefile = "${stateDir}/dnsmasq.leases";
9696+ conf-file = optional cfg.resolveLocalQueries "/etc/dnsmasq-conf.conf";
9797+ resolv-file = optional cfg.resolveLocalQueries "/etc/dnsmasq-resolv.conf";
9898+ }
9999+ '';
100100+ example = literalExpression ''
101101+ {
102102+ domain-needed = true;
103103+ dhcp-range = [ "192.168.0.2,192.168.0.254" ];
104104+ }
105105+ '';
106106+ };
107107+66108 extraConfig = mkOption {
67109 type = types.lines;
68110 default = "";
69111 description = lib.mdDoc ''
70112 Extra configuration directives that should be added to
71113 `dnsmasq.conf`.
114114+115115+ This option is deprecated, please use {option}`settings` instead.
72116 '';
73117 };
74118···80124 ###### implementation
8112582126 config = mkIf cfg.enable {
127127+128128+ warnings = lib.optional (cfg.extraConfig != "") "Text based config is deprecated, dnsmasq now supports `services.dnsmasq.settings` for an attribute-set based config";
129129+130130+ services.dnsmasq.settings = {
131131+ dhcp-leasefile = mkDefault "${stateDir}/dnsmasq.leases";
132132+ conf-file = mkDefault (optional cfg.resolveLocalQueries "/etc/dnsmasq-conf.conf");
133133+ resolv-file = mkDefault (optional cfg.resolveLocalQueries "/etc/dnsmasq-resolv.conf");
134134+ };
8313584136 networking.nameservers =
85137 optional cfg.resolveLocalQueries "127.0.0.1";
···8282 # Since we don't have internet here, use dnsmasq to provide MX records from /etc/hosts
8383 services.dnsmasq = {
8484 enable = true;
8585- extraConfig = ''
8686- selfmx
8787- '';
8585+ settings.selfmx = true;
8886 };
89879088 networking.extraHosts = ''