From dd0520516328eb0a0af886a7ddcd127e059f890b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=B9=82=E0=B8=97=E0=B8=AA=E0=B8=BA=E0=B8=95=E0=B8=B1?= =?UTF-8?q?=E0=B8=A5?= Date: Fri, 24 Jan 2025 00:37:35 +0700 Subject: [PATCH] nix flake: use ``lib.mkAfter`` to allow extraHosts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At present, if a user uses ``networking.stevenBlockHosts.enable = true`` in tandem with ``networking.extraHosts``, the ``extraHosts`` will override this Flake which is an unexpected behavior. By using ``lib.mkAfter``, a user can now prepend extra hosts. Meaning: .. code:: nix { networking = { stevenBlockHosts.enable = true; extraHosts = '' 127.0.0.1 myproject.localhost ''; }; } will now output .. code:: 127.0.0.1 localhost ::1 localhost 127.0.0.1 myproject.localhost # Title: StevenBlack/hosts with the fakenews extension # # … instead of removing StevenBlack/hosts. Format: text/x-rst --- flake.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ac991cf5d45..2698fdd6e3b 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,7 @@ nixosModule = { config, ... }: with nixpkgs.lib; let + inherit (nixpkgs) lib; cfg = config.networking.stevenBlackHosts; alternatesList = (if cfg.blockFakenews then [ "fakenews" ] else []) ++ (if cfg.blockGambling then [ "gambling" ] else []) ++ @@ -35,7 +36,8 @@ let orig = builtins.readFile ("${self}/" + (if alternatesList != [] then alternatesPath else "") + "hosts"); ipv6 = builtins.replaceStrings [ "0.0.0.0" ] [ "::" ] orig; - in orig + (optionalString cfg.enableIPv6 ("\n" + ipv6)); + in + lib.mkAfter (orig + (lib.optionalString cfg.enableIPv6 ("\n" + ipv6))); }; };