unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Taylan Ulrich Kammer <taylanbayirli@gmail.com>
To: Alex Vorobiev <alexander.vorobiev@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: --with-store-dir and/or --localstatedir seem to be ignored
Date: Fri, 15 May 2015 11:03:25 +0200	[thread overview]
Message-ID: <87h9refc0y.fsf@gmail.com> (raw)
In-Reply-To: <loom.20150515T054841-459@post.gmane.org> (Alex Vorobiev's message of "Fri, 15 May 2015 04:07:39 +0000 (UTC)")

[-- Attachment #1: Type: text/plain, Size: 2382 bytes --]

Alex Vorobiev <alexander.vorobiev@gmail.com> writes:

> Hi,
> I have built guix-0.8.2 and specified both --with-store-dir and --
> localstatedir (both directories are world-writable) but when I started 
> guix-daemon (as myself) and tried to install a package I got:
>
> $ guix package -i mc
> guix package: error: build failed: creating directory `/gnu': Permission 
> denied
>
> Am I doing anything wrong? Why would it want to go to /gnu? I am using 
> RHEL-6.5.
>
> Thanks,
> Alex

The local state dir would be 'var' (e.g. /var, /usr/var, /usr/local/var,
depending on the value for $prefix), and I've used that option before
and believe it works fine.  (At the very least I've seen --prefix affect
its default value.)

So I believe your problem is about --with-store-dir only.

I've grepped a fresh guix clone for the raw string '/gnu/store' in .c,
.cc, .scm, and .sh files, and outside of comments and docstrings, found
the following:

guix/build/utils.scm:

  (define (%store-directory)
    "Return the directory name of the store."
    (or (getenv "NIX_STORE")
        "/gnu/store"))

guix/packages.scm (patch-and-repack):

  (let* ((store     (or (getenv "NIX_STORE") "/gnu/store"))

gnu/packages/busybox.scm (busybox):

  (substitute* "testsuite/cpio.tests"
     (("/usr/bin") "/gnu/store")
     (("usr") "gnu"))

(There are also some matches in the tests/ directory but I think they're
harmless.)

Those should probably use %store-directory from (guix config).  Here's a
patch doing that, but note that:

- In the busybox recipe, the "gnu" is replaced by (car (filter (negate
  string-null?) (string-split (%store-directory) #\/))) meaning it
  assumes (%store-directory) not to be the root directory.  (Note that
  this uses the %store-directory procedure from (guix build utils); see
  next point.)

- (guix build utils) has its own %store-directory bound to a procedure
  doing environment variable look-up on NIX_STORE instead of
  NIX_STORE_DIR (which determines the value of %store-directory from
  (guix config)); I preserved this semantics by importing
  %store-directory from (guix config) with a rename and falling back to
  it only if NIX_STORE is unset.

- Similarly, packages.scm checks NIX_STORE and not NIX_STORE_DIR, and I
  preserved this semantics by falling back to %store-directory only if
  NIX_STORE is unset.

Are these decisions right?

The patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Parameterize-references-to-gnu-store.patch --]
[-- Type: text/x-diff, Size: 3057 bytes --]

From 97b43ab87a35fce3b197edf75f8545cfac5860f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli@gmail.com>
Date: Fri, 15 May 2015 10:59:44 +0200
Subject: [PATCH] Parameterize references to /gnu/store.

* gnu/packages/busybox.scm (busybox): Call %store-directory from (guix build
  utils) instead of referencing "/gnu/store" directly.

* guix/build/utils.scm (%store-directory): Fall back to the value of
  %store-directory from (guix config) instead of "/gnu/store".

* guix/packages.scm (patch-and-repack): Likewise.
---
 gnu/packages/busybox.scm | 5 +++--
 guix/build/utils.scm     | 3 ++-
 guix/packages.scm        | 4 +++-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/busybox.scm b/gnu/packages/busybox.scm
index d200cd7..13630b3 100644
--- a/gnu/packages/busybox.scm
+++ b/gnu/packages/busybox.scm
@@ -53,8 +53,9 @@
 
            ;; There is no /usr/bin or /bin - replace it with /gnu/store
            (substitute* "testsuite/cpio.tests"
-              (("/usr/bin") "/gnu/store")
-              (("usr") "gnu"))
+              (("/usr/bin") (%store-directory))
+              (("usr") (car (filter (negate string-null?)
+                                    (string-split (%store-directory) #\/)))))
 
            (substitute* "testsuite/date/date-works-1"
              (("/bin/date") (which "date")))
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 676a012..903cea9 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -19,6 +19,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (guix build utils)
+  #:use-module ((guix config) #:prefix config)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-60)
@@ -80,7 +81,7 @@
 (define (%store-directory)
   "Return the directory name of the store."
   (or (getenv "NIX_STORE")
-      "/gnu/store"))
+      config:%store-directory))
 
 (define (store-file-name? file)
   "Return true if FILE is in the store."
diff --git a/guix/packages.scm b/guix/packages.scm
index c955b35..d312d05 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -18,6 +18,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (guix packages)
+  #:use-module ((guix config) #:prefix config)
   #:use-module (guix utils)
   #:use-module (guix records)
   #:use-module (guix store)
@@ -445,7 +446,8 @@ IMPORTED-MODULES specify modules to use/import for use by SNIPPET."
 
           ;; SOURCE may be either a directory or a tarball.
           (and (if (file-is-directory? #+source)
-                   (let* ((store     (or (getenv "NIX_STORE") "/gnu/store"))
+                   (let* ((store     (or (getenv "NIX_STORE")
+                                         config:%store-directory))
                           (len       (+ 1 (string-length store)))
                           (base      (string-drop #+source len))
                           (dash      (string-index base #\-))
-- 
2.2.1


[-- Attachment #3: Type: text/plain, Size: 8 bytes --]


Taylan

  reply	other threads:[~2015-05-15  9:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-15  4:07 --with-store-dir and/or --localstatedir seem to be ignored Alex Vorobiev
2015-05-15  9:03 ` Taylan Ulrich Kammer [this message]
2015-05-15 10:45   ` Ludovic Courtès
2015-05-15 14:03     ` Taylan Ulrich Kammer
2015-05-15 14:35       ` Ludovic Courtès
2015-05-15 14:58         ` Taylan Ulrich Kammer
2015-05-15 16:51           ` Ludovic Courtès
2015-05-15 20:22             ` ftp " Alex Vorobiev
2015-05-16 19:42               ` Ludovic Courtès
2015-05-21  2:42                 ` Alex Vorobiev
2015-05-21  8:20                   ` Ludovic Courtès
2015-05-19 22:17       ` Mark H Weaver
2015-05-20  7:27         ` Taylan Ulrich Bayırlı/Kammer
2015-05-20 16:53           ` Mark H Weaver
2015-05-15 10:40 ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h9refc0y.fsf@gmail.com \
    --to=taylanbayirli@gmail.com \
    --cc=alexander.vorobiev@gmail.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).