From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Creating user profiles Date: Sun, 13 Jan 2013 23:05:37 +0100 Message-ID: <87libwrb66.fsf@gnu.org> References: <201301131423.36130.andreas@enge.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:44765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuVgY-0005W1-A4 for bug-guix@gnu.org; Sun, 13 Jan 2013 17:05:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TuVgS-00052H-CJ for bug-guix@gnu.org; Sun, 13 Jan 2013 17:05:46 -0500 Received: from mail4-relais-sop.national.inria.fr ([192.134.164.105]:64155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuVgS-000524-0R for bug-guix@gnu.org; Sun, 13 Jan 2013 17:05:40 -0500 In-Reply-To: <201301131423.36130.andreas@enge.fr> (Andreas Enge's message of "Sun, 13 Jan 2013 14:23:36 +0100") 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: Andreas Enge Cc: bug-guix@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello! Andreas Enge skribis: > I think the problem is that only the directory /usr/local/guix- > git/var/nix/profiles exists, but that it is empty; maybe one should first= =20 > create the directory $PREFIX/var/nix/profiles/per-user/$USER if it does n= ot=20 > exist yet? Right, good point. (Apparently Nix=E2=80=99s manual doesn=E2=80=99t mentio= n it either.) So here=E2=80=99s what I would do: --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable --- a/doc/guix.texi +++ b/doc/guix.texi @@ -233,6 +233,16 @@ The @code{guix-daemon} program may then be run as @cod= e{root} with: # guix-daemon --build-users-group=3Dguix-builder @end example =20 +In such a multi-user setup, @dfn{user profiles}---i.e., the set of +user-installed packages as seen by @command{guix-package} +(@pxref{Invoking guix-package})---must be stored in a place registered +as a @dfn{garbage-collector root}. That directory is normally +@code{@var{localstatedir}/profiles/per-user/@var{user}}, where +@var{localstatedir} is the value passed to @code{configure} as +@code{--localstatedir}, and @var{user} is the user name. This directory +must be created by @code{root}, with @var{user} as the owner. When it +does not exist, @command{guix-package} emits an error about it. + Guix may also be used in a single-user setup, with @command{guix-daemon} running as a unprivileged user. However, to maximize non-interference of build processes, the daemon still needs to perform certain operations diff --git a/guix-package.in b/guix-package.in index 450d09e..ec09cc4 100644 --- a/guix-package.in +++ b/guix-package.in @@ -36,6 +36,7 @@ exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \ #:use-module (guix packages) #:use-module (guix utils) #:use-module (guix config) + #:use-module ((guix build utils) #:select (directory-exists?)) #:use-module (ice-9 ftw) #:use-module (ice-9 format) #:use-module (ice-9 match) @@ -465,6 +466,25 @@ Install, remove, or upgrade PACKAGES in a single trans= action.\n")) (not (file-exists? %user-environment-directory))) (symlink %current-profile %user-environment-directory)) =20 + ;; Attempt to create /=E2=80=A6/profiles/per-user/$USER if needed. + (unless (or (not (equal? (assoc-ref opts 'profile) %current-profile)) + (directory-exists? %profile-directory)) + (catch 'system-error + (lambda () + (mkdir %profile-directory)) + (lambda args + ;; Often, we cannot create %PROFILE-DIRECTORY because its + ;; parent directory is root-owned and we're running + ;; unprivileged. + (format (current-error-port) + (_ "error: while creating directory `~a': ~a~%") + %profile-directory + (strerror (system-error-errno args))) + (format (current-error-port) + (_ "Please create the `~a' directory, with you as the ow= ner.~%") + %profile-directory) + (exit 1)))) + (with-error-handling (or (process-query opts) (parameterize ((%guile-for-build --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable WDYT? Thanks, Ludo=E2=80=99. --=-=-=--