etc: Add systemd files for running ‘guix gc’ periodically
[jackhill/guix/guix.git] / nix / local.mk
CommitLineData
233e7676 1# GNU Guix --- Functional package management for GNU
8dc6c387 2# Copyright © 2012, 2013, 2014, 2015, 2016, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
e71ad29d 3# Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
ebbf9154 4# Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
c2033df4 5#
233e7676 6# This file is part of GNU Guix.
c2033df4 7#
233e7676 8# GNU Guix is free software; you can redistribute it and/or modify it
c2033df4
LC
9# under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 3 of the License, or (at
11# your option) any later version.
12#
233e7676 13# GNU Guix is distributed in the hope that it will be useful, but
c2033df4
LC
14# WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
233e7676 19# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
c2033df4
LC
20
21#
22# Integration of the `guix-daemon' code taken from upstream Nix.
23#
24
c0d2e7b1 25BUILT_SOURCES += %D%/libstore/schema.sql.hh
751164bc 26CLEANFILES += %D%/libstore/schema.sql.hh
c2033df4
LC
27
28noinst_LIBRARIES = libformat.a libutil.a libstore.a
29
2bb04905
LC
30# Use '-std=c++11' for 'std::shared_ptr', 'auto', lambdas, and more.
31AM_CXXFLAGS = -Wall -std=c++11
996ed6ac 32
c2033df4 33libformat_a_SOURCES = \
c0d2e7b1
ML
34 %D%/boost/format/free_funcs.cc \
35 %D%/boost/format/parsing.cc \
36 %D%/boost/format/format_implementation.cc
c2033df4
LC
37
38libformat_headers = \
c0d2e7b1
ML
39 %D%/boost/throw_exception.hpp \
40 %D%/boost/format.hpp \
41 %D%/boost/assert.hpp \
42 %D%/boost/format/macros_default.hpp \
43 %D%/boost/format/format_fwd.hpp \
44 %D%/boost/format/format_class.hpp \
45 %D%/boost/format/exceptions.hpp \
46 %D%/boost/format/group.hpp \
47 %D%/boost/format/feed_args.hpp \
48 %D%/boost/format/internals_fwd.hpp \
49 %D%/boost/format/internals.hpp
c2033df4
LC
50
51libformat_a_CPPFLAGS = \
52 -I$(top_srcdir)/nix
53
54libutil_a_SOURCES = \
c0d2e7b1
ML
55 %D%/libutil/archive.cc \
56 %D%/libutil/affinity.cc \
57 %D%/libutil/serialise.cc \
58 %D%/libutil/util.cc \
8dc6c387 59 %D%/libutil/hash.cc
c2033df4
LC
60
61libutil_headers = \
c0d2e7b1
ML
62 %D%/libutil/affinity.hh \
63 %D%/libutil/hash.hh \
64 %D%/libutil/serialise.hh \
c0d2e7b1
ML
65 %D%/libutil/util.hh \
66 %D%/libutil/archive.hh \
8dc6c387 67 %D%/libutil/types.hh
c2033df4
LC
68
69libutil_a_CPPFLAGS = \
70 -I$(top_builddir)/nix \
c0d2e7b1 71 -I$(top_srcdir)/%D%/libutil \
c2033df4
LC
72 $(libformat_a_CPPFLAGS)
73
74libstore_a_SOURCES = \
c0d2e7b1
ML
75 %D%/libstore/gc.cc \
76 %D%/libstore/globals.cc \
77 %D%/libstore/misc.cc \
78 %D%/libstore/references.cc \
79 %D%/libstore/store-api.cc \
80 %D%/libstore/optimise-store.cc \
81 %D%/libstore/local-store.cc \
82 %D%/libstore/build.cc \
83 %D%/libstore/pathlocks.cc \
7bed5d91 84 %D%/libstore/derivations.cc \
94d92c77 85 %D%/libstore/builtins.cc \
7bed5d91 86 %D%/libstore/sqlite.cc
c2033df4
LC
87
88libstore_headers = \
c0d2e7b1
ML
89 %D%/libstore/references.hh \
90 %D%/libstore/pathlocks.hh \
91 %D%/libstore/globals.hh \
92 %D%/libstore/worker-protocol.hh \
93 %D%/libstore/derivations.hh \
94 %D%/libstore/misc.hh \
95 %D%/libstore/local-store.hh \
7bed5d91 96 %D%/libstore/sqlite.hh \
94d92c77 97 %D%/libstore/builtins.hh \
c0d2e7b1 98 %D%/libstore/store-api.hh
c2033df4
LC
99
100libstore_a_CPPFLAGS = \
101 $(libutil_a_CPPFLAGS) \
c0d2e7b1
ML
102 -I$(top_srcdir)/%D%/libstore \
103 -I$(top_builddir)/%D%/libstore \
c2033df4 104 -DNIX_STORE_DIR=\"$(storedir)\" \
f5768afa
LC
105 -DNIX_STATE_DIR=\"$(localstatedir)/guix\" \
106 -DNIX_LOG_DIR=\"$(localstatedir)/log/guix\" \
9dd674db 107 -DGUIX_CONFIGURATION_DIRECTORY=\"$(sysconfdir)/guix\" \
c2033df4 108 -DNIX_BIN_DIR=\"$(bindir)\" \
2bb04905 109 -DDEFAULT_CHROOT_DIRS="\"\""
c2033df4 110
06ea5c8f 111libstore_a_CXXFLAGS = $(AM_CXXFLAGS) \
c2033df4
LC
112 $(SQLITE3_CFLAGS) $(LIBGCRYPT_CFLAGS)
113
114bin_PROGRAMS = guix-daemon
115
116guix_daemon_SOURCES = \
c0d2e7b1
ML
117 %D%/nix-daemon/nix-daemon.cc \
118 %D%/nix-daemon/guix-daemon.cc
c2033df4
LC
119
120guix_daemon_CPPFLAGS = \
7887bcbf 121 -DLOCALEDIR=\"$(localedir)\" \
c2033df4 122 $(libutil_a_CPPFLAGS) \
c0d2e7b1 123 -I$(top_srcdir)/%D%/libstore
c2033df4
LC
124
125guix_daemon_LDADD = \
f997137d 126 libstore.a libutil.a libformat.a -lz \
c2033df4
LC
127 $(SQLITE3_LIBS) $(LIBGCRYPT_LIBS)
128
351782e2 129guix_daemon_headers = \
c0d2e7b1 130 %D%/nix-daemon/shared.hh
c2033df4 131
f997137d
LC
132if HAVE_LIBBZ2
133
134guix_daemon_LDADD += -lbz2
f997137d
LC
135
136endif HAVE_LIBBZ2
a7a4e6a4 137
c2033df4 138noinst_HEADERS = \
351782e2
LC
139 $(libformat_headers) $(libutil_headers) $(libstore_headers) \
140 $(guix_daemon_headers)
c2033df4 141
3931c761 142%D%/libstore/schema.sql.hh: guix/store/schema.sql
e71ad29d 143 $(AM_V_GEN)$(GUILE) --no-auto-compile -c \
c2033df4
LC
144 "(use-modules (rnrs io ports)) \
145 (call-with-output-file \"$@\" \
146 (lambda (out) \
147 (call-with-input-file \"$^\" \
148 (lambda (in) \
149 (write (get-string-all in) out)))))"
150
332d7903 151# The '.service' files for systemd.
d2825c96 152systemdservicedir = $(libdir)/systemd/system
1a1faa78
TGR
153nodist_systemdservice_DATA = \
154 etc/gnu-store.mount \
155 etc/guix-daemon.service \
5c4fd770
TJB
156 etc/guix-publish.service \
157 etc/guix-gc.service \
158 etc/guix-gc.timer
1a1faa78
TGR
159
160etc/%.mount: etc/%.mount.in \
161 $(top_builddir)/config.status
162 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
163 $(SED) -e 's|@''storedir''@|$(storedir)|' < \
164 "$<" > "$@.tmp"; \
165 mv "$@.tmp" "$@"
d2825c96 166
332d7903 167etc/guix-%.service: etc/guix-%.service.in \
d2825c96 168 $(top_builddir)/config.status
5a5fc61f 169 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
613d0895 170 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
5a5fc61f 171 "$<" > "$@.tmp"; \
d2825c96
LC
172 mv "$@.tmp" "$@"
173
9927e5b1 174# The service script for sysvinit.
73fbe041
DM
175sysvinitservicedir = $(sysconfdir)/init.d
176nodist_sysvinitservice_DATA = etc/init.d/guix-daemon
177
178etc/init.d/guix-daemon: etc/init.d/guix-daemon.in \
179 $(top_builddir)/config.status
180 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
181 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
182 "$<" > "$@.tmp"; \
183 mv "$@.tmp" "$@"
184
cabac732 185# The service script for openrc.
aed51ece 186openrcservicedir = $(sysconfdir)/openrc
cabac732
MS
187nodist_openrcservice_DATA = etc/openrc/guix-daemon
188
189etc/openrc/guix-daemon: etc/openrc/guix-daemon.in \
190 $(top_builddir)/config.status
191 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
192 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
193 "$<" > "$@.tmp"; \
194 mv "$@.tmp" "$@"
195
332d7903 196# The '.conf' jobs for Upstart.
ad227484 197upstartjobdir = $(libdir)/upstart/system
332d7903 198nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
ad227484 199
332d7903 200etc/guix-%.conf: etc/guix-%.conf.in \
ad227484 201 $(top_builddir)/config.status
5a5fc61f 202 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
613d0895 203 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
5a5fc61f 204 "$<" > "$@.tmp"; \
ad227484
MDRS
205 mv "$@.tmp" "$@"
206
b20644ed
LC
207CLEANFILES += \
208 $(nodist_systemdservice_DATA) \
73fbe041 209 $(nodist_upstartjob_DATA) \
cabac732
MS
210 $(nodist_sysvinitservice_DATA) \
211 $(nodist_openrcservice_DATA)
b20644ed 212
c2033df4 213EXTRA_DIST += \
c0d2e7b1
ML
214 %D%/AUTHORS \
215 %D%/COPYING \
c40ad1df 216 etc/gnu-store.mount.in \
fa54f44b
LC
217 etc/guix-daemon.service.in \
218 etc/guix-daemon.conf.in \
219 etc/guix-publish.service.in \
73fbe041 220 etc/guix-publish.conf.in \
5c4fd770
TJB
221 etc/guix-gc.service.in \
222 etc/guix-gc.timer \
cabac732
MS
223 etc/init.d/guix-daemon.in \
224 etc/openrc/guix-daemon.in
d23077dc 225
bb251307
LC
226if CAN_RUN_TESTS
227
d23077dc 228AM_TESTS_ENVIRONMENT += \
69cfce50 229 top_builddir="$(abs_top_builddir)"
d23077dc
LC
230
231TESTS += \
232 tests/guix-daemon.sh
233
bb251307
LC
234endif CAN_RUN_TESTS
235
d23077dc 236clean-local:
03fa2758
LC
237 -if test -d "$(GUIX_TEST_ROOT)"; then \
238 find "$(GUIX_TEST_ROOT)" | xargs chmod +w; \
239 fi
69cfce50 240 -rm -rf "$(GUIX_TEST_ROOT)"