From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id oAQCO7jo9GNXZAAAbAwnHQ (envelope-from ) for ; Tue, 21 Feb 2023 16:52:25 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 0Nl1Orjo9GPhEQEA9RJhRA (envelope-from ) for ; Tue, 21 Feb 2023 16:52:24 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 267DF115D9 for ; Tue, 21 Feb 2023 16:52:23 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=disroot.org header.s=mail header.b=apGLhxOe; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=reject) header.from=disroot.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1676994744; a=rsa-sha256; cv=none; b=s/9iMe/7wIaOS8q39x3NqZU+FAY1yMrklaf3IuBsxDABmeqSi8+HOAC/ckXZB4FUytdvGn bb8WqJpTHdYC/9zg63lFZWjH/zMT0nQolghD0+ZHkZduW6qAXjmGueeM5TQlG/XDh28k49 CmCJFjBlXiWUhKLwp6JVTRIbvpTc8RxO0ySI3XIakmNT7VfrJpk4QmS+gzfCRiUNikJnfZ 5bLXsXokZhSVT6LItnT+zhnVaCwoIMa4lw0IJOZBWDIWD3lzKI5APYxaruiTHmNz4XcH22 Vjy5EvgwKYEoMXWdUQkj3b01Lhj1AnEvQKERbSD5k2ffdWwHWQYGFBGVygBQcA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=disroot.org header.s=mail header.b=apGLhxOe; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=reject) header.from=disroot.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1676994744; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=FudgVfXdBOCRoY0luv/UWarBzBJY/P6ZKLAUXjVI0qM=; b=eidI4eUJsT0ggPoUum7T8djcx4A5l2fTfRzI/ehDGknjBPLWT2w9pLZdqJqC7xo3q7Cow9 F+nBg4LcYof4jRjldJltxThywTGIOzwUNMSrjIKI7LdJZ8xY2RwUb2Yi9t3RZOXqcKiMi/ MDDaHCknaEMHTST0uLXp6PMhhNAxTxvd2oDJvanfP6MfVrr4tNeq8Ex0tK51W5MCAhjY+/ kzogxykThM9o/qo7TZXzkgJuVACadt9kfr8wonJkihbiF/AeDM5gXKxB/VD6MExJBYjPlh 0n/OkAV6Pb3NO6Ii1+w0yRMgr7VsEV7bfHw/+a5eh5a+RgLBeaUeh+MoiQtjsA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUUvZ-000288-SX; Tue, 21 Feb 2023 10:51:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUUuh-00019o-A9 for help-guix@gnu.org; Tue, 21 Feb 2023 10:50:47 -0500 Received: from knopi.disroot.org ([178.21.23.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUUue-0004P3-D8 for help-guix@gnu.org; Tue, 21 Feb 2023 10:50:42 -0500 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id B6D0044653; Tue, 21 Feb 2023 16:50:36 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zMbGpE60ue_J; Tue, 21 Feb 2023 16:50:35 +0100 (CET) References: <87k00pi15e.fsf@colimite.fr> <87r0uw4e78.fsf@remworks.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1676994635; bh=TLOfmT01qOy0rG1KrW5+i9ylOcrQfV/GGe4VYQkoIug=; h=References:Date:From:To:Cc:Subject:In-reply-to; b=apGLhxOeM0qW8nPihbUXrhhB9+YijAVvaKx7vgA95RUOoakkPXccIngbw45mSfaOX IxuolGNNnoxQFTe40Nkiiv+U19l5NmiP3GBcIueNKBYA58ADw/YJuWW23If7fe65CI qT3PRNJ7w6dlzJgrN5HRST71vkH3YhMHTOG7Mwecu2JDPRH9ppY0ogH9XLa/yV1Opx NQnXGU5MrYNaXNq42JCYPxGbd9GdKxv97HY7iBIfNYwigsgsfcKUbx5HGy5lj5s7YV +7sS7qq/l8Eafs/VvItEkfbruUGLr8SBoaY/fBaIIsHNzDUdCvize3ixPAccd/cdng IVR52RnZspjSw== Date: Tue, 21 Feb 2023 10:33:25 -0500 From: Gary Johnson To: Remco van 't Veer Cc: Sergiu Ivanov , help-guix@gnu.org Subject: Re: Examples of local-host-entries or hosts-service-type? In-reply-to: <87r0uw4e78.fsf@remworks.net> Message-ID: <874jrfrpa1.fsf@disroot.org> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=178.21.23.139; envelope-from=lambdatronic@disroot.org; helo=knopi.disroot.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: X-Migadu-Queue-Id: 267DF115D9 X-Spam-Score: -8.87 X-Migadu-Spam-Score: -8.87 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: help-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-TUID: qL3lnQDac9YQ 2023/02/10 23:40, Sergiu Ivanov: > I am reconfiguring my system right now, and guix system reconfigure > /etc/config.scm tells me this: > > /etc/config.scm:126:27: warning: 'local-host-aliases' is deprecated, use 'local-host-entries' instead > /etc/config.scm:126:27: warning: 'local-host-aliases' is deprecated, use 'local-host-entries' instead > /etc/config.scm:124:14: warning: the 'hosts-file' field is deprecated, please use 'hosts-service-type' instead > > For the record, here are the lines guix system reconfigure is > complaining about: > > (hosts-file (plain-file "hosts" > (string-append > (local-host-aliases host-name) > "some.ip.address.1 machine1\n" > "some.other.ip.address machine2\n"))) > > I spent quite some time trying to find some examples of using > local-host-entries or hosts-service-type, but I don't seem to find any > mention of these. Quite on the contrary, the Guix manual actually seems > to advice declarations similar to those which I have in my > /etc/config.scm. > > Could someone point me to an example of how I should update > my configuration? Hi Sergiu et al, I just went through this exercise myself, and I decided to keep my extra /etc/hosts entries in a separate text file using the original hosts format. This makes them much easier for me to read and edit. To provide them to the `hosts-service-type` service, I went ahead and wrote a little importer function in Scheme that I thought some other folks might benefit from. Here it is along with how to use it in your `operating-system` declaration: ```scheme (use-modules ((gnu services base) #:select (hosts-service-type host)) ((gnu services desktop) #:select (%desktop-services)) ((gnu services) #:select (simple-service)) ((gnu system) #:select (operating-system)) ((ice-9 ports) #:select (call-with-input-file)) ((ice-9 textual-ports) #:select (get-string-all))) (define (load-hosts-entries) (call-with-input-file "etcfiles/extra-hosts" (lambda (p) (let* ((text (get-string-all p)) (lines (string-split text #\newline)) (lines* (filter (lambda (l) (not (or (string-null? l) (string-prefix? "#" l)))) lines))) (map (lambda (l) (let* ((tokens (string-split l #\space)) (tokens* (filter (lambda (t) (not (string-null? t))) tokens)) (ip (car tokens*)) (alias (cadr tokens*))) (host ip alias))) lines*))))) (operating-system ... (services (cons* (simple-service 'add-extra-hosts hosts-service-type (load-hosts-entries)) ... %desktop-services))) ``` To make this work, I have my additional hosts entries in a file called "etcfiles/extra-hosts" relative to the location of my `system.scm` file (which contains the `operating-system` declaration above). That file looks like so: ``` # Section Comment 1 10.1.30.1 name1 # Maybe a comment for myself 10.1.30.2 name2 10.1.30.3 name3 10.1.30.4 name4 # Another comment # Section Comment 2 10.6.1.1 name5 10.6.1.2 name6 # And yet another comment 10.6.1.3 name7 10.6.1.4 name8 ``` This is, of course, the regular /etc/hosts format. I just leave out the 127.0.0.1 and ::1 entries for localhost since Guix adds those automatically. Also, please note that the Guix info pages are incorrect for `hosts-service-type` and `host`. The docs say they are exported by `(gnu services)`, but they are actually located in `(gnu services base)`. It would be great if one of the manual maintainers could fix this mistake as it was one of the trickiest things I had to figure out to make this code work. Thanks and happy hacking! Gary -- GPG Key ID: C4FBEDBD Use `gpg --search-keys tracker@disroot.org' to find me Protect yourself from surveillance: https://emailselfdefense.fsf.org ======================================================================= () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments Why is HTML email a security nightmare? See https://useplaintext.email/ Please avoid sending me MS-Office attachments. See http://www.gnu.org/philosophy/no-word-attachments.html