File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 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 [ ] ) ++
1819 ( if cfg . blockPorn then [ "porn" ] else [ ] ) ++
1920 ( if cfg . blockSocial then [ "social" ] else [ ] ) ;
20- alternatesPath = "alternates/" + builtins . concatStringsSep "-" alternatesList + "/" ;
21+ alternatesPath = "/alternates/" + builtins . concatStringsSep "-" alternatesList ;
22+ orig = builtins . readFile (
23+ self . outPath + ( if alternatesList != [ ] then alternatesPath else "" ) + "/hosts"
24+ ) ;
25+ filtered =
26+ if cfg . enableIPv6 then
27+ orig
28+ else
29+ lib . concatStringsSep "\n " (
30+ lib . filter ( line : ! ( lib . strings . hasPrefix "::" line ) ) ( lib . strings . splitString "\n " orig )
31+ ) ;
2132 in
2233 {
2334 options . networking . stevenBlackHosts = {
3243 blockSocial = mkEnableOption "social hosts entries" ;
3344 } ;
3445 config = mkIf cfg . enable {
35- networking . extraHosts =
36- let
37- orig = builtins . readFile ( "${ self } /" + ( if alternatesList != [ ] then alternatesPath else "" ) + "hosts" ) ;
38- ipv6 = builtins . replaceStrings [ "0.0.0.0" ] [ "::" ] orig ;
39- in orig + ( optionalString cfg . enableIPv6 ( "\n " + ipv6 ) ) ;
46+ networking . extraHosts = filtered ;
4047 } ;
4148 } ;
4249
You can’t perform that action at this time.
0 commit comments