guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A postinst equivalent in Guix?


From: Ludovic Courtès
Subject: Re: A postinst equivalent in Guix?
Date: Sat, 21 Jan 2017 16:34:55 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Georgi Kirilov <address@hidden> skribis:

> On Fri, Jan 20, 2017 at 03:09:25PM +0100, Ludovic Courtès 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=/var to this package’s
>>configure state, since at run time it won’t be able to write to
>>/gnu/store/…/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 ‘avahi-localstatedir.patch’ or ‘mcron-install.patch’.
>
> 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/<package>/ 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
“activation” 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’t think there’s much we can do.  Again, these 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 postinst
>>> scripts in Debian?
>>
>>No.  There are “profile hooks” in (guix profiles) that are used to a
>>similar effect, for instance to assemble the ‘dir’ file that 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/<package>/ 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. ‘localstatedir’) is for mutable state, 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’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]