2025-11-21 11:38:18 +01:00
{
config ,
lib ,
pkgs ,
inputs ,
host ,
. . .
} :
let
ipv6 = false ; # We don't have IPv6 yet sadly
blocklist_base = builtins . readFile inputs . oisd ;
extraBlocklist = '' '' ;
blocklist_txt = pkgs . writeText " b l o c k l i s t . t x t " ''
$ { extraBlocklist }
$ { blocklist_base }
'' ;
in
{
services . dnscrypt-proxy = {
enable = true ;
# See https://github.com/DNSCrypt/dnscrypt-proxy/blob/master/dnscrypt-proxy/example-dnscrypt-proxy.toml
settings = {
sources . public-resolvers = {
urls = [
" h t t p s : / / r a w . g i t h u b u s e r c o n t e n t . c o m / D N S C r y p t / d n s c r y p t - r e s o l v e r s / m a s t e r / v 3 / p u b l i c - r e s o l v e r s . m d "
" h t t p s : / / d o w n l o a d . d n s c r y p t . i n f o / r e s o l v e r s - l i s t / v 3 / p u b l i c - r e s o l v e r s . m d "
] ;
2025-12-01 14:32:36 +01:00
minisign_key = " s h a 2 5 6 - c M 9 A Y k f 1 O R y D m w N 4 o E 4 C N G 8 s e p d z Q i 3 X T 9 6 8 S D s O t C Y = " ; # See https://github.com/DNSCrypt/dnscrypt-resolvers/blob/master/v3/public-resolvers.md
2025-11-21 11:38:18 +01:00
cache_file = " / v a r / l i b / d n s c r y p t / p u b l i c - r e s o l v e r s . m d " ;
} ;
# Use servers reachable over IPv6 -- Do not enable if you don't have IPv6 connectivity
ipv6_servers = ipv6 ;
block_ipv6 = ! ( ipv6 ) ;
require_dnssec = true ;
require_nolog = true ;
require_nofilter = true ;
# If you want, choose a specific set of servers that come from your sources.
# Here it's from https://github.com/DNSCrypt/dnscrypt-resolvers/blob/master/v3/public-resolvers.md
# If you don't specify any, dnscrypt-proxy will automatically rank servers
# that match your criteria and choose the best one.
# server_names = [ ... ];
blocked_names . blocked_names_file = blocklist_txt ;
} ;
} ;
systemd . services . dnscrypt-proxy . serviceConfig . StateDirectory = " d n s c r y p t - p r o x y " ;
networking . networkmanager . dns = " n o n e " ; # set system DNS to not get random records from DHCP
programs . captive-browser = {
enable = true ; # enable dedicated Chromium instance to deal with captive portals without messing with system DNS settings
interface = if ( host = = " s a k u r a " ) then " w l p 1 s 0 " else " n u l l " ; # TODO: add hostnames for more devices
} ;
}