efx
January 29, 2024, 11:42am
1
I’m curious how folks feel about packaging StevenBlack’s hosts project: GitHub - StevenBlack/hosts: 🔒 Consolidating and extending hosts files from several well-curated sources. Optionally pick extensions for porn, social media, and other categories. (DNSBL = DNS block list)
I am building a DNS Sinkhole using NixOS and will rely on that project for the blocking portion of my unbound configuration.
I’m lazy and love upstream packages :).
Do chime in with your thoughts, opinions, feelings on good idea, bad idea, something else.
A good fit for nixpkgs
Not a good fit; let users manage the configuration independently
It sounds to me like a mildly poor fit for nixpkgs’ update cadence, and could be prototyped readily as a flake or external channel input to work out the syntax/DX and provide a more prompt update flow.
2 Likes
Nixpkgs already contains this as a Package
{ lib, fetchFromGitHub }:
let
version = "3.13.10";
in
fetchFromGitHub {
name = "stevenblack-blocklist-${version}";
owner = "StevenBlack";
repo = "hosts";
rev = version;
sha256 = "sha256-LTo0NV1DpHI05AvfmTKNz+/NdXaNoLxgpMhV/HqeT6g=";
meta = with lib; {
description = "Unified hosts file with base extensions";
homepage = "https://github.com/StevenBlack/hosts";
license = licenses.mit;
maintainers = with maintainers; [ moni ];
};
}
and Nixos Module
{ config, lib, pkgs, ... }:
let
inherit (lib) optionals mkOption mkEnableOption types mkIf elem concatStringsSep maintainers mdDoc;
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 (mdDoc "the stevenblack hosts file blocklist");
block = mkOption {
This file has been truncated. show original
But even then, directly using the upstream flake.nix is probably better due to more frequent updates.
{
description = "Unified hosts file with base extensions.";
outputs = { self, nixpkgs, ... }@inputs:
let
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.platforms.unix;
nixpkgsFor = forAllSystems (system: import nixpkgs {
inherit system;
});
in
{
nixosModule = { config, ... }:
with nixpkgs.lib;
let
cfg = config.networking.stevenBlackHosts;
alternatesList = (if cfg.blockFakenews then [ "fakenews" ] else []) ++
(if cfg.blockGambling then [ "gambling" ] else []) ++
(if cfg.blockPorn then [ "porn" ] else []) ++
(if cfg.blockSocial then [ "social" ] else []);
alternatesPath = "alternates/" + builtins.concatStringsSep "-" alternatesList + "/";
This file has been truncated. show original
1 Like
efx
January 30, 2024, 11:49am
4
winter
January 30, 2024, 12:49pm
5
I don’t think Elasticsearch is smart enough to correct “stephen” to “steven” in the context of package names
1 Like