mirror of
https://github.com/StevenBlack/hosts.git
synced 2026-07-01 10:46:51 +00:00
Automtaically add ipv6 entries to nix flake
This commit is contained in:
12
flake.nix
12
flake.nix
@@ -21,7 +21,10 @@
|
||||
in
|
||||
{
|
||||
options.networking.stevenBlackHosts = {
|
||||
enable = mkEnableOption "Use Steven Black's hosts file as extra hosts.";
|
||||
enable = mkEnableOption "Steven Black's hosts file";
|
||||
enableIPv6 = mkEnableOption "IPv6 rules" // {
|
||||
default = config.networking.enableIPv6;
|
||||
};
|
||||
blockFakenews = mkEnableOption "Additionally block fakenews hosts.";
|
||||
blockGambling = mkEnableOption "Additionally block gambling hosts.";
|
||||
blockPorn = mkEnableOption "Additionally block porn hosts.";
|
||||
@@ -29,9 +32,10 @@
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
networking.extraHosts =
|
||||
builtins.readFile (
|
||||
"${self}/" + (if alternatesList != [] then alternatesPath else "") + "hosts"
|
||||
);
|
||||
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));
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user