summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--config-daemon.ac2
-rw-r--r--doc/guix.texi14
-rw-r--r--m4/guix.m446
4 files changed, 63 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
index 8a5430794a9..a9c281d4d19 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -421,7 +421,11 @@ include daemon.am
421endif BUILD_DAEMON 421endif BUILD_DAEMON
422 422
423ACLOCAL_AMFLAGS = -I m4 423ACLOCAL_AMFLAGS = -I m4
424
425# Pass an explicit '--localstatedir' so that configure does not error out if
426# it finds an existing installation with a different localstatedir.
424AM_DISTCHECK_CONFIGURE_FLAGS = \ 427AM_DISTCHECK_CONFIGURE_FLAGS = \
428 --localstatedir="$$dc_install_base/var" \
425 --with-libgcrypt-prefix="$(LIBGCRYPT_PREFIX)" \ 429 --with-libgcrypt-prefix="$(LIBGCRYPT_PREFIX)" \
426 --with-libgcrypt-libdir="$(LIBGCRYPT_LIBDIR)" \ 430 --with-libgcrypt-libdir="$(LIBGCRYPT_LIBDIR)" \
427 --with-nix-prefix="$(NIX_PREFIX)" \ 431 --with-nix-prefix="$(NIX_PREFIX)" \
diff --git a/config-daemon.ac b/config-daemon.ac
index 63174d62c79..803eb536996 100644
--- a/config-daemon.ac
+++ b/config-daemon.ac
@@ -140,6 +140,8 @@ if test "x$guix_build_daemon" = "xyes"; then
140 GUIX_TEST_ROOT="$ac_cv_guix_test_root" 140 GUIX_TEST_ROOT="$ac_cv_guix_test_root"
141 AC_SUBST([GUIX_TEST_ROOT]) 141 AC_SUBST([GUIX_TEST_ROOT])
142 142
143 GUIX_CHECK_LOCALSTATEDIR
144
143 AC_CONFIG_FILES([nix/scripts/list-runtime-roots], 145 AC_CONFIG_FILES([nix/scripts/list-runtime-roots],
144 [chmod +x nix/scripts/list-runtime-roots]) 146 [chmod +x nix/scripts/list-runtime-roots])
145 AC_CONFIG_FILES([nix/scripts/substitute], 147 AC_CONFIG_FILES([nix/scripts/substitute],
diff --git a/doc/guix.texi b/doc/guix.texi
index b36be056869..868948adfce 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -527,6 +527,14 @@ following packages are also needed:
527C++11 standard. 527C++11 standard.
528@end itemize 528@end itemize
529 529
530When configuring Guix on a system that already has a Guix installation,
531be sure to specify the same state directory as the existing installation
532using the @code{--localstatedir} option of the @command{configure}
533script (@pxref{Directory Variables, @code{localstatedir},, standards,
534GNU Coding Standards}). The @command{configure} script protects against
535unintended misconfiguration of @var{localstatedir} so you do not
536inadvertently corrupt your store (@pxref{The Store}).
537
530When a working installation of @url{http://nixos.org/nix/, the Nix package 538When a working installation of @url{http://nixos.org/nix/, the Nix package
531manager} is available, you 539manager} is available, you
532can instead configure Guix with @code{--disable-daemon}. In that case, 540can instead configure Guix with @code{--disable-daemon}. In that case,
@@ -2945,9 +2953,9 @@ Sub-directories in the store are referred to as @dfn{store items} or
2945sometimes @dfn{store paths}. The store has an associated database that 2953sometimes @dfn{store paths}. The store has an associated database that
2946contains information such as the store paths referred to by each store 2954contains information such as the store paths referred to by each store
2947path, and the list of @emph{valid} store items---results of successful 2955path, and the list of @emph{valid} store items---results of successful
2948builds. This database resides in @file{/var/guix/db} (or under whatever 2956builds. This database resides in @file{@var{localstatedir}/guix/db},
2949state directory was specified @i{via} @option{--localstatedir} at 2957where @var{localstatedir} is the state directory specified @i{via}
2950configure time). 2958@option{--localstatedir} at configure time, usually @file{/var}.
2951 2959
2952The store is @emph{always} accessed by the daemon on behalf of its clients 2960The store is @emph{always} accessed by the daemon on behalf of its clients
2953(@pxref{Invoking guix-daemon}). To manipulate the store, clients 2961(@pxref{Invoking guix-daemon}). To manipulate the store, clients
diff --git a/m4/guix.m4 b/m4/guix.m4
index acfc33e170c..2d3dfd282ec 100644
--- a/m4/guix.m4
+++ b/m4/guix.m4
@@ -307,3 +307,49 @@ AC_DEFUN([GUIX_LIBGCRYPT_LIBDIR], [
307 fi]) 307 fi])
308 $1="$guix_cv_libgcrypt_libdir" 308 $1="$guix_cv_libgcrypt_libdir"
309]) 309])
310
311dnl GUIX_CURRENT_LOCALSTATEDIR
312dnl
313dnl Determine the localstatedir of an existing Guix installation and set
314dnl 'guix_cv_current_localstatedir' accordingly. Set it to "none" if no
315dnl existing installation was found.
316AC_DEFUN([GUIX_CURRENT_LOCALSTATEDIR], [
317 AC_PATH_PROG([GUILE], [guile])
318 AC_CACHE_CHECK([the current installation's localstatedir],
319 [guix_cv_current_localstatedir],
320 [dnl Call 'dirname' because (guix config) appends "/guix" to LOCALSTATEDIR.
321 guix_cv_current_localstatedir="`"$GUILE" \
322 -c '(use-modules (guix config))
323 (when (string=? %store-directory "'$storedir'")
324 (display (dirname %state-directory)))' \
325 2>/dev/null`"
326 if test "x$guix_cv_current_localstatedir" = "x"; then
327 guix_cv_current_localstatedir=none
328 fi])])
329
330dnl GUIX_CHECK_LOCALSTATEDIR
331dnl
332dnl Check that the LOCALSTATEDIR value is consistent with that of the existing
333dnl Guix installation, if any. Error out or warn if they do not match.
334AC_DEFUN([GUIX_CHECK_LOCALSTATEDIR], [
335 AC_REQUIRE([GUIX_CURRENT_LOCALSTATEDIR])
336 if test "x$guix_cv_current_localstatedir" != "xnone"; then
337 if test "$guix_cv_current_localstatedir" != "$guix_localstatedir"; then
338 case "$localstatedir" in
339 NONE|\${prefix}*)
340 # User kept the default value---i.e., did not pass '--localstatedir'.
341 AC_MSG_ERROR([chosen localstatedir '$guix_localstatedir' does not match \
342that of the existing installation '$guix_cv_current_localstatedir'
343Installing may corrupt $storedir!
344Use './configure --localstatedir=$guix_cv_current_localstatedir'.])
345 ;;
346 *)
347 # User passed an explicit '--localstatedir'. Assume they know what
348 # they're doing.
349 AC_MSG_WARN([chosen localstatedir '$guix_localstatedir' does not match \
350that of the existing installation '$guix_cv_current_localstatedir'])
351 AC_MSG_WARN([installing may corrupt $storedir!])
352 ;;
353 esac
354 fi
355 fi])