diff --git a/home/scripts/dns/dnsblock-norestart.sh b/home/scripts/dns/dnsblock-norestart.sh new file mode 100755 index 0000000..a74f0a0 --- /dev/null +++ b/home/scripts/dns/dnsblock-norestart.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail +OP=${1:-}; DOMAIN=${2:-} +[[ $OP =~ ^(on|off)$ && -n $DOMAIN ]] || { + echo "usage: dnsblock on|off "; exit 1; } + +FILE="/var/lib/dnsmasq/conf.d/block-$DOMAIN.conf" + +if [[ $OP == on ]]; then + sudo tee "$FILE" >/dev/null <"; exit 1; } + +FILE="/var/lib/dnsmasq/conf.d/block-$DOMAIN.conf" + +if [[ $OP == on ]]; then + sudo tee "$FILE" >/dev/null < "$tempHosts" + mv "$tempHosts" /etc/hosts +done diff --git a/system/networking/default.nix b/system/networking/default.nix index ad63f65..4d4cc93 100644 --- a/system/networking/default.nix +++ b/system/networking/default.nix @@ -12,12 +12,23 @@ "127.0.0.1" = ["localhost"]; }; - networkmanager.enable = true; + networkmanager = { + enable = true; + # dispatcherScripts = [ + # { + # source = ./blockers.sh; + # type = "basic"; + # } + # ]; + }; # interfaces = { # enp0s31f6 = {}; # wlp4s0 = {}; # }; + + # ensures wireless is wlan0, eth is eth0; + # predictable interfaces is kinda sussy innit? usePredictableInterfaceNames = false; }; } diff --git a/system/services/dnsmasq/default.nix b/system/services/dnsmasq/default.nix index 736f769..b5ed4a2 100644 --- a/system/services/dnsmasq/default.nix +++ b/system/services/dnsmasq/default.nix @@ -1,8 +1,13 @@ { config, pkgs, + lib, ... }: { + system.activationScripts.dnsmasqConfd = lib.stringAfter ["var"] '' + mkdir -p /var/lib/dnsmasq/conf.d + ''; + services.dnsmasq = { enable = true; resolveLocalQueries = true;