From b0e18601db2daa3c026baa349e5255d4269b5185 Mon Sep 17 00:00:00 2001 From: Bruno Victal Date: Fri, 27 Jan 2023 21:06:13 +0000 Subject: services: Add block-facebook-hosts-service-type. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deprecates %facebook-host-aliases in favour of using hosts-service-type service extensions. * gnu/services/networking.scm (block-facebook-hosts-service-type): New variable. (%facebook-host-aliases): Deprecate variable. * doc/guix.texi: Document it. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index d1cb6eebf7..96b396b58c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -20998,42 +20998,14 @@ Logging level. @end table @end deftp -@defvar %facebook-host-aliases -This variable contains a string for use in @file{/etc/hosts} -(@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each -line contains a entry that maps a known server name of the Facebook +@defvar block-facebook-hosts-service-type +This service type adds a list of known Facebook hosts to the +@file{/etc/hosts} file. +(@pxref{Host Names,,, libc, The GNU C Library Reference Manual}) +Each line contains a entry that maps a known server name of the Facebook on-line service---e.g., @code{www.facebook.com}---to the local host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}. -This variable is typically used as a @code{hosts-service-type} -service extension (@pxref{Service Reference, @code{hosts-service-type}}): - -@lisp -(use-modules (gnu) (gnu services) (guix) (srfi srfi-1) (ice-9 match)) -(use-service-modules networking) - -(operating-system - ;; @dots{} - - (service - (simple-service 'block-facebook-hosts hosts-service-type - (let ((host-pairs - (filter-map - (lambda (x) - (and (not (or (string-null? x) - (string-prefix? "#" x))) - (remove string-null? - (string-split - x - char-set:whitespace)))) - (string-split %facebook-host-aliases #\newline)))) - (map (match-lambda - ((addr name) - (host addr name))) - host-pairs))) - ;; @dots{} -@end lisp - This mechanism can prevent programs running locally, such as Web browsers, from accessing Facebook. @end defvar -- cgit v1.2.3