From 86f7b971bb7e432ed238f1be40620870f7ee775e Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Mon, 17 Jun 2024 19:54:21 +0700 Subject: [PATCH] pihole: added to nameserver --- system/podman/pihole.nix | 10 ++++++---- system/services/stubby.nix | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/system/podman/pihole.nix b/system/podman/pihole.nix index f5972d0..4c03dec 100644 --- a/system/podman/pihole.nix +++ b/system/podman/pihole.nix @@ -23,19 +23,21 @@ in sopsFile = ../../secrets/pihole.yaml; }; + networking.nameservers = [ piholeDNSIPBind ]; - systemd.services.create-kavita-network = { + + systemd.services."create-${name}-network" = { serviceConfig = { Type = "oneshot"; RemainAfterExit = true; }; - wantedBy = [ "podman-pihole.service" ]; + wantedBy = [ "podman-${name}.service" ]; script = ''${pkgs.podman}/bin/podman network exists ${name} || ${pkgs.podman}/bin/podman network create --gateway=${gateway} --subnet=${subnet} --ip-range=${ip-range} ${name}''; }; environment.etc."pihole/custom.list" = { # Copy file instead of symlink - mode = "0400"; + mode = "0444"; # Creates a pihole custom.list file with the following pattern: # @@ -53,7 +55,7 @@ in )} ''; }; - virtualisation.oci-containers.containers.pihole = { + virtualisation.oci-containers.containers.${name} = { inherit image; environment = { TZ = "Asia/Jakarta"; diff --git a/system/services/stubby.nix b/system/services/stubby.nix index 1875070..c8a99d5 100644 --- a/system/services/stubby.nix +++ b/system/services/stubby.nix @@ -1,12 +1,12 @@ { config, lib, pkgs, ... }: let cfg = config.profile.services.stubby; - inherit (lib) mkIf; + inherit (lib) mkIf lists; in { config = mkIf cfg.enable { networking.resolvconf.useLocalResolver = false; - networking.nameservers = [ "192.168.100.5" ]; + networking.nameservers = lists.optional (!config.profile.podman.pihole.enable) "192.168.100.5"; services.stubby = { enable = true; settings = pkgs.stubby.passthru.settingsExample // {