Compare commits
4 commits
e8f7331b6c
...
539af51473
| Author | SHA1 | Date | |
|---|---|---|---|
| 539af51473 | |||
| f21777b1fb | |||
| 290c0692bb | |||
| d19d535d85 |
7 changed files with 109 additions and 27 deletions
|
|
@ -3,4 +3,12 @@
|
|||
|
||||
echo "restoring stashed changes"
|
||||
|
||||
git stash pop -q
|
||||
# Find the most recent pre-commit stash and restore it
|
||||
recent_stash=$(git stash list | grep "pre-commit-stash-" | head -n 1 | cut -d: -f1)
|
||||
|
||||
if [ -n "$recent_stash" ]; then
|
||||
echo "Found recent pre-commit stash: $recent_stash"
|
||||
git stash pop -q "$recent_stash"
|
||||
else
|
||||
echo "No pre-commit stash found to restore"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -4,14 +4,28 @@
|
|||
# Get current branch name
|
||||
current_branch=$(git branch --show-current)
|
||||
|
||||
# Only restore stash if we're on main branch and a merge just completed
|
||||
# Only perform actions if we're on main branch and a merge just completed
|
||||
if [ "$current_branch" = "main" ]; then
|
||||
# Check if there are any stashes to restore
|
||||
if git stash list | grep -q "stash@"; then
|
||||
echo "Post-merge: restoring stashed changes on main branch"
|
||||
git stash pop -q
|
||||
echo "Post-merge on main branch - running nix flake check"
|
||||
|
||||
# Run nix flake check after merge into main
|
||||
nix flake check
|
||||
|
||||
if [ ! $? -eq 0 ]; then
|
||||
echo "Warning: nix flake check failed after merge into main"
|
||||
echo "Please fix the issues as soon as possible"
|
||||
else
|
||||
echo "Post-merge: no stash to restore on main branch"
|
||||
echo "nix flake check passed after merge"
|
||||
fi
|
||||
|
||||
# Check if there are any pre-commit stashes to restore
|
||||
recent_stash=$(git stash list | grep "pre-commit-stash-" | head -n 1 | cut -d: -f1)
|
||||
|
||||
if [ -n "$recent_stash" ]; then
|
||||
echo "Post-merge: restoring pre-commit stash on main branch"
|
||||
git stash pop -q "$recent_stash"
|
||||
else
|
||||
echo "Post-merge: no pre-commit stash to restore on main branch"
|
||||
fi
|
||||
else
|
||||
echo "Post-merge: no action needed on branch '$current_branch'"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,24 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash ../shell.nix
|
||||
|
||||
echo "stashing all uncommitted changes"
|
||||
git stash -q --keep-index
|
||||
# Get current branch name
|
||||
current_branch=$(git branch --show-current)
|
||||
|
||||
echo "checking flakes all compile"
|
||||
nix flake check
|
||||
echo "stashing all uncommitted changes with named stash (excluding hooks)"
|
||||
git stash push -q --keep-index -m "pre-commit-stash-$(date +%s)" -- ':!.hooks/'
|
||||
|
||||
if [ ! $? -eq 0 ]; then
|
||||
exit 1
|
||||
# Only run nix flake check if we're on main branch
|
||||
if [ "$current_branch" = "main" ]; then
|
||||
echo "On main branch - checking flakes all compile"
|
||||
nix flake check
|
||||
|
||||
if [ ! $? -eq 0 ]; then
|
||||
echo "Error: nix flake check failed on main branch"
|
||||
exit 1
|
||||
fi
|
||||
echo "nix flake check passed"
|
||||
else
|
||||
echo "Not on main branch - skipping nix flake check"
|
||||
fi
|
||||
|
||||
echo "running linter"
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ fi
|
|||
if [ "$target_branch" = "main" ]; then
|
||||
echo "Merging into main branch - running nix flake check..."
|
||||
|
||||
echo "stashing all uncommitted changes"
|
||||
git stash -q --keep-index
|
||||
echo "stashing all uncommitted changes with named stash (excluding hooks)"
|
||||
git stash push -q --keep-index -m "pre-merge-stash-$(date +%s)" -- ':!.hooks/'
|
||||
|
||||
echo "checking flakes all compile"
|
||||
nix flake check
|
||||
|
|
|
|||
|
|
@ -343,17 +343,18 @@
|
|||
};
|
||||
|
||||
crab-hole = {
|
||||
enable = true;
|
||||
enable = false;
|
||||
port = 8085;
|
||||
openFirewall = true;
|
||||
show_doc = true;
|
||||
downstreams = {
|
||||
loopback = {
|
||||
host = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
};
|
||||
upstreams.cloudFlare.enable = true;
|
||||
blocklists.ad_malware.enable = true;
|
||||
};
|
||||
|
||||
qbittorrent = {
|
||||
|
|
|
|||
|
|
@ -27,9 +27,19 @@ in {
|
|||
show_doc = lib.mkEnableOption "OpenAPI documentation (loads content from third party websites)";
|
||||
|
||||
downstreams = {
|
||||
loopback = {
|
||||
enable = lib.mkEnableOption "loopback downstream DNS server on localhost:53";
|
||||
openFirewall = lib.mkEnableOption "automatic port forwarding for the loopback downstream";
|
||||
host = {
|
||||
enable = lib.mkEnableOption "host downstream DNS server accessible from network on all interfaces";
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 53;
|
||||
description = "Port for the host downstream DNS server to listen on.";
|
||||
};
|
||||
openFirewall = lib.mkEnableOption "automatic port forwarding for the host downstream";
|
||||
disableSystemdResolved = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to automatically disable systemd-resolved when using port 53. Set to false if you want to handle the conflict manually.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -79,9 +89,44 @@ in {
|
|||
default = [];
|
||||
description = "List of additional upstream DNS server configurations.";
|
||||
};
|
||||
|
||||
blocklists = {
|
||||
ad_malware = {
|
||||
enable = lib.mkEnableOption "Host file for blocking ads and malware";
|
||||
url = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "http://sbc.io/hosts/hosts";
|
||||
description = "URL of the ad and malware blocklist host file";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
extraBlocklists = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [];
|
||||
description = "Additional blocklist URLs to be added to the configuration";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Assertions for proper configuration
|
||||
assertions = [
|
||||
{
|
||||
assertion = !(cfg.downstreams.host.enable && cfg.downstreams.host.port == 53 && config.services.resolved.enable && cfg.downstreams.host.disableSystemdResolved);
|
||||
message = "crab-hole host downstream cannot use port 53 while systemd-resolved is enabled. Either disable systemd-resolved or use a different port.";
|
||||
}
|
||||
{
|
||||
assertion = !(cfg.downstreams.host.enable && cfg.downstreams.host.port == 53 && !cfg.downstreams.host.disableSystemdResolved && config.services.resolved.enable);
|
||||
message = "crab-hole host downstream is configured to use port 53 but systemd-resolved is still enabled and disableSystemdResolved is false. Set disableSystemdResolved = true or manually disable systemd-resolved.";
|
||||
}
|
||||
];
|
||||
|
||||
# Automatically disable systemd-resolved if using port 53
|
||||
services.resolved.enable = lib.mkIf (cfg.downstreams.host.enable && cfg.downstreams.host.port == 53 && cfg.downstreams.host.disableSystemdResolved) (lib.mkForce false);
|
||||
|
||||
# Configure DNS nameservers when disabling systemd-resolved
|
||||
networking.nameservers = lib.mkIf (cfg.downstreams.host.enable && cfg.downstreams.host.port == 53 && cfg.downstreams.host.disableSystemdResolved) (lib.mkDefault ["127.0.0.1" "1.1.1.1" "8.8.8.8"]);
|
||||
|
||||
services.crab-hole.settings = lib.mkMerge [
|
||||
{
|
||||
api = {
|
||||
|
|
@ -91,13 +136,17 @@ in {
|
|||
};
|
||||
downstream = cfg.extraDownstreams;
|
||||
upstream.name_servers = cfg.extraUpstreams;
|
||||
blocklist.lists = cfg.extraBlocklists;
|
||||
}
|
||||
(lib.mkIf cfg.downstreams.loopback.enable {
|
||||
(lib.mkIf cfg.blocklists.ad_malware.enable {
|
||||
blocklist.lists = [cfg.blocklists.ad_malware.url];
|
||||
})
|
||||
(lib.mkIf cfg.downstreams.host.enable {
|
||||
downstream = [
|
||||
{
|
||||
protocol = "udp";
|
||||
listen = "localhost";
|
||||
port = 53;
|
||||
listen = "0.0.0.0";
|
||||
port = cfg.downstreams.host.port;
|
||||
}
|
||||
];
|
||||
})
|
||||
|
|
@ -136,8 +185,8 @@ in {
|
|||
(lib.mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [cfg.port];
|
||||
})
|
||||
(lib.mkIf (cfg.downstreams.loopback.enable && cfg.downstreams.loopback.openFirewall) {
|
||||
allowedUDPPorts = [53];
|
||||
(lib.mkIf (cfg.downstreams.host.enable && cfg.downstreams.host.openFirewall) {
|
||||
allowedUDPPorts = [cfg.downstreams.host.port];
|
||||
})
|
||||
];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
}: let
|
||||
workingDirectory = "/var/lib/private/crab-hole";
|
||||
in {
|
||||
config = lib.mkIf (config.services.immich.enable && config.host.impermanence.enable) {
|
||||
config = lib.mkIf (config.services.crab-hole.enable && config.host.impermanence.enable) {
|
||||
assertions = [
|
||||
{
|
||||
assertion =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue