Merge pull request #321649 from Frontear/update-stevenblack-blocklist
stevenblack-blocklist: rev bump and improvements of module + package
This commit is contained in:
@@ -1,34 +1,49 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) optionals mkOption mkEnableOption types mkIf elem concatStringsSep maintainers;
|
||||
inherit (lib)
|
||||
getOutput
|
||||
maintainers
|
||||
mkEnableOption
|
||||
mkIf
|
||||
mkOption
|
||||
mkPackageOption
|
||||
types
|
||||
;
|
||||
|
||||
cfg = config.networking.stevenblack;
|
||||
|
||||
# needs to be in a specific order
|
||||
activatedHosts = with cfg; [ ]
|
||||
++ optionals (elem "fakenews" block) [ "fakenews" ]
|
||||
++ optionals (elem "gambling" block) [ "gambling" ]
|
||||
++ optionals (elem "porn" block) [ "porn" ]
|
||||
++ optionals (elem "social" block) [ "social" ];
|
||||
|
||||
hostsPath = "${pkgs.stevenblack-blocklist}/alternates/" + concatStringsSep "-" activatedHosts + "/hosts";
|
||||
in
|
||||
{
|
||||
options.networking.stevenblack = {
|
||||
enable = mkEnableOption "the stevenblack hosts file blocklist";
|
||||
|
||||
package = mkPackageOption pkgs "stevenblack-blocklist" { };
|
||||
|
||||
block = mkOption {
|
||||
type = types.listOf (types.enum [ "fakenews" "gambling" "porn" "social" ]);
|
||||
type = types.listOf (
|
||||
types.enum [
|
||||
"fakenews"
|
||||
"gambling"
|
||||
"porn"
|
||||
"social"
|
||||
]
|
||||
);
|
||||
default = [ ];
|
||||
description = "Additional blocklist extensions.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
networking.hostFiles = [ ]
|
||||
++ optionals (activatedHosts != [ ]) [ hostsPath ]
|
||||
++ optionals (activatedHosts == [ ]) [ "${pkgs.stevenblack-blocklist}/hosts" ];
|
||||
networking.hostFiles = map (x: "${getOutput x cfg.package}/hosts") ([ "ads" ] ++ cfg.block);
|
||||
};
|
||||
|
||||
meta.maintainers = [ maintainers.moni maintainers.artturin ];
|
||||
meta.maintainers = with maintainers; [
|
||||
moni
|
||||
artturin
|
||||
frontear
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
fetchFromGitHub,
|
||||
nix-update-script,
|
||||
}:
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
pname = "stevenblack-blocklist";
|
||||
version = "3.14.84";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "StevenBlack";
|
||||
repo = "hosts";
|
||||
rev = "refs/tags/${finalAttrs.version}";
|
||||
hash = "sha256-tahf6mdtmZofwMZfMsuDAqCR/V1qZt6vV+o6t4YTKG0=";
|
||||
};
|
||||
|
||||
outputs = [
|
||||
# default src fallback
|
||||
"out"
|
||||
|
||||
# base hosts file
|
||||
"ads"
|
||||
|
||||
# extensions only
|
||||
"fakenews"
|
||||
"gambling"
|
||||
"porn"
|
||||
"social"
|
||||
];
|
||||
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out $ads $fakenews $gambling $porn $social
|
||||
|
||||
# out
|
||||
find alternates -type f -not -name "hosts" -exec rm {} +
|
||||
cp -r alternates $out
|
||||
install -Dm644 hosts $out
|
||||
|
||||
# ads
|
||||
install -Dm644 hosts $ads
|
||||
|
||||
# extensions
|
||||
install -Dm644 alternates/fakenews-only/hosts $fakenews
|
||||
install -Dm644 alternates/gambling-only/hosts $gambling
|
||||
install -Dm644 alternates/porn-only/hosts $porn
|
||||
install -Dm644 alternates/social-only/hosts $social
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru.updateScript = nix-update-script { };
|
||||
|
||||
meta = with lib; {
|
||||
description = "Unified hosts file with base extensions";
|
||||
homepage = "https://github.com/StevenBlack/hosts";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [
|
||||
moni
|
||||
Guanran928
|
||||
frontear
|
||||
];
|
||||
};
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
{ lib, fetchFromGitHub }:
|
||||
|
||||
let
|
||||
version = "3.14.79";
|
||||
in
|
||||
fetchFromGitHub {
|
||||
name = "stevenblack-blocklist-${version}";
|
||||
|
||||
owner = "StevenBlack";
|
||||
repo = "hosts";
|
||||
rev = version;
|
||||
hash = "sha256-MfQGu+Y4/A0GKIu9d//U+yiP0fN/7cWhEo2dut4UvcE=";
|
||||
|
||||
meta = with lib; {
|
||||
description = "Unified hosts file with base extensions";
|
||||
homepage = "https://github.com/StevenBlack/hosts";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [
|
||||
moni
|
||||
Guanran928
|
||||
frontear
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -13163,8 +13163,6 @@ with pkgs;
|
||||
|
||||
staticjinja = with python3.pkgs; toPythonApplication staticjinja;
|
||||
|
||||
stevenblack-blocklist = callPackage ../tools/networking/stevenblack-blocklist { };
|
||||
|
||||
stress = callPackage ../tools/system/stress { };
|
||||
|
||||
stress-ng = callPackage ../tools/system/stress-ng { };
|
||||
|
||||
Reference in New Issue
Block a user