mirror of
https://github.com/StevenBlack/hosts.git
synced 2026-10-02 14:25:44 +01:00
Merge pull request #2803 from Pandapip1/ipv6-flake
Automtaically add ipv6 entries to nix flake
This commit is contained in:
@@ -21,17 +21,21 @@
|
||||
in
|
||||
{
|
||||
options.networking.stevenBlackHosts = {
|
||||
enable = mkEnableOption "Use Steven Black's hosts file as extra hosts.";
|
||||
blockFakenews = mkEnableOption "Additionally block fakenews hosts.";
|
||||
blockGambling = mkEnableOption "Additionally block gambling hosts.";
|
||||
blockPorn = mkEnableOption "Additionally block porn hosts.";
|
||||
blockSocial = mkEnableOption "Additionally block social hosts.";
|
||||
enable = mkEnableOption "Steven Black's hosts file";
|
||||
enableIPv6 = mkEnableOption "IPv6 rules" // {
|
||||
default = config.networking.enableIPv6;
|
||||
};
|
||||
blockFakenews = mkEnableOption "fakenews hosts entries";
|
||||
blockGambling = mkEnableOption "gambling hosts entries";
|
||||
blockPorn = mkEnableOption "porn hosts entries";
|
||||
blockSocial = mkEnableOption "social hosts entries";
|
||||
};
|
||||
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));
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -405,6 +405,7 @@ The hosts extensions are also available with the following options:
|
||||
```nix
|
||||
{
|
||||
networking.stevenBlackHosts = {
|
||||
enableIPv6 = true;
|
||||
blockFakenews = true;
|
||||
blockGambling = true;
|
||||
blockPorn = true;
|
||||
@@ -413,6 +414,8 @@ The hosts extensions are also available with the following options:
|
||||
}
|
||||
```
|
||||
|
||||
IPv6 rules are enabled by default when `networking.enableIPv6` is set to `true`.
|
||||
|
||||
## Updating hosts file on Windows
|
||||
|
||||
(NOTE: See also some third-party Hosts managers, listed below.)
|
||||
|
||||
Reference in New Issue
Block a user