From b6c057e70a477413635b0a8168787a9a09069bf0 Mon Sep 17 00:00:00 2001 From: Jake Ginesin Date: Sat, 28 Jun 2025 04:48:04 -0400 Subject: [PATCH] 455 current 2025-06-28 04:47:33 25.05.20250424.f771eb4 6.12.24 * --- home/scripts/dns/dnsblock-norestart.sh | 16 ++++++++++++++++ home/scripts/dns/dnsblock.sh | 19 +++++++++++++++++++ system/networking/blockers.sh | 8 ++++++++ system/networking/default.nix | 13 ++++++++++++- system/services/dnsmasq/default.nix | 5 +++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 home/scripts/dns/dnsblock-norestart.sh create mode 100755 home/scripts/dns/dnsblock.sh create mode 100644 system/networking/blockers.sh 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;