First, let me say, I am truly enjoying NixOS. Second, I am not trying to use the AdGuard Home Service, and only the DNS Service ( https://adguard-dns.io ). Generally, they tell you to edit dnsmasq.conf, and add the following:
no-resolv
bogus-priv
strict-order
server=94.140.14.49
server=94.140.14.59
port=My_Port
add-cpe-id=My_ID
But I presume that would not work in NixOS, since you’re not meant to edit system files. So what I have in my configuration.nix
services.dnsmasq.enable = true;
And I was thinking of adding:
services.dnsmasq.settings = {
no-resolv
bogus-priv
strict-order
server=94.140.14.49
server=94.140.14.59
port=MY_PORT_HERE
add-cpe-id=MY_ID_HERE
};
Will this work, or will the system ignore this?
I do not know how to proceed, because I decided to try and this was the outcome:
sudo nixos-rebuild switch --upgrade
[sudo] password for rimuru:
unpacking 1 channels…
error:
… while evaluating the attribute ‘config’
at /nix/store/4dz0r22swgqmsy0w450pv0dcdr4c73wq-nixos/nixos/lib/modules.nix:359:9:
358| options = checked options;
359| config = checked (removeAttrs config [ “_module” ]);
| ^
360| _module = checked (config._module);
… while calling the 'seq' builtin
at /nix/store/4dz0r22swgqmsy0w450pv0dcdr4c73wq-nixos/nixos/lib/modules.nix:359:18:
358| options = checked options;
359| config = checked (removeAttrs config [ "_module" ]);
| ^
360| _module = checked (config._module);
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: syntax error, unexpected ID, expecting '.' or '='
at /etc/nixos/configuration.nix:105:3:
104| no-resolv
105| bogus-priv
| ^
106| strict-order
building Nix…
error:
… while evaluating the attribute ‘config’
at /nix/store/4dz0r22swgqmsy0w450pv0dcdr4c73wq-nixos/nixos/lib/modules.nix:359:9:
358| options = checked options;
359| config = checked (removeAttrs config [ “_module” ]);
| ^
360| _module = checked (config._module);
… while calling the 'seq' builtin
at /nix/store/4dz0r22swgqmsy0w450pv0dcdr4c73wq-nixos/nixos/lib/modules.nix:359:18:
358| options = checked options;
359| config = checked (removeAttrs config [ "_module" ]);
| ^
360| _module = checked (config._module);
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: syntax error, unexpected ID, expecting '.' or '='
at /etc/nixos/configuration.nix:105:3:
104| no-resolv
105| bogus-priv
| ^
106| strict-order
building the system configuration…
error:
… while evaluating the attribute ‘config.system.build.toplevel’
at /nix/store/4dz0r22swgqmsy0w450pv0dcdr4c73wq-nixos/nixos/lib/modules.nix:359:9:
358| options = checked options;
359| config = checked (removeAttrs config [ “_module” ]);
| ^
360| _module = checked (config._module);
… while calling the 'seq' builtin
at /nix/store/4dz0r22swgqmsy0w450pv0dcdr4c73wq-nixos/nixos/lib/modules.nix:359:18:
358| options = checked options;
359| config = checked (removeAttrs config [ "_module" ]);
| ^
360| _module = checked (config._module);
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: syntax error, unexpected ID, expecting '.' or '='
at /etc/nixos/configuration.nix:105:3:
104| no-resolv
105| bogus-priv
| ^
106| strict-order
You need to write it in Nix syntax. See the example for services.dnsmaq.settings
. E.g no-resolv
→ no-resolv = true;
. I would suggest using an editor with a Nix LSP like nil
or nixd
to deal with syntax errors before rebuilding your system.
That page is where I got my idea, and we see where that lead. I do not know how to proceed.
SOLUTION:
services.dnsmasq.enable = true;
services.dnsmasq.settings = {
no-resolv = true;
bogus-priv = true;
strict-order = true;
server = [“94.140.14.49” “94.140.14.59” ];
add-cpe-id = “My_ID”;
};
You just cannot include the port, or it will not resolve. To be more clear, ping resolved, but my web browser in Flatpak did not. Drop the port and the above works nicely (as I am posted from there now).
2 Likes