Skip to content

Commit c770cb7

Browse files
committed
nix flake: use lib.mkAfter put the host list at the end
At present, if a user uses ``networking.stevenBlockHosts.enable = true`` in tandem with ``networking.extraHosts``, the ``extraHosts`` will put be put after which makes it very difficult to see the custom adds with even the ``$PAGER`` operating a bit slow due to file size. I would propose putting this project’s hosts at the end of the hosts file. 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 # # … Format: text/x-rst
1 parent 181b549 commit c770cb7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

flake.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
nixosModule = { config, ... }:
1313
with nixpkgs.lib;
1414
let
15+
inherit (nixpkgs) lib;
1516
cfg = config.networking.stevenBlackHosts;
1617
alternatesList = (if cfg.blockFakenews then [ "fakenews" ] else []) ++
1718
(if cfg.blockGambling then [ "gambling" ] else []) ++
@@ -35,7 +36,8 @@
3536
let
3637
orig = builtins.readFile ("${self}/" + (if alternatesList != [] then alternatesPath else "") + "hosts");
3738
ipv6 = builtins.replaceStrings [ "0.0.0.0" ] [ "::" ] orig;
38-
in orig + (optionalString cfg.enableIPv6 ("\n" + ipv6));
39+
in
40+
lib.mkAfter (orig + (lib.optionalString cfg.enableIPv6 ("\n" + ipv6)));
3941
};
4042
};
4143

0 commit comments

Comments
 (0)