Skip to content

Commit

Permalink
modules/nixos: init stevenblack
Browse files Browse the repository at this point in the history
  • Loading branch information
moni-dz committed Apr 22, 2022
1 parent 09f704a commit 2476a91
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions modules/nixos/networking/stevenblack.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ config, lib, pkgs, ... }:

with lib;

let
cfg = config.networking.stevenblack;

activatedHosts = with cfg.block; []
++ optionals fakeNews [ "fakenews" ]
++ optionals gambling [ "gambling" ]
++ optionals porn [ "porn" ]
++ optionals social [ "social" ];

hostsPath = "${pkgs.stevenblack-blocklist}/alternates/" + concatStringsSep "-" activatedHosts + "/hosts";
in
{
options.networking.stevenblack = {
enable = mkEnableOption "Enable the stevenblack hosts file blocklist.";

block = {
fakeNews = mkEnableOption "Block fake news websites.";
gambling = mkEnableOption "Block gambling websites.";
porn = mkEnableOption "Block porn websites.";
social = mkEnableOption "Block social media websites.";
};
};

config = mkIf cfg.enable {
networking.hostFiles = []
++ optionals (activatedHosts != []) [ hostsPath ]
++ optionals (activatedHosts == []) [ "${pkgs.stevenblack-blocklist}/hosts" ];
};
}

0 comments on commit 2476a91

Please sign in to comment.