From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: A postinst equivalent in Guix? Date: Sat, 21 Jan 2017 16:34:55 +0100 Message-ID: <87wpdojujk.fsf@gnu.org> References: <87efzxakmi.fsf@gnu.org> <20170121143923.vdmmljvc3ngksuze@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUxh0-0000Iq-4x for guix-devel@gnu.org; Sat, 21 Jan 2017 10:35:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cUxgw-0003ba-Vp for guix-devel@gnu.org; Sat, 21 Jan 2017 10:35:02 -0500 In-Reply-To: <20170121143923.vdmmljvc3ngksuze@gmail.com> (Georgi Kirilov's message of "Sat, 21 Jan 2017 16:39:23 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Georgi Kirilov Cc: guix-devel@gnu.org Georgi Kirilov skribis: > On Fri, Jan 20, 2017 at 03:09:25PM +0100, Ludovic Court=C3=A8s wrote: >> >>> A program in a package I created is trying to access /var, but has no >>> permissions. (Well, /gnu/store/.../var) >> >>First, you probably need to pass --localstatedir=3D/var to this package= =E2=80=99s >>configure state, since at run time it won=E2=80=99t be able to write to >>/gnu/store/=E2=80=A6/var anyway. >> >>Second, it will try and fail to create /var. The way to address that is >>by simply commenting out or patching out the offending commands. See >>for instance =E2=80=98avahi-localstatedir.patch=E2=80=99 or =E2=80=98mcro= n-install.patch=E2=80=99. > > That's what happened indeed. When I removed the writes to /var the > build passed. But the programs in the package couldn't write to the > system /var directory, since they expect /var/lib// to exist > and be writable. Right, but this is typically for daemons and programs that expect to be installed system-wide. In that case, the trick is to define a GuixSD service providing an =E2=80=9Cactivation=E2=80=9D snippet that makes sur /var/lib/PACKAGE exists= and has the right permissions beforehand. For Avahi, this happens here: http://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/avahi.scm#n93 > Besides, writing to /var on a foreign distro may interfere with the > same package installed natively there (if it is installed). Yeah, but I don=E2=80=99t think there=E2=80=99s much we can do. Again, the= se are typically daemons, and for any given daemon there can usually only be one instance running. >>> is there anything in Guix that can do things at install time, like post= inst >>> scripts in Debian? >> >>No. There are =E2=80=9Cprofile hooks=E2=80=9D in (guix profiles) that ar= e used to a >>similar effect, for instance to assemble the =E2=80=98dir=E2=80=99 file t= hat contains >>pointers to Info documentation. > > This looks to me much better than the system-wide /var. It is not only > user-specific, but generation-specific. Really nice mechanism. > I tried to write a new hook, to scan the installed packages and if > they have a /var/lib// inside, to create a writable copy in > the user's profile, so the programs can write to it without > interfering with anything on the system. > > It didn't work because the hook's output turned out to be immutable... > Whatever chmod or chown I tried inside the hook, the files always > ended up '-r--r--r-- root root' > > Why are these customizations immutable? All of /gnu/store is purposefully immutable and profiles live in /gnu/store. This is what allows Guix to support reproducible setups, transactional upgrades, and roll-backs. By definition /var (aka. =E2=80=98localstatedir=E2=80=99) is for mutable st= ate, so it has to be outside of the store. To make things more concrete, we could discuss specific packages you are interested in and see how we could provide them in Guix{,SD}. HTH! Ludo=E2=80=99.