build: Fix typo that would lead to hitting the socket name length limit.
[jackhill/guix/guix.git] / tests / guix-daemon.sh
CommitLineData
233e7676 1# GNU Guix --- Functional package management for GNU
c9e2b0b1 2# Copyright © 2012, 2014 Ludovic Courtès <ludo@gnu.org>
d23077dc 3#
233e7676 4# This file is part of GNU Guix.
d23077dc 5#
233e7676 6# GNU Guix is free software; you can redistribute it and/or modify it
d23077dc
LC
7# under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or (at
9# your option) any later version.
10#
233e7676 11# GNU Guix is distributed in the hope that it will be useful, but
d23077dc
LC
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
233e7676 17# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
d23077dc
LC
18
19#
c9e2b0b1 20# Test the daemon and its interaction with 'guix substitute-binary'.
d23077dc
LC
21#
22
23set -e
24
d23077dc 25guix-daemon --version
e49951eb 26guix build --version
d23077dc 27
c9e2b0b1
LC
28drv="`guix build emacs -d`"
29out="`guile -c ' \
30 (use-modules (guix) (gnu packages emacs)) \
31 (define store (open-connection)) \
32 (display (derivation->output-path (package-derivation store emacs)))'`"
33
34hash_part="`basename $out | cut -c 1-32`"
35narinfo="$hash_part.narinfo"
36substitute_dir="`echo $GUIX_BINARY_SUBSTITUTE_URL | sed -'es,file://,,g'`"
37
38cat > "$substitute_dir/nix-cache-info"<<EOF
39StoreDir: `dirname $drv`
40WantMassQuery: 0
41EOF
42
43cat > "$substitute_dir/$narinfo"<<EOF
44StorePath: $out
45URL: /nowhere/example.nar
46Compression: none
47NarSize: 1234
48References:
49System: `guile -c '(use-modules (guix)) (display (%current-system))'`
50Deriver: $drv
51EOF
52
53# Remove the cached narinfo.
54rm -f "$XDG_CACHE_HOME/guix/substitute-binary/$hash_part"
55
56# Make sure we see the substitute.
57guile -c '
58 (use-modules (guix))
59 (define store (open-connection))
60 (set-build-options store #:use-substitutes? #t)
61 (exit (has-substitutes? store "'"$out"'"))'
62
63# Now, run guix-daemon --no-substitutes.
64socket="$NIX_STATE_DIR/alternate-socket"
65guix-daemon --no-substitutes --listen="$socket" --disable-chroot &
66daemon_pid=$!
67trap "kill $daemon_pid" EXIT
68
69# Make sure we DON'T see the substitute.
70guile -c "
71 (use-modules (guix))
72 (define store (open-connection \"$socket\"))
73
74 ;; This setting MUST NOT override the daemon's --no-substitutes.
75 (set-build-options store #:use-substitutes? #t)
76
77 (exit (not (has-substitutes? store \"$out\")))"