From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: bug#22962: Something keeps overwriting /etc/hosts Date: Thu, 10 Mar 2016 11:39:00 +0300 Message-ID: <87k2la682j.fsf@gmail.com> References: <20160309214232.027164e0@scratchpost.org> <20160310002811.0b59a57f@scratchpost.org> <20160310014323.GA29687@jasmine> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adw7f-0005Lu-5u for bug-guix@gnu.org; Thu, 10 Mar 2016 03:39:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adw7b-0003ki-39 for bug-guix@gnu.org; Thu, 10 Mar 2016 03:39:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:45102) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adw7b-0003kS-01 for bug-guix@gnu.org; Thu, 10 Mar 2016 03:39:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1adw7a-0006M6-SC for bug-guix@gnu.org; Thu, 10 Mar 2016 03:39:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <20160310014323.GA29687@jasmine> (Leo Famulari's message of "Wed, 9 Mar 2016 20:43:23 -0500") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Leo Famulari Cc: 22962@debbugs.gnu.org Leo Famulari (2016-03-10 04:43 +0300) wrote: > On Thu, Mar 10, 2016 at 12:28:11AM +0100, Danny Milosavljevic wrote: >> If I make it immutable, I get the following message on guix system reconfigure ... : >> >> guix system: error: copy-file: Permission denied: "/etc/hosts" >> >> Aha! > > I think that on GuixSD, the hosts file is generated from the system > configuration, specifically the 'hosts-file' field, which is mentioned > in section 7.2.2 Operating System Reference [0]. > > I assume that the resulting file is recreated each time you reconfigure. > > In that case, you'd want to leave the file /etc/hosts alone, and make > your changes in the operating system configuration. > > I say "I think" and "I assume" because I haven't actually used > 'hosts-file' yet, nor have I looked at that part of the code. You are absolutely right! On GuixSD, to modify /etc/hosts a user need to adjust his/her system config. Danny, you can keep your hosts file wherever you want, let's say "~/my-config/hosts"; and you can add this line to your operating-system declaration: (hosts-file (local-file (string-append (getenv "HOME") "/my-config/hosts"))) After reconfiguring your system, this file will be put into the store, and /etc/hosts will have the same contents after reboot. Moreover, every time you change this file and make a new system, a new version of "hosts" will be put to the store. So if you boot into some old system, it will be booted with the hosts file that was used at that time (as you can see, every system in /var/guix/profiles, has its own "etc/hosts"). -- Alex