projects/guix·blob a04b886f · refs

235 lines · 6.6 KiB

1# GNU Guix --- Functional package management for GNU
2# Copyright © 2012-2016, 2018-2020, 2024-2025 Ludovic Courtès <[email protected]>
3# Copyright © 2016 Mathieu Lirzin <[email protected]>
4# Copyright © 2020 Tobias Geerinckx-Rice <[email protected]>
5#
6# This file is part of GNU Guix.
7#
8# GNU Guix is free software; you can redistribute it and/or modify it
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#
13# GNU Guix is distributed in the hope that it will be useful, but
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
19# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21#
22# Integration of the `guix-daemon' code taken from upstream Nix.
23#
24
25BUILT_SOURCES += %D%/libstore/schema.sql.hh
26CLEANFILES += %D%/libstore/schema.sql.hh
27
28noinst_LIBRARIES = libutil.a libstore.a
29
30# Use '-std=c++20' for 'std::shared_ptr', 'auto', lambdas, and more.
31AM_CXXFLAGS = -Wall -std=c++20
32
33libutil_a_SOURCES = \
34 %D%/libutil/archive.cc \
35 %D%/libutil/affinity.cc \
36 %D%/libutil/serialise.cc \
37 %D%/libutil/util.cc \
38 %D%/libutil/hash.cc \
39 %D%/libutil/spawn.cc \
40 %D%/libutil/seccomp.cc
41
42libutil_headers = \
43 %D%/libutil/affinity.hh \
44 %D%/libutil/hash.hh \
45 %D%/libutil/serialise.hh \
46 %D%/libutil/util.hh \
47 %D%/libutil/archive.hh \
48 %D%/libutil/types.hh \
49 %D%/libutil/spawn.hh \
50 %D%/libutil/seccomp.hh
51
52libutil_a_CPPFLAGS = \
53 -I$(top_builddir)/nix \
54 -I$(top_srcdir)/%D%/libutil \
55 $(LIBGCRYPT_CPPFLAGS)
56
57libstore_a_SOURCES = \
58 %D%/libstore/gc.cc \
59 %D%/libstore/globals.cc \
60 %D%/libstore/misc.cc \
61 %D%/libstore/references.cc \
62 %D%/libstore/store-api.cc \
63 %D%/libstore/optimise-store.cc \
64 %D%/libstore/local-store.cc \
65 %D%/libstore/build.cc \
66 %D%/libstore/pathlocks.cc \
67 %D%/libstore/derivations.cc \
68 %D%/libstore/builtins.cc \
69 %D%/libstore/sqlite.cc
70
71libstore_headers = \
72 %D%/libstore/references.hh \
73 %D%/libstore/pathlocks.hh \
74 %D%/libstore/globals.hh \
75 %D%/libstore/worker-protocol.hh \
76 %D%/libstore/derivations.hh \
77 %D%/libstore/misc.hh \
78 %D%/libstore/local-store.hh \
79 %D%/libstore/sqlite.hh \
80 %D%/libstore/builtins.hh \
81 %D%/libstore/store-api.hh
82
83libstore_a_CPPFLAGS = \
84 $(libutil_a_CPPFLAGS) \
85 -I$(top_srcdir)/%D%/libstore \
86 -I$(top_builddir)/%D%/libstore \
87 -DNIX_STORE_DIR=\"$(storedir)\" \
88 -DNIX_STATE_DIR=\"$(localstatedir)/guix\" \
89 -DNIX_LOG_DIR=\"$(localstatedir)/log/guix\" \
90 -DGUIX_CONFIGURATION_DIRECTORY=\"$(sysconfdir)/guix\" \
91 -DNIX_BIN_DIR=\"$(bindir)\" \
92 -DDEFAULT_CHROOT_DIRS="\"\""
93
94libstore_a_CXXFLAGS = $(AM_CXXFLAGS) \
95 $(SQLITE3_CFLAGS)
96
97bin_PROGRAMS = guix-daemon
98
99guix_daemon_SOURCES = \
100 %D%/nix-daemon/nix-daemon.cc \
101 %D%/nix-daemon/guix-daemon.cc
102
103guix_daemon_CPPFLAGS = \
104 -DLOCALEDIR=\"$(localedir)\" \
105 $(libutil_a_CPPFLAGS) \
106 -I$(top_srcdir)/%D%/libstore
107
108guix_daemon_LDFLAGS = \
109 $(LIBGCRYPT_LDFLAGS)
110
111guix_daemon_LDADD = \
112 libstore.a libutil.a -lz \
113 $(SQLITE3_LIBS) $(LIBGCRYPT_LIBS)
114
115guix_daemon_headers = \
116 %D%/nix-daemon/nix-daemon.hh
117
118if HAVE_LIBBZ2
119
120guix_daemon_LDADD += -lbz2
121
122endif HAVE_LIBBZ2
123
124noinst_HEADERS = \
125 $(libutil_headers) $(libstore_headers) \
126 $(guix_daemon_headers)
127
128%D%/libstore/schema.sql.hh: guix/store/schema.sql
129 $(AM_V_GEN)$(GUILE) --no-auto-compile -c \
130 "(use-modules (rnrs io ports)) \
131 (call-with-output-file \"$@\" \
132 (lambda (out) \
133 (call-with-input-file \"$^\" \
134 (lambda (in) \
135 (write (get-string-all in) out)))))"
136
137# The '.service' and other files for systemd.
138systemdservicedir = $(libdir)/systemd/system
139nodist_systemdservice_DATA = \
140 etc/gnu-store.mount \
141 etc/guix-daemon.service \
142 etc/guix-publish.service \
143 etc/guix-gc.service \
144 etc/guix-gc.timer
145
146etc/%.mount: etc/%.mount.in \
147 $(top_builddir)/config.status
148 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
149 $(SED) -e 's|@''storedir''@|$(storedir)|' < \
150 "$<" > "$@.tmp"; \
151 mv "$@.tmp" "$@"
152
153etc/guix-%.service: etc/guix-%.service.in \
154 $(top_builddir)/config.status
155 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
156 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|g' \
157 -e 's|@''storedir''@|$(storedir)|g' \
158 -e 's|@''GUIX_SUBSTITUTE_URLS''@|$(GUIX_SUBSTITUTE_URLS)|' \
159 < "$<" > "$@.tmp"; \
160 mv "$@.tmp" "$@"
161
162etc/guix-gc.timer: etc/guix-gc.timer.in \
163 $(top_builddir)/config.status
164 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
165 cp "$<" "$@"
166
167# The service script for sysvinit.
168sysvinitservicedir = $(sysconfdir)/init.d
169nodist_sysvinitservice_DATA = etc/init.d/guix-daemon
170
171etc/init.d/guix-daemon: etc/init.d/guix-daemon.in \
172 $(top_builddir)/config.status
173 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
174 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' \
175 -e 's|@''GUIX_SUBSTITUTE_URLS''@|$(GUIX_SUBSTITUTE_URLS)|' \
176 < "$<" > "$@.tmp"; \
177 mv "$@.tmp" "$@"
178
179# The service script for openrc.
180openrcservicedir = $(sysconfdir)/openrc
181nodist_openrcservice_DATA = etc/openrc/guix-daemon
182
183etc/openrc/guix-daemon: etc/openrc/guix-daemon.in \
184 $(top_builddir)/config.status
185 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
186 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
187 "$<" > "$@.tmp"; \
188 mv "$@.tmp" "$@"
189
190# The '.conf' jobs for Upstart.
191upstartjobdir = $(libdir)/upstart/system
192nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
193
194etc/guix-%.conf: etc/guix-%.conf.in \
195 $(top_builddir)/config.status
196 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
197 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' \
198 -e 's|@''GUIX_SUBSTITUTE_URLS''@|$(GUIX_SUBSTITUTE_URLS)|' \
199 < "$<" > "$@.tmp"; \
200 mv "$@.tmp" "$@"
201
202CLEANFILES += \
203 $(nodist_systemdservice_DATA) \
204 $(nodist_upstartjob_DATA) \
205 $(nodist_sysvinitservice_DATA) \
206 $(nodist_openrcservice_DATA)
207
208EXTRA_DIST += \
209 %D%/AUTHORS \
210 %D%/COPYING \
211 etc/gnu-store.mount.in \
212 etc/guix-daemon.service.in \
213 etc/guix-daemon.conf.in \
214 etc/guix-publish.service.in \
215 etc/guix-publish.conf.in \
216 etc/guix-gc.service.in \
217 etc/guix-gc.timer.in \
218 etc/init.d/guix-daemon.in \
219 etc/openrc/guix-daemon.in
220
221if CAN_RUN_TESTS
222
223AM_TESTS_ENVIRONMENT += \
224 top_builddir="$(abs_top_builddir)"
225
226TESTS += \
227 tests/guix-daemon.sh
228
229endif CAN_RUN_TESTS
230
231clean-local:
232 -if test -d "$(GUIX_TEST_ROOT)"; then \
233 find "$(GUIX_TEST_ROOT)" | xargs chmod +w; \
234 fi
235 -rm -rf "$(GUIX_TEST_ROOT)"