[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/17: guix: register-path: use new %store-database-directory
From: |
Caleb Ristvedt |
Subject: |
05/17: guix: register-path: use new %store-database-directory |
Date: |
Tue, 29 Aug 2017 02:07:47 -0400 (EDT) |
reepca pushed a commit to branch guile-daemon
in repository guix.
commit f7beadf2ff8477f3f5b83930c266a64fc333b3d2
Author: Caleb Ristvedt <address@hidden>
Date: Mon Jun 5 22:34:59 2017 -0500
guix: register-path: use new %store-database-directory
* guix/config.scm.in (%store-database-directory): new variable.
* guix/store.scm (register-path): use variables from (guix config) instead
of
using environment variables directly.
---
guix/config.scm.in | 6 ++++++
guix/store.scm | 41 ++++++++++++++++++++++-------------------
2 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/guix/config.scm.in b/guix/config.scm.in
index 8f2c4ab..dfe5fe0 100644
--- a/guix/config.scm.in
+++ b/guix/config.scm.in
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <address@hidden>
+;;; Copyright © 2017 Caleb Ristvedt <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -29,6 +30,7 @@
%store-directory
%state-directory
+ %store-database-directory
%config-directory
%guix-register-program
@@ -80,6 +82,10 @@
(or (getenv "NIX_STATE_DIR")
(string-append %localstatedir "/guix")))
+(define %store-database-directory
+ (or (and=> (getenv "NIX_DB_DIR") canonicalize-path)
+ (string-append %state-directory "/db")))
+
(define %config-directory
;; This must match `GUIX_CONFIGURATION_DIRECTORY' as defined in
`nix/local.mk'.
(or (getenv "GUIX_CONFIGURATION_DIRECTORY")
diff --git a/guix/store.scm b/guix/store.scm
index 0aa32dc..b0e0fd2 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -1351,7 +1351,10 @@ makes a wrapper around a port which implements
GET-POSITION."
#:key (references '()) deriver prefix
state-directory)
;; Priority for options: first what is given, then environment variables,
- ;; then defaults.
+ ;; then defaults. %state-directory, %store-directory, and
+ ;; %store-database-directory already handle the "environment variables /
+ ;; defaults" question, so we only need to choose between what is given and
+ ;; those.
"Register PATH as a valid store file, with REFERENCES as its list of
references, and DERIVER as its deriver (.drv that led to it.) If PREFIX is
given, it must be the name of the directory containing the new store to
@@ -1365,28 +1368,28 @@ be used internally by the daemon's build hook."
(state-directory
(string-append state-directory "/db"))
(prefix
- (string-append prefix %state-directory "/db"))
- ((getenv "NIX_DB_DIR")
- (getenv "NIX_DB_DIR"))
- ((getenv "NIX_STATE_DIR")
- (string-append (getenv "NIX_STATE_DIR") "/db"))
+ ;; If prefix is specified, the value of NIX_STATE_DIR
+ ;; (which affects %state-directory) isn't supposed to
+ ;; affect db-dir, only the compile-time-customized
+ ;; default should.
+ (string-append prefix %localstatedir "/guix/db"))
(else
- (string-append %state-directory "/db"))))
+ %store-database-directory)))
(store-dir (if prefix
- (string-append prefix %store-directory)
- (or
- (getenv "NIX_STORE_DIR")
- (getenv "NIX_STORE")
- %store-directory)))
+ ;; same situation as above
+ (string-append prefix %storedir)
+ %store-directory))
(to-register (if prefix
- ;; note: we assume here that if path is, for example,
- ;; /foo/bar/gnu/store/thing.txt, then an environment
- ;; variable has been used to change the store
- ;; directory to /foo/bar/gnu/store.
- (string-append %store-directory "/" (basename path))
+ (string-append %storedir "/" (basename path))
+ ;; note: we assume here that if path is, for
+ ;; example, /foo/bar/gnu/store/thing.txt and prefix
+ ;; isn't given, then an environment variable has
+ ;; been used to change the store directory to
+ ;; /foo/bar/gnu/store, since otherwise real-path
+ ;; would end up being /gnu/store/thing.txt, which is
+ ;; probably not the right file in this case.
path))
- (real-path (string-append store-dir "/"
- (basename path))))
+ (real-path (string-append store-dir "/" (basename path))))
(let-values (((hash nar-size)
(nar-sha256 real-path)))
(sqlite-register
- 03/17: .dir-locals.el: properly indent sql macros., (continued)
- 03/17: .dir-locals.el: properly indent sql macros., Caleb Ristvedt, 2017/08/29
- 04/17: guix: sql.scm: split into generic and store-specific parts., Caleb Ristvedt, 2017/08/29
- 16/17: build-derivations: Leaked environment variables more robust., Caleb Ristvedt, 2017/08/29
- 12/17: linux-container: new use-output argument., Caleb Ristvedt, 2017/08/29
- 14/17: build-derivations: initial build-group support, Caleb Ristvedt, 2017/08/29
- 07/17: guix: register-path: do deduplication., Caleb Ristvedt, 2017/08/29
- 13/17: build-derivations: use call-with-container, Caleb Ristvedt, 2017/08/29
- 09/17: deduplication: new module., Caleb Ristvedt, 2017/08/29
- 06/17: guix: register-path: reset timestamps after registering., Caleb Ristvedt, 2017/08/29
- 10/17: guix: register-path: use new %store-database-directory, Caleb Ristvedt, 2017/08/29
- 05/17: guix: register-path: use new %store-database-directory,
Caleb Ristvedt <=
- 17/17: Merge remote-tracking branch 'origin/guile-daemon' into guile-daemon, Caleb Ristvedt, 2017/08/29
- 08/17: guix: register-path: return #t on success., Caleb Ristvedt, 2017/08/29
- 01/17: guix: register-path: Implement prototype in scheme., Caleb Ristvedt, 2017/08/29
- 15/17: linux-container: don't include /dev/ptmx or /dev/pts from host., Caleb Ristvedt, 2017/08/29
- 11/17: guix/store/build-derivations.scm: new module., Caleb Ristvedt, 2017/08/29