Commit graph

223 commits

Author SHA1 Message Date
Ludovic Courtès
47e99e626b
daemon: Remove traces of 'NIX_ROOT_FINDER'.
This is a followup to 2e3e5d2198.

* build-aux/test-env.in: Remove mentions of 'NIX_ROOT_FINDER'.
* nix/libstore/gc.cc (LocalStore::collectGarbage): Adjust comment
accordingly.
2019-10-16 22:53:40 +02:00
Ludovic Courtès
ada9a19a2d
daemon: Strictly respect timeouts for 'guix offload'.
Until now it was up to 'guix offload' to honor timeouts.  Unfortunately
it would sometimes fail to do that, for example due to the libssh bug at
<https://bugs.libssh.org/T33>.  With this change, 'guix offload' is
automatically killed by the daemon when one of the timeouts expires.

Thus, data transfers performed by 'guix offload' now count as part of
the timeouts, rather than just actual build time.

* nix/libstore/build.cc (DerivationGoal::tryBuildHook): Pass true as the
'respectTimeouts' argument to 'childStarted'.
2019-09-28 22:56:40 +02:00
Timothy Sample
82c4ad9646
daemon: Include 'config.h' in 'nix-daemon.cc'.
* nix/nix-daemon/nix-daemon.cc: Include 'config.h'.
2019-09-16 23:54:58 -04:00
Ludovic Courtès
82f903e70f
daemon: Remove 'NIX_LIBEXEC_DIR'.
* nix/libstore/globals.hh (Settings)[nixLibexecDir]: Remove.
* nix/libstore/globals.cc (Settings::processEnvironment): Remove
reference to 'nixLibexecDir'.
* nix/local.mk (libstore_a_CPPFLAGS): Remove -DNIX_LIBEXEC_DIR flag.
* build-aux/pre-inst-env.in: Remove references to 'NIX_LIBEXEC_DIR'.
2019-09-08 11:49:24 +02:00
Ludovic Courtès
f6919ebdc6
daemon: Run 'guix substitute' directly and assume a single substituter.
The daemon had a mechanism that allows it to handle a list of
substituters and try them sequentially; this removes it.

* nix/scripts/substitute.in: Remove.
* nix/local.mk (nodist_pkglibexec_SCRIPTS): Remove.
* config-daemon.ac: Don't output 'nix/scripts/substitute'.
* nix/libstore/build.cc (SubstitutionGoal)[subs, sub, hasSubstitute]:
Remove.
[tryNext]: Make private.
(SubstitutionGoal::SubstitutionGoal, SubstitutionGoal::init): Remove now
unneeded initializers.
(SubstitutionGoal::tryNext): Adjust to assume a single substituter: call
'amDone' upfront when we couldn't find substitutes.
(SubstitutionGoal::tryToRun): Adjust to run 'guix substitute' via
'settings.guixProgram'.
(SubstitutionGoal::finished): Call 'amDone(ecFailed)' upon failure
instead of setting 'state' to 'tryNext'.
* nix/libstore/globals.hh (Settings)[substituters]: Remove.
* nix/libstore/local-store.cc (LocalStore::~LocalStore): Adjust to
handle a single substituter.
(LocalStore::startSubstituter): Remove 'path' parameter.  Adjust to
invoke 'settings.guixProgram'.  Don't refer to 'run.program', which no
longer exists.
(LocalStore::querySubstitutablePaths): Adjust for 'runningSubstituters'
being a singleton instead of a list.
(LocalStore::querySubstitutablePathInfos): Likewise, and remove
'substituter' parameter.
* nix/libstore/local-store.hh (RunningSubstituter)[program]: Remove.
(LocalStore)[runningSubstituters]: Remove.
[runningSubstituter]: New field.
[querySubstitutablePathInfos]: Remove 'substituter' parameter.
[startSubstituter]: Remove 'substituter' parameter.
* nix/nix-daemon/guix-daemon.cc (main): Remove references to
'settings.substituters'.
* nix/nix-daemon/nix-daemon.cc (performOp): Ignore the user's
"build-use-substitutes" value when 'settings.useSubstitutes' is false.
2019-09-08 11:49:24 +02:00
Ludovic Courtès
bc69ea2d60
daemon: Run 'guix offload' directly.
* nix/scripts/offload.in: Remove.
* nix/local.mk (nodist_pkglibexec_SCRIPTS) [BUILD_DAEMON_OFFLOAD]:
Remove 'scripts/offload'.
* config-daemon.ac: Don't output 'nix/scripts/offload'.
* build-aux/pre-inst-env.in: Don't set 'NIX_BUILD_HOOK'.
* nix/libstore/build.cc (HookInstance::HookInstance): Run 'guix
offload'.
(DerivationGoal::tryBuildHook): Remove reference to 'NIX_BUILD_HOOK'.
* nix/nix-daemon/guix-daemon.cc (main) [HAVE_DAEMON_OFFLOAD_HOOK]: Don't
set 'NIX_BUILD_HOOK'.
* nix/nix-daemon/nix-daemon.cc (performOp) [!HAVE_DAEMON_OFFLOAD_HOOK]:
Leave 'settings.useBuildHook' unchanged.
2019-09-08 11:49:24 +02:00
Ludovic Courtès
9fcc35c51f
daemon: Run 'guix perform-download' directly.
* nix/scripts/download.in: Remove.
* nix/local.mk (nodist_pkglibexec_SCRIPTS): Remove 'scripts/download'.
* config-daemon.ac: Don't output 'nix/scripts/download'.
* nix/libstore/builtins.cc (builtinDownload): Invoke 'guix
perform-download' directly.
2019-09-08 11:49:24 +02:00
Ludovic Courtès
0c684b7edf
daemon: Run 'guix authenticate' directly.
* nix/scripts/authenticate.in: Remove.
* nix/local.mk (nodist_pkglibexec_SCRIPTS): Remove
scripts/authenticate.
* config-daemon.ac: Don't output 'nix/scripts/authenticate'.
* nix/libstore/local-store.cc (runAuthenticationProgram): Run 'guix
authenticate'.
2019-09-08 11:49:24 +02:00
Ludovic Courtès
2e3e5d2198
daemon: Invoke 'guix gc --list-busy' instead of 'list-runtime-roots'.
* nix/scripts/list-runtime-roots.in: Remove.
* guix/store/roots.scm (%proc-directory): New variable.
(proc-file-roots, proc-exe-roots, proc-cwd-roots)
(proc-fd-roots, proc-maps-roots, proc-environ-roots)
(referenced-files, canonicalize-store-item, busy-store-items): New
procedures, taken from 'list-runtime-roots.in'.
* nix/libstore/globals.hh (Settings)[guixProgram]: New field.
* nix/libstore/globals.cc (Settings::processEnvironment): Initialize
'guixProgram'.
* nix/libstore/gc.cc (addAdditionalRoots): Drop code related to
'NIX_ROOT_FINDER'.  Run "guix gc --list-busy".
* nix/local.mk (nodist_pkglibexec_SCRIPTS): Remove
'scripts/list-runtime-roots'.
* config-daemon.ac: Don't output nix/scripts/list-runtime-roots.
* build-aux/pre-inst-env.in: Don't set 'NIX_ROOT_FINDER'.
Set 'GUIX'.
* doc/guix.texi (Invoking guix gc): Document '--list-busy'.
* guix/scripts/gc.scm (show-help, %options): Add "--list-busy".
(guix-gc)[list-busy]: New procedure.
Handle the 'list-busy' action.
2019-09-08 11:49:24 +02:00
Eelco Dolstra
546a709f20
daemon: Don't reply on 'st_blocks'.
Ported by Ludovic Courtès <ludo@gnu.org>
from <a2c4fcd5e9>.

* nix/libstore/gc.cc (LocalStore::removeUnusedLinks): Use 'st.st_size'
instead of 'st.st_blocks * 512'.
* nix/libutil/util.cc (_deletePath): Likewise.
2019-08-30 01:33:45 +02:00
Ludovic Courtès
76533c52c0
daemon: Replace "illegal" by "invalid" in error messages.
* nix/libstore/build.cc (parseReferenceSpecifiers): Replace "illegal" by
"invalid".
* nix/libstore/globals.cc (Settings::pack): Likewise.
* nix/libstore/store-api.cc (checkStoreName): Likewise.
2019-06-13 00:44:01 +02:00
Ludovic Courtès
59e8044588
Remove traces of "GuixSD".
* gnu/bootloader/extlinux.scm (extlinux-configuration-file): Remove
mentions of "GuixSD".
* gnu/bootloader/grub.scm (install-grub-efi): Likewise.
* gnu/build/vm.scm (make-iso9660-image): Change default #:volume-id to
"Guix_image".
(initialize-hard-disk): Search for the "Guix_image" label.
* gnu/ci.scm (system-test-jobs, tarball-jobs): Remove "GuixSD".
* gnu/installer/newt/welcome.scm (run-welcome-page): Likewise.
* gnu/packages/audio.scm (supercollider)[description]: Likewise.
* gnu/packages/curl.scm (curl): Likewise.
* gnu/packages/emacs.scm (emacs): Likewise.
* gnu/packages/gnome.scm (network-manager): Likewise.
* gnu/packages/julia.scm (julia): Likewise.
* gnu/packages/linux.scm (alsa-plugins): Likewise.
(powertop, wireless-regdb): Likewise.
* gnu/packages/package-management.scm (guix): Likewise.
* gnu/packages/polkit.scm (polkit): Likewise.
* gnu/packages/tex.scm (texlive-bin): Likewise.
* gnu/services/base.scm (file-systems->fstab): Likewise.
* gnu/services/cups.scm (%cups-activation): Likewise.
* gnu/services/mail.scm (%dovecot-activation): Likewise.
* gnu/services/messaging.scm (prosody-configuration)[log]: Likewise.
* gnu/system/examples/vm-image.tmpl (vm-image-motd): Likewise.
* gnu/system/install.scm (installation-os)[file-systems]: Change root
file system label to "Guix_image".
* gnu/system/mapped-devices.scm (check-device-initrd-modules):
Remove "GuixSD".
* gnu/system/vm.scm (system-docker-image): Likewise.
(system-disk-image)[root-label]: Change to "Guix_image".
* gnu/tests/install.scm (run-install): Remove "GuixSD".
* guix/modules.scm (guix-module-name?): Likewise.
* nix/libstore/optimise-store.cc: Likewise.
2019-03-13 23:12:43 +01:00
Ludovic Courtès
d591242808
daemon: Emit a 'build-succeeded' event in check mode.
Until now, something like "guix build sed -v1 --check" would not get a
'build-succeeded' event, which in turn meant that the spinner would not
be erased upon build completion.

* nix/libstore/build.cc (DerivationGoal::registerOutputs): When
'buildMode' is bmCheck and 'settings.printBuildTrace' emit a
"@ build-succeeded" trace upon success.
* tests/store.scm ("build-succeeded trace in check mode"): New test.
2019-02-06 23:06:18 +01:00
Ludovic Courtès
959eaa1eb8
daemon: Add "/guix" to default 'nixLibexecDir'.
This makes it easier to run the uninstalled daemon.

* nix/local.mk (libstore_a_CPPFLAGS): Append "/guix" to
NIX_LIBEXEC_DIR.
* build-aux/pre-inst-env.in (NIX_LIBEXEC_DIR): Adjust comment.
* nix/libstore/builtins.cc (builtinDownload): Remove SUBDIR and its
use.
* nix/libstore/local-store.cc (runAuthenticationProgram): Ditto.
* nix/libstore/gc.cc (addAdditionalRoots): Remove "/guix" prefix.
* nix/nix-daemon/guix-daemon.cc (main): Ditto.
2019-02-04 16:20:01 +01:00
Ludovic Courtès
4d4a38f620
daemon: Remove the 'NIX_SUBSTITUTERS' environment variable.
* nix/libstore/globals.cc (Settings:update): Remove changes to
'substituters'.
* nix/nix-daemon/guix-daemon.cc (main): Set 'settings.substituters'
directly instead of changing the 'NIX_SUBSTITUTERS' environment variable.
* build-aux/pre-inst-env.in: Remove reference to 'NIX_SUBSTITUTERS'.
2019-02-04 16:20:01 +01:00
Ludovic Courtès
65d13e3043
daemon: Remove unused 'NIX_DATA_DIR' environment variable.
* nix/libstore/globals.hh (Settings)[nixDataDir]: Remove.
* nix/libstore/globals.cc (Settings:processEnvironment): Remove setting
of 'nixDataDir'.
* nix/local.mk (libstore_a_CPPFLAGS): Remove '-DNIX_DATA_DIR'.
2019-02-04 00:03:30 +01:00
Ludovic Courtès
a87d66f371
daemon: Rename 'NIX_STATE_DIR' and 'NIX_DB_DIR' environment variables.
Fixes <https://bugs.gnu.org/22459>.
Reported by Jeff Mickey <j@codemac.net>.

* guix/config.scm.in (%state-directory): Change NIX_STATE_DIR to
GUIX_STATE_DIRECTORY.
(%store-database-directory): Change NIX_DB_DIR to
GUIX_DATABASE_DIRECTORY.
* nix/libstore/globals.cc (Settings::processEnvironment): Likewise.
* guix/self.scm (make-config.scm): Likewise.
* build-aux/build-self.scm (make-config.scm): Likewise.
* build-aux/test-env.in: Likewise.
* tests/derivations.scm ("derivation #:leaked-env-vars"): Likewise.
* tests/guix-build.sh (GUIX_DAEMON_SOCKET): Likewise.
* tests/guix-daemon.sh (socket): Likewise.
2019-02-04 00:03:30 +01:00
Ludovic Courtès
8327e73396
daemon: Use unbranded phrases in comments and messages.
* nix/libstore/build.cc, nix/libstore/globals.cc,
nix/libstore/gc.cc, nix/libstore/local-store.cc,
nix/libstore/optimise-store.cc, nix/libstore/store-api.cc,
nix/libutil/archive.cc, nix/nix-daemon/nix-daemon.cc: Replace "Nix
store" by "store", and "Nix daemon" by "build daemon".
2018-12-16 16:28:07 +01:00
Ludovic Courtès
bb640d6133
daemon: Ignore '--keep-failed' for TCP/IP clients.
* nix/nix-daemon/nix-daemon.cc (performOp) <wopSetOptions>: When
'isRemoteConnection' is true, set 'settings.keepFailed' to zero.
* doc/guix.texi (Common Build Options): Document this behavior.
2018-11-24 19:52:16 +01:00
Ludovic Courtès
0fe1fba4af
daemon: Install 'authenticate' script under LIBEXECDIR/guix.
That way it is handled in the same way as other helper scripts.

* nix/scripts/guix-authenticate.in: Rename to...
* nix/scripts/authenticate.in: ... this.
* config-daemon.ac: Adjust accordingly.
* nix/local.mk (libstore_a_CPPFLAGS): Remove -DOPENSSL_PATH.
(nodist_libexec_SCRIPTS): Remove.
(nodist_pkglibexec_SCRIPTS): New variable.
* nix/nix-daemon/guix-daemon.cc (main): Remove 'setenv' call for
"PATH".
* nix/libstore/local-store.cc (runAuthenticationProgram): New function.
(LocalStore::exportPath, LocalStore::importPath): Use it instead of
'runProgram' and OPENSSL_PATH.
2018-11-14 21:34:08 +01:00
Ludovic Courtès
6ef61cc4c3
daemon: Support multiplexed build output.
This allows clients to tell whether output comes from the daemon or, if
it comes from a builder, from which builder it comes.  The latter is
particularly useful when MAX-BUILD-JOBS > 1.

* nix/libstore/build.cc (DerivationGoal::tryBuildHook)
(DerivationGoal::startBuilder): Print the child's PID in "@ build-started"
traces.
(DerivationGoal::handleChildOutput): Define 'prefix', pass it to
'writeToStderr'.
* nix/libstore/globals.cc (Settings:Settings): Initialize
'multiplexedBuildOutput'.
(Settings::update): Likewise.
* nix/libstore/globals.hh (Settings)[multiplexedBuildOutput]: New field.
Update 'printBuildTrace' documentation.
* nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump to 0.163.
* nix/nix-daemon/nix-daemon.cc (performOp) <wopSetOptions>: Special-case
"multiplexed-build-output" and remove "use-ssh-substituter".
* guix/store.scm (set-build-options): Add #:multiplexed-build-output?
and honor it.
(%protocol-version): Bump to #x163.
* tests/store.scm ("multiplexed-build-output"): New test.

fixlet
2018-10-15 22:40:35 +02:00
Ludovic Courtès
c577ac194a
daemon: Remove unused 'Settings' fields.
* nix/libstore/globals.hh (Settings)[sshSubstituterHosts]
[useSshSubstituter, logServers, enableImportNative]: Remove fields.
* nix/libstore/globals.cc (Settings::Settings, Settings::update): Remove
references to these.
2018-10-02 23:08:30 +02:00
Ludovic Courtès
7eca789201
daemon: Remove "case hack" for nars.
This code has never been of any use in Guix.

* nix/libutil/archive.cc (useCaseHack): Remove.
(parse): Keep only the alternate branch in "if (useCaseHack)".
2018-10-02 23:08:30 +02:00
Ludovic Courtès
240a9c69a6
perform-download: Optionally report a "download-progress" trace.
* guix/scripts/perform-download.scm (perform-download): Add
 #:print-build-trace? and pass it to 'url-fetch'.
(guix-perform-download): Define 'print-build-trace?' and pass it to
'perform-download'.
* guix/build/download.scm (ftp-fetch): Add #:print-build-trace? and
honor it.
(url-fetch): Likewise.
* nix/libstore/builtins.cc (builtinDownload): Set _NIX_OPTIONS
environment variable.
2018-09-27 23:21:53 +02:00
Ludovic Courtès
dc0f74e5fc
Add (guix status) and use it for pretty colored output.
* guix/progress.scm (progress-reporter/trace): New procedure.
(%progress-interval): New variable.
(progress-reporter/file): Use it.
* guix/scripts/build.scm (set-build-options-from-command-line): Pass
 #:print-extended-build-trace?.
(%default-options): Add 'print-extended-build-trace?'.
(guix-build): Parameterize CURRENT-TERMINAL-COLUMNS.  Use
'build-status-updater'.
* guix/scripts/environment.scm (%default-options): Add
'print-extended-build-trace?'.
(guix-environment): Wrap body in 'with-status-report'.
* guix/scripts/pack.scm (%default-options): Add 'print-build-trace?' and
'print-extended-build-trace?'.
(guix-pack): Wrap body in 'with-status-report'.
* guix/scripts/package.scm (%default-options, guix-package): Likewise.
* guix/scripts/system.scm (%default-options, guix-system): Likewise.
* guix/scripts/pull.scm (%default-options, guix-pull): Likewise.
* guix/scripts/substitute.scm (progress-report-port): Don't call STOP
when TOTAL is zero.
(process-substitution): Add #:print-build-trace? and honor it.
(guix-substitute)[print-build-trace?]: New variable.
Pass #:print-build-trace? to 'process-substitution'.
* guix/status.scm: New file.
* guix/store.scm (set-build-options): Add #:print-extended-build-trace?;
pass it into PAIRS.
(%protocol-version): Bump.
(protocol-version, nix-server-version): New procedures.
(current-store-protocol-version): New variable.
(with-store, build-things): Parameterize it.
* guix/ui.scm (build-output-port): Remove.
(colorize-string): Export.
* po/guix/POTFILES.in: Add guix/status.scm.
* tests/status.scm: New file.
* Makefile.am (SCM_TESTS): Add it.
* nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump to 0x162.
* nix/libstore/build.cc (DerivationGoal::registerOutputs)
(SubstitutionGoal::finished): Print a "@ hash-mismatch" trace before
throwing.
2018-09-27 23:21:53 +02:00
Ludovic Courtès
de30f71a09
build: Remove leftover reference to nix/libstore/schema.sql.
This is a followup to 3931c76154.
Reported by Julien Lepiller.

* nix/local.mk (EXTRA_DIST): Remove schema.sql.
2018-06-22 10:23:31 +02:00
Ludovic Courtès
ea0a06cee2
Remove 'guix-register' and its traces.
* Makefile.am (SH_TESTS): Remove tests/guix-register.sh.
* build-aux/pre-inst-env.in (GUIX_REGISTER): Remove.
* gnu/build/install.scm (directives): Remove outdated comment.
* gnu/build/vm.scm (root-partition-initializer): Update comment.
* gnu/packages/package-management.scm (guix-register): Remove.
* guix/config.scm.in (%sbindir, %guix-register-program): Remove.
* guix/scripts/system.scm (install): Adjust docstring.
* guix/self.scm (make-config.scm): Remove #:guix.  Do not generate
%sbindir and %guix-register-program.
(specification->package): Remove "guix".
* nix/guix-register/guix-register.cc: Remove.
* nix/libstore/store-api.cc (decodeValidPathInfo): Remove.
* nix/libstore/store-api.hh (decodeValidPathInfo): Remove declaration.
* nix/local.mk (sbin_PROGRAMS, guix_register_SOURCES)
(guix_register_CPPFLAGS, guix_register_LDFLAGS): Remove.
* tests/guix-register.sh: Remove.
2018-06-14 11:17:00 +02:00
Ludovic Courtès
3931c76154
database: 'with-database' can now initialize new databases.
* nix/libstore/schema.sql: Rename to...
* guix/store/schema.sql: ... this.
* Makefile.am (nobase_dist_guilemodule_DATA): Add it.
* nix/local.mk (%D%/libstore/schema.sql.hh): Adjust accordingly.
* guix/store/database.scm (sql-schema): New variable.
(sqlite-exec, initialize-database, call-with-database): New procedures.
(with-database): Rewrite in terms of 'call-with-database'.
* tests/store-database.scm ("new database"): New test.
* guix/self.scm (compiled-guix)[*core-modules*]: Add 'schema.sql' to
 #:extra-files.
2018-06-14 11:16:58 +02:00
Ludovic Courtès
751164bca1
build: Do not add all of $(BUILT_SOURCES) to $(CLEANFILES).
Reported by Gábor Boskovits <boskovits@gmail.com>.
Fixes <https://bugs.gnu.org/31700>.

* nix/local.mk (CLEANFILES): Add nothing but schema.sql.hh.
2018-06-08 15:23:39 +02:00
Efraim Flashner
162825f965
daemon: Allow building for armhf-linux on aarch64-linux.
* nix/libstore/build.cc (canBuildLocally): Allow building armhf-linux
builds on aarch64-linux.
(DerivationGoal::runChild) Throw error if attempting to build for
armhf-linux on an unsupported platform.
* doc/guix.texi (Invoking guix build): Document how to build natively
for armhf-linux on aarch64-linux.  Add note that on some aarch64
machines this is unsupported.
2018-05-17 20:37:27 +03:00
Roel Janssen
5cefb13ddd
guix-daemon: Disable garbage collection for remote connections.
* nix/nix-daemon/nix-daemon.cc (isRemoteConnection): New variable.
  (performOp): For wopCollectGarbage, throw an error when isRemoteConnection
  is set.
  (acceptConnection): Set isRemoteConnection when connection is not AF_UNIX.
* tests/guix-daemon.sh: Add a test for the new behavior.
2018-04-19 19:06:26 +02:00
Ludovic Courtès
602a148650
daemon: Remove unused schema upgrade code.
* nix/libstore/local-store.cc (LocalStore): Remove upgrade code.
(LocalStore::queryValidPathsOld, LocalStore::queryPathInfoOld)
(LocalStore::upgradeStore6, makeMutable)
(LocalStore::upgardeStore7): Remove.
* nix/libstore/local-store.hh: Adjust accordingly.
2018-03-30 23:42:07 +02:00
Ludovic Courtès
c7589cce8d
daemon: Remove dead code.
* nix/libstore/globals.cc (Settings::loadConfFile, Settings::unpack):
Remove.
* nix/libstore/globals.hh: Adjust accordingly.
* nix/libstore/misc.cc (queryMissing): Remove.
* nix/libstore/misc.hh: Adjust accordingly.
* nix/libstore/store-api.cc (followLinksToStore)
(followLinksToStorePath, computeStorePathForHash): Remove.
* nix/libstore/store-api.hh: Adjust accordingly.
2018-03-30 23:42:07 +02:00
Ludovic Courtès
7bf2a70a4f
daemon: Always try to execute the builder regardless of the platform.
* nix/libstore/build.cc (runChild): Move platform check after 'execve'
call.  Check specifically for ENOEXEC.
2018-01-11 10:25:06 +01:00
Ludovic Courtès
f997137d0e
daemon: Make libbz2 an optional dependency.
* config-daemon.ac: Don't bail out when libbz2 is missing.  Define
'HAVE_LIBBZ2' Automake conditional.
* nix/libstore/build.cc: Wrap relevant bits in '#if HAVE_BZLIB_H'.
* nix/libstore/globals.cc (Settings::Settings): 'logCompression'
defaults to COMPRESSION_GZIP when HAVE_BZLIB_H is false.
* nix/libstore/globals.hh (CompressionType): Make 'COMPRESSION_BZIP2'
conditional on HAVE_BZLIB_H.
* nix/local.mk (guix_register_LDADD, guix_daemon_LDADD): Add -lbz2 only
when HAVE_LIBBZ2.
* nix/nix-daemon/guix-daemon.cc (parse_opt): Ignore "bzip2" when not
HAVE_BZLIB_H.
2018-01-07 23:47:22 +01:00
Ludovic Courtès
29a6866886
daemon: Add gzip log compression.
* nix/nix-daemon/guix-daemon.cc (GUIX_OPT_LOG_COMPRESSION): New macro.
(options): Mark "disable-log-compression" as hidden and add
"log-compression".
(parse_opt): Handle GUIX_OPT_LOG_COMPRESSION.
* nix/libstore/build.cc (DerivationGoal): Add 'gzLogFile'.
(openLogFile): Initialize it when 'logCompression' is COMPRESSION_GZIP.
(closeLogFile, handleChildOutput): Honor 'gzLogFile'.
* nix/libstore/globals.hh (Settings)[compressLog]: Remove.
[logCompression]: New field.
(CompressionType): New enum.
* nix/libstore/globals.cc (Settings::Settings): Initialize it.
(update): Remove '_get' call for 'compressLog'.
* nix/local.mk (guix_daemon_LDADD, guix_register_LDADD): Add -lz.
* guix/store.scm (log-file): Handle '.gz' log files.
* tests/guix-daemon.sh: Add test with '--log-compression=gzip'.
* doc/guix.texi (Invoking guix-daemon): Adjust accordingly.
* config-daemon.ac: Check for libz and zlib.h.
2018-01-07 23:47:22 +01:00
Ludovic Courtès
091191c3dc
list-runtime-root: Fix off-by-one in 'strip-drop' call.
Fixes <https://bugs.gnu.org/29862>.
Reported by Danny Milosavljevic <dannym@scratchpost.org>.

* nix/scripts/list-runtime-roots.in (canonicalize-store-item): Define
'store' with a trailing "/".  Have the 'string-prefix?' call match the
'string-drop' call.
2017-12-31 11:18:30 +01:00
Ludovic Courtès
9b07130129
list-runtime-roots: Ignore ESRCH while reading from /proc.
Fixes <https://bugs.gnu.org/29368>.
Reported by Martin Castillo <castilma@uni-bremen.de>.

* nix/scripts/list-runtime-roots.in (referenced-files): Ignore ESRCH.
2017-11-26 15:58:33 +01:00
Ludovic Courtès
856b68bda9
list-runtime-roots: Ignore PIDs we cannot access.
This allows running as non-root.
Fixes a regression introduced in b8f59cdc20.

* nix/scripts/list-runtime-roots.in (referenced-files): Handle EACCES in
addition to ENOENT.
2017-11-12 23:53:12 +01:00
Ludovic Courtès
fb17a89912
list-runtime-roots: Canonicalize store items.
Looking at 'addAdditionalRoots' in libstore/gc.cc, it looks like it
should always have been this way.  In practice it probably doesn't make
much of a difference.

* nix/scripts/list-runtime-roots.in (canonicalize-store-item): New
procedure.
<top level>: Use it.
2017-11-12 22:42:17 +01:00
Ludovic Courtès
b8f59cdc20
list-runtime-roots: Do not use 'lsof'.
This makes things a bit faster (0.8s instead of 1.4s on my laptop).

* nix/scripts/list-runtime-roots.in (lsof-roots): Remove.
(proc-fd-roots): Return the empty list when 'scandir' returns #f.
(referenced-files): New procedure.
Use it at the top level.
2017-11-12 22:42:17 +01:00
Andy Wingo
ed464f48ef
nix: Remove unused function.
* nix/libutil/util.hh:
* nix/libutil/util.cc (decodeOctalEscaped): Remove unused and buggy function.
2017-08-18 11:31:28 +02:00
Jörg Thalheim
842e0e439a
Simplify remouting with MS_PRIVATE in sandbox build
also fix race condition if mounts are added after mountinfo is read.
2017-08-18 11:31:17 +02:00
Mark H Weaver
a1aa5dabaa
daemon: Ensure the child stack is aligned on a 16-byte boundary.
* nix/libstore/build.cc (DerivationGoal::startBuilder): When calling 'clone',
ensure that the stack is aligned on a 16-byte boundary.
2017-08-07 16:41:03 -04:00
Efraim Flashner
31ed845b70
daemon: On aarch64, use increments of 16 on the stack.
* nix/libstore/build.cc (DerivationGoal::startBuilder): When on aarch64,
when calling clone(), increment the stack by 16.
2017-08-05 22:38:48 +03:00
Mark H Weaver
7656739771
Revert "daemon: Ensure proper alignment on the stack."
This reverts commit ab4ccc8fcf.
2017-08-05 01:57:25 -04:00
Jan Nieuwenhuizen
2e009ae7cd
daemon: Flush the sink upon 'exportPath' errors.
Prior to this change, errors such as wrong permissions on
/etc/guix/signing-key.sec would give:

  guix-daemon: nix/libutil/serialise.cc:15: virtual nix::BufferedSink::~BufferedSink(): Assertion `!bufPos' failed.

This patch correctly propagates the error to the client and thus changes
that to:

  error: build failed: file `/etc/guix/signing-key.sec' should be secret (inaccessible to everybody else)!

* nix/nix-daemon/nix-daemon.cc (performOp): Wrap 'exportPath' call in
'try' block.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2017-07-17 15:13:41 +02:00
Ludovic Courtès
5c82722cac
daemon: Allow compilation with GCC 4.9.
Reported by Ricardo Wurmus.

* nix/nix-daemon/nix-daemon.cc (acceptConnection): Remove intermediate
'inaddr' variables that relied on implicit casts.  This fixes
compilation with GCC 4.9.
2017-07-10 11:55:54 +02:00
Ludovic Courtès
6efb578a14
daemon: Set TCP_NODELAY and TCP_QUICKACK on remote sockets.
* nix/nix-daemon/nix-daemon.cc (acceptConnection): Set TCP_NODELAY and
TCP_QUICKACK on REMOTE.
2017-06-22 10:59:07 +02:00
Ludovic Courtès
1071f781d9
daemon: '--listen' can be passed several times, can specify TCP endpoints.
* nix/nix-daemon/guix-daemon.cc (DEFAULT_GUIX_PORT): New macro.
(listen_options): New variable.
(parse_opt): Push back '--listen' options to LISTEN_OPTIONS.
(open_unix_domain_socket, open_inet_socket)
(listening_sockets): New functions.
(main): Use it.  Pass SOCKETS to 'run'.
* nix/nix-daemon/nix-daemon.cc (matchUser): Remove.
(SD_LISTEN_FDS_START): Remove.
(acceptConnection): New function.
(daemonLoop): Rewrite to take a vector of file descriptors, to select(2)
on them, and to call 'acceptConnection'.
(run): Change to take a vector of file descriptors.
* tests/guix-daemon.sh: Add test.
2017-06-22 10:59:07 +02:00
Ludovic Courtès
2ca9f51ec8
daemon: Add '--timeout' and '--max-silent-time'.
* nix/nix-daemon/guix-daemon.cc (GUIX_OPT_TIMEOUT)
(GUIX_OPT_MAX_SILENT_TIME): New macros.
* nix/nix-daemon/guix-daemon.cc (options): Add '--timeout' and
'--max-silent-time'.
(parse_opt): Honor them.
* tests/guix-daemon.sh: Add test.
* doc/guix.texi (Invoking guix-daemon): Document the options.
(Common Build Options): Properly describe default
timeout/max-silent-time value.  Add cross-ref to "Invoking
guix-daemon".
2017-06-04 00:35:55 +02:00
Ludovic Courtès
f0a0b58bfa
daemon: Report hash mismatches in a cleaner way.
Suggested by Hartmut Goebel.

* nix/libstore/build.cc (DerivationGoal::registerOutputs): Report hash
mismatches on 3 lines for clarity.
(SubstitutionGoal::finished): Likewise.
2017-05-30 18:08:37 +02:00
Ludovic Courtès
ac9c1dc7bd
list-runtime-roots: Bufferize the lsof pipe.
* nix/scripts/list-runtime-roots.in (lsof-roots): Add 'setvbuf' call for
PIPE.
2017-03-08 23:42:53 +01:00
Leo Famulari
613d0895b9
build: Don't embed absolute paths in .service and .conf service files.
Otherwise, users will be stuck running an old copy of guix and the guix-daemon
if they copy the service files instead of symlinking them.

* etc/guix-daemon.conf.in, etc/guix-daemon.service.in, etc/guix-publish.conf.in,
etc/guix-publish.service.in: Expand @localstatedir@ instead of @bindir@.
* nix/local.mk (etc/guix-%.service, etc/guix-%.conf): Use @localstatedir@
instead of @bindir@.
2017-03-06 13:25:51 -05:00
Efraim Flashner
ab4ccc8fcf
daemon: Ensure proper alignment on the stack.
* nix/libstore/build.cc (startBuilder): When calling 'clone', increase
the step to 16 and ensure it aligns properly on the stack.
2017-02-20 13:09:03 +02:00
Ludovic Courtès
328f7cbe43
daemon: Define 'NIX_STORE' before invoking 'guix perform-download'.
Reported by rohit yadav <rohityadav@utexas.edu>
at <https://lists.gnu.org/archive/html/guix-devel/2017-02/msg00191.html>.

This fixes a regression whereby 'guix perform-download' would always see
NIX_STORE as unset and thus use "/gnu/store", leading it to miscompute
the hydra.gnu.org content-addressed URLs when the store file name is not
"/gnu/store".

* nix/libstore/builtins.cc (builtinDownload): Add 'setenv' call for
'NIX_STORE'.
2017-02-07 14:51:17 +01:00
Ludovic Courtès
deac976d3d
daemon: Client settings no longer override daemon settings.
Fixes <http://bugs.gnu.org/20217>.

* nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump to 0x161.
* nix/nix-daemon/nix-daemon.cc (performOp): "build-max-jobs",
"build-max-silent-time", and "build-cores" are no longer read upfront;
instead, read them from the key/value list at the end.
* nix/nix-daemon/guix-daemon.cc (main): Explicitly set
'settings.maxBuildJobs'.
* guix/store.scm (%protocol-version): Bump to #x161.
(set-build-options): #:max-build-jobs, #:max-silent-time, and
 #:build-cores now default to #f.  Adjust handshake to new protocol.
* tests/store.scm ("build-cores"): New test.
* tests/guix-daemon.sh: Add test for default "build-cores" value.
2017-01-15 15:43:22 +01:00
Ludovic Courtès
9b5364a3af
daemon: Allow check builds of 'builtin:download' derivations.
Fixes <http://bugs.gnu.org/25089>.
Reported by Leo Famulari <leo@famulari.name>.

* nix/libstore/build.cc (DerivationGoal::runChild): In the 'isBuiltin'
case, check whether DRV's output is in 'redirectedOutputs', and pass an
'output' argument to the built-in builder.
(DerivationGoal::addHashRewrite): Add 'printMsg' call.
* nix/libstore/builtins.hh (derivationBuilder): Add 'output' parameter.
* nix/libstore/builtins.cc (builtinDownload): Likewise.
Add OUTPUT to ARGV.
* guix/scripts/perform-download.scm (perform-download): Add 'output'
parameter.
(guix-perform-download): Adjust 'match' clauses accordingly.
* tests/derivations.scm ("'download' built-in builder, check mode"): New
test.
2017-01-11 17:06:31 +01:00
Ludovic Courtès
8ecc3c6c44
daemon: Allow fixed-output derivation builds with TMPDIR set.
Fixes <http://bugs.gnu.org/25242>.
Reported by Leo Famulari <leo@famulari.name>.
The regression was introduced in 94d92c7796.

* nix/libstore/build.cc (DerivationGoal::startBuilder): Set 'useChroot'
as a function 'of isBuiltin(drv)'.
(DerivationGoal::runChild): Use 'useChroot' instead of
'useChroot && !isBuiltin(drv)'.
2016-12-29 18:22:49 +01:00
Ludovic Courtès
b20644ed18
build: Delete all the .service and .conf files upon 'make clean'.
* nix/local.mk (CLEANFILES): Define to add $(nodist_systemdservice_DATA)
and $(nodist_upstartjob_DATA).
2016-12-20 15:14:40 +01:00
Ludovic Courtès
5a5fc61f07
build: Fix .service and .conf targets for VPATH builds.
* nix/local.mk (etc/guix-%.service, etc/guix-%.conf): Use "$<", not
"$(srcdir)/$<".
2016-12-18 17:45:44 +01:00
Ludovic Courtès
fa54f44bb7
build: Add 'guix-publish.*.in' to the distribution.
This is a followup to 332d7903f5.

* nix/local.mk (EXTRA_DIST): Add 'guix-service.publish.in' and
'guix-publish.conf.in'.
2016-12-18 17:45:44 +01:00
Hartmut Goebel
2608e40988
daemon: Set ownership of kept build directories to the calling user.
Fixes <http://bugs.gnu.org/15890>.

* nix/libstore/globals.hh (Settings) Add clientUid and clientGid.
* nix/nix-daemon/nix-daemon.cc (daemonLoop] Store UID and GID of the
  caller in settings.
* nix/libstore/build.cc (_chown): New function.
  (DerivationGoal::deleteTmpDir): Use it, change ownership of build
  directory if it is kept and the new owner is not root.
2016-12-09 15:46:09 +01:00
Ludovic Courtès
638ccde1fb
daemon: Fix invalid Boost format string.
* nix/libstore/optimise-store.cc (LocalStore::optimisePath_): Use %3%
instead of %m, the latter being an invalid Boost format specifier.
2016-12-05 18:18:10 +01:00
Ludovic Courtès
9a8f9f84cc
daemon: Buffer data sent to clients by the 'export-path' RPC.
Before that we'd have STDERR_WRITE round trips for very small amounts of
data, ranging from a few bytes for the metadata of nars to the size of
one file being exported.

With this change, something like:

  guix archive --export /gnu/store/5rrsbaghh5ix1vjcicsl60gsxilhjnf2-coreutils-8.25 | dd of=/dev/null

reports a throughput of 35 MB/s instead of 25 MB/s before.

* nix/nix-daemon/nix-daemon.cc (TunnelSink): Inherit from 'BufferedSink'
rather than 'Sink'.  Rename 'operator ()' to 'write'.
(performOp) <wopExportPath>: Add 'sink.flush' call.
2016-12-01 23:35:10 +01:00
Hartmut Goebel
332d7903f5
Add system start-up files for "guix publish".
* .gitignore: add etc/guix-publish.conf and /etc/guix-publish.service.
* etc/guix-publish.conf.in: New file.
* etc/guix-publish.service.in: New file.
* nix/local.mk (etc/guix-%.service, etc/guix-%.conf): Generalized former
  build-rules for by using patterns.
  (nodist_systemdservice_DATA): Add etc/guix-publish.service, update
  comment.
  (nodist_upstartjob_DATA): Add etc/guix-publish.conf, update comment.
* doc/guix.texi (Invoking guix publish): Add description for enabling
  "guix publish" on host distros using the new files.
2016-11-24 09:23:11 +01:00
Ludovic Courtès
f9aefa2d5f
daemon: Add 'built-in-builders' RPC.
* nix/libstore/builtins.cc (builtinBuilderNames): New function.
* nix/libstore/builtins.hh (builtinBuilderNames): New declaration.
* nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump to 0x160.
(WorkerOp)[wopBuiltinBuilders]: New value.
* nix/nix-daemon/nix-daemon.cc (performOp): Handle it.
* guix/store.scm (operation-id)[built-in-builders]: New value.
* guix/store.scm (read-arg): Add 'string-list'.
(built-in-builders): New procedure.
* tests/derivations.scm ("built-in-builders"): New test.
2016-11-16 18:19:54 +01:00
Ludovic Courtès
94d92c7796
daemon: Add "builtin:download" derivation builder.
This ensures that 1) the derivation doesn't change when Guix changes;
2) the derivation closure doesn't contain Guix and its dependencies; 3)
we don't have to rely on ugly chroot hacks.

Adapted from Nix commit 0a2bee307b20411f5b0dda0c662b1f9bb9e0e131.

* nix/libstore/build.cc (DerivationGoal::runChild): Add special case for
'isBuiltin(drv)'.  Disable chroot when 'isBuiltin(drv)'.
* nix/libstore/builtins.cc, nix/libstore/builtins.hh,
nix/scripts/download.in, guix/scripts/perform-download.scm: New files.
* guix/ui.scm (show-guix-help)[internal?]: Add 'perform-download'.
* nix/local.mk (libstore_a_SOURCES): Add builtins.cc.
(libstore_headers): Add builtins.hh.
(nodist_pkglibexec_SCRIPTS): Add 'scripts/download'.
* config-daemon.ac: Emit 'scripts/download'.
* Makefile.am (MODULES): Add 'guix/scripts/perform-download.scm'.
* tests/derivations.scm ("unknown built-in builder")
("'download' built-in builder")
("'download' built-in builder, invalid hash")
("'download' built-in builder, not found")
("'download' built-in builder, not fixed-output"): New tests.

Co-authored-by: Eelco Dolstra <eelco.dolstra@logicblox.com>
2016-11-16 18:19:47 +01:00
Ludovic Courtès
12b6c951cf
daemon: Do not error out when deduplication fails due to ENOSPC.
This solves a problem whereby if /gnu/store/.links had enough entries,
ext4's directory index would be full, leading to link(2) returning
ENOSPC.

* nix/libstore/optimise-store.cc (LocalStore::optimisePath_): Upon
ENOSPC from link(2), print a message and return instead of throwing a
'SysError'.
2016-10-28 22:30:17 +02:00
Eelco Dolstra
b1fd0ab734
daemon: Improve the SQLite wrapper API.
In particular, this eliminates a bunch of boilerplate code.

Also integrates these Nix commits:

  80da7a6 Probably fix SQLITE_BUSY errors
  37a337b throwSQLiteError(): Check for SIGINT so we don't loop forever

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2016-10-28 22:30:17 +02:00
Eelco Dolstra
7bed5d91de
daemon: Factor out SQLite handling.
* nix/libstore/local-store.cc: Move SQLite code to...
* nix/libstore/sqlite.cc, nix/libstore/sqlite.hh: ... here.  New files.
* nix/local.mk (libstore_a_SOURCES): Add sqlite.cc.
(libstore_headers): Add sqlite.hh.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2016-10-28 22:30:17 +02:00
Eelco Dolstra
517ce0c15b
daemon: Turn retrying SQLite transactions into a higher-order function.
* nix/libstore/local-store.cc (retry_sqlite, end_retry_sqlite): Remove.
(retrySQLite): New template.
(LocalStore::registerFailedPath, LocalStore::hasPathFailed)
(LocalStore::queryFailedPaths, LocalStore::clearFailedPaths)
(LocalStore::queryPathInfo, LocalStore::isValidPath_)
(LocalStore::queryValidPaths, LocalStore::queryAllValidPaths)
(LocalStore::queryReferrers, LocalStore::queryValidDerivers)
(LocalStore::queryDerivationOutputs)
(LocalStore::queryDerivationOutputNames)
(LocalStore::queryPathFromHashPart, LocalStore::registerValidPaths)
(LocalStore::invalidatePathChecked): Use it.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2016-10-28 22:30:17 +02:00
David Craven
9dd674db01
daemon: Rename 'NIX_CONF_DIR' to 'GUIX_CONFIGURATION_DIRECTORY'.
Partly fixes <http://bugs.gnu.org/22459>.
Reported by Jeff Mickey <j@codemac.net> and David Craven <david@craven.ch>.

* nix/libstore/globals.cc (Settings::processEnvironment()): Change
'NIX_CONF_DIR' to 'GUIX_CONFIGURATION_DIRECTORY'.
* nix/local.mk (libstore_a_CPPFLAGS): Likewise.
* guix/config.scm.in (%config-directory): Likewise.
* build-aux/test-env.in: Likewise.
* gnu/packages/patches/hydra-automake-1.15.patch: Likewise.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2016-06-26 23:11:07 +02:00
Ludovic Courtès
151afd84dc
daemon: Substitute queries return immediately when substitutes are disabled.
Reported by Federico Beffa <beffa@ieee.org>
at <https://lists.gnu.org/archive/html/guix-devel/2016-05/msg00928.html>.

* nix/libstore/local-store.cc (LocalStore::querySubstitutablePaths)
(LocalStore::querySubstitutablePathInfos): Return when
'settings.useSubstitutes' is false.
* tests/store.scm ("references/substitutes missing reference info"):
Make sure to return #f on failure.
* tests/store.scm ("substitutable-path-info when substitutes are turned off"):
("substitutable-paths when substitutes are turned off"): New tests.
2016-05-31 18:22:14 +02:00
Ludovic Courtès
4078fa8f72
daemon: Fix typo.
Fixes a regression/typo introduced in
e08380fb6c.

* nix/libstore/build.cc (DerivationGoal::startBuilder): Canonicalize
"/tmp", not "/tmp/guix-build".
2016-05-31 18:22:14 +02:00
Ludovic Courtès
75abbd0cbe
daemon: Remove unused XML output code.
* nix/local.mk (libutil_a_SOURCES): Remove libutil/xml-writer.cc.
(libutil_headers): Remove libutil/xml-writer.hh.
* nix/libutil/xml-writer.hh, nix/libutil/xml-writer.cc: Remove.
2016-05-31 18:22:14 +02:00
Eelco Dolstra
b4528110c6
daemon: rounds: Keep the differing output if -K is given.
Regardless of -K, we now also print which output differs.
2016-05-31 14:25:28 +02:00
Eelco Dolstra
56b8f56788
daemon: Canonicalize gids to 0.
Previously files in the Nix store were owned by root or by nixbld,
depending on whether they were created by a substituter or by a
builder. This doesn't matter much, but causes spurious diffoscope
differences. So use root everywhere.
2016-05-31 14:25:28 +02:00
Eelco Dolstra
7f3b2510d6
daemon: check: Keep the differing output if -K is given.
This makes it easier to investigate the non-determinism, e.g.

  $ nix-build pkgs/stdenv/linux -A stage1.pkgs.zlib --check -K
  error: derivation ‘/nix/store/l54i8wlw22656i4pk05c52ngv9rpl39q-zlib-1.2.8.drv’ may not be deterministic: output ‘/nix/store/11a27shh6n2ivi4a7s964i65ql80cf27-zlib-1.2.8’ differs from ‘/nix/store/11a27shh6n2ivi4a7s964i65ql80cf27-zlib-1.2.8-check’

  $ diffoscope /nix/store/11a27shh6n2ivi4a7s964i65ql80cf27-zlib-1.2.8 /nix/store/11a27shh6n2ivi4a7s964i65ql80cf27-zlib-1.2.8-check
  ...
  ├── lib/libz.a
  │   ├── metadata
  │   │ @@ -1,15 +1,15 @@
  │   │ -rw-r--r-- 30001/30000   3096 Jan 12 15:20 2016 adler32.o
  ...
  │   │ +rw-r--r-- 30001/30000   3096 Jan 12 15:28 2016 adler32.o
  ...

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2016-05-31 14:25:28 +02:00
Eelco Dolstra
7889e72dad
daemon: check: Fix "failed to produce output path".
This occured when sandbox building is disabled, at least one output
exists, and at least one other output does not.
2016-05-31 14:25:28 +02:00
Eelco Dolstra
f83e82cd00
daemon: check: Fix assertion failure when some outputs are missing.
E.g.

  $ nix-build pkgs/stdenv/linux/ -A stage1.pkgs.perl --check
  nix-store: src/libstore/build.cc:1323: void nix::DerivationGoal::tryToBuild(): Assertion `buildMode != bmCheck || validPaths.size() == drv->outputs.size()' failed.

when perl.out exists but perl.man doesn't. The fix is to only check
the outputs that exist. Note that "nix-build -A stage1.pkgs.all
--check" will still give a (proper) error in this case.
2016-05-31 14:25:28 +02:00
Eelco Dolstra
c56cd90cc9
daemon: When repairing, rebuild if there is no substituter. 2016-05-31 14:25:28 +02:00
Eelco Dolstra
1a9574e3a7
daemon: Fix --repair failure on multiple-output derivations.
If repair found a corrupted/missing path that depended on a
multiple-output derivation, and some of the outputs of the latter were
not present, it failed with a message like

  error: path ‘/nix/store/cnfn9d5fjys1y93cz9shld2xwaibd7nn-bash-4.3-p42-doc’ is not valid

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2016-05-31 14:25:28 +02:00
Eelco Dolstra
63a5be07e2
daemon: ~PathLocks(): Handle exceptions.
Otherwise, since the call to write a "d" character to the lock file
can fail with ENOSPC, we can get an unhandled exception resulting in a
call to terminate().
2016-05-31 14:25:28 +02:00
Eelco Dolstra
e08380fb6c
daemon: Handle /tmp being a symlink.
* nix/libstore/build.cc (DerivationGoal::startBuilder): Call 'canonPath'
on "/tmp".
2016-05-31 14:25:28 +02:00
Mathieu Lirzin
c0d2e7b197
build: Use "%D%" in Makefile fragments.
* doc/local.mk: Use "%D%" for the directory of the fragment relative to
the base 'Makefile.am'.
* emacs/local.mk: Likewise.
* gnu/local.mk: Likewise.
* nix/local.mk: Likewise.
2016-05-24 13:07:19 +02:00
Mathieu Lirzin
03d0e2d2b9 build: Move 'Makefile' fragments to subdirectories.
This follows a convention used by some other GNU packages like Autoconf,
Bison, Coreutils, and Gnulib.

* doc.am: Rename to ...
* doc/local.mk: ... this.
* emacs.am: Rename to ...
* emacs/local.mk: ... this.
* gnu-system.am: Rename to ...
* gnu/local.mk: ... this.
* daemon.am: Rename to ...
* nix/local.mk: ... this.
* Makefile.am: Adapt to them.
* doc/guix.texi (Porting to a New Platform): Adapt documentation.
* guix/config.scm.in (%state-directory, %config-directory): Adapt comments.
* emacs/guix-config.el.in (guix-config-state-directory): Likewise.
2016-04-21 18:47:50 +02:00
Ludovic Courtès
df061d079b build: Default to "https://mirror.hydra.gnu.org/" for substitutes.
* config-daemon.ac: Check for (gnutls) and define 'GUIX_SUBSTITUTE_URLS'.
* nix/nix-daemon/guix-daemon.cc (main): Use GUIX_SUBSTITUTE_URLS.
* guix/store.scm (%default-substitute-urls): Use 'https' when (gnutls)
is available.
* doc/guix.texi (Binary Installation): Mention mirrors
(Invoking guix-daemon): Mention mirror.hydra.gnu.org.
(Substitutes): Mention mirrors.
(Invoking guix archive): Show https URLs.
2016-03-16 11:27:37 +01:00
Ludovic Courtès
7a57c96a10 daemon: Build in /tmp/guix-build-*.
* nix/libstore/build.cc (DerivationGoal::startBuilder): Use "guix-build"
instead of "nix-build" for TMPDIR.
* doc/guix.texi (Build Environment Setup): Adjust accordingly.
2015-12-30 18:01:01 +01:00
Ludovic Courtès
20b978192e daemon: Remove unused 'RemoteStore' class.
* nix/libstore/remote-store.cc, nix/libstore/remote-store.hh: Remove.
* nix/libstore/store-api.cc (readStorePath, readStorePaths): New
functions, formerly in remote-store.cc.
(openStore): Remove reference to 'RemoteStore'.
* daemon.am (libstore_a_SOURCES): Remove remote-store.cc.
(libstore_headers): Remote remote-store.hh.
2015-12-30 01:20:41 +01:00
Ludovic Courtès
ecf84b7c48 daemon: Add '--rounds'.
* nix/nix-daemon/guix-daemon.cc (GUIX_OPT_BUILD_ROUNDS): New macro.
(options): Add --rounds.
(parse_opt): Honor it.
* doc/guix.texi (Invoking guix-daemon): Document it.
2015-12-13 19:20:01 +01:00
Eelco Dolstra
f3ff1da424 daemon: Better distinguish build statuses.
In Nix itself, the new 'BuildResult' type is returned by the new
'buildDerivation' method, which we don't have and need.

* nix/libstore/build.cc (Goal)[cancel]: Remove.
[timeOut]: New pure virtual method.
(DerivationGoal)[result]: New field.
[cancel]: Remove.
[timedOut, getResult, done]: New methods.
(DerivationGoal::cancel): Remove.
(DerivationGoal::timedOut): New method.
(DerivationGoal::haveDerivation): Call 'done' instead of 'amDone'.
(DerivationGoal::outputsSubstituted): Ditto.
(DerivationGoal::inputsRealised): Ditto.
(DerivationGoal::buildDone): Ditto.
(DerivationGoal::handleChildOutput): Call 'timedOut' instead of
'cancel'.
(DerivationGoal::done): New method.
(SubstitutionGoal)[cancel]: Remove.
[timedOut]: New method.
(SubstitutionGoal::cancel): Remove.
(SubstitutionGoal::timedOut): New method.
(Worker::waitForInput): Use it.
* nix/libstore/store-api.hh (BuildResult): New struct.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2015-12-13 19:20:01 +01:00
Eelco Dolstra
cb9601029e daemon: Use deterministic $TMPDIR in chroot.
Rather than using $<host-TMPDIR>/nix-build-<drvname>-<number>, the
temporary directory is now always /tmp/nix-build-<drvname>-0. This
improves bitwise-exact reproducibility for builds that store $TMPDIR
in their build output. (Of course, those should still be fixed...)

* nix/libstore/build.cc (DerivationGoal)[tmpDirInSandbox]: New field.
(DerivationGoal::startBuilder): Initialize 'useChroot' earlier.  Compute
'tmpDirInSandbox', and use it when populating 'dirsInChroot'.
* doc/guix.texi (Build Environment Setup): Document it.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2015-12-09 14:29:41 +01:00
Eelco Dolstra
b23b4d394a daemon: Allow builds to be repeated.
This makes it easy to detect non-deterministic builds.

* nix/libstore/build.cc (DerivationGoal): Remove 'InodesSeen'; add
'curRound', 'nrRound', and 'prevInfos'.
(DerivationGoal::inputsRealised): Initialize 'nrRound'.
(NotDeterministic): New error type.
(DerivationGoal::buildDone): Check whether we need to repeat.
(DerivationGoal::startBuilder): Adjust message.
(DerivationGoal::registerOutputs): Check whether we get the same result.
* nix/libstore/globals.cc (Settings::get(const string & name, int def)):
New method.
* nix/libstore/globals.hh (Settings): Add it.
* nix/libstore/store-api.hh (ValidPathInfo): Add operator ==.
* nix/nix-daemon/nix-daemon.cc (performOp): Allow "build-repeat" for
"untrusted" users.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2015-12-08 23:58:12 +01:00
Ludovic Courtès
708d907000 daemon: Add 'buildMode' parameter to 'buildPaths' RPC.
* nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump to 0x10f.
* nix/libstore/remote-store.cc (RemoteStore::buildPaths): Send the
BUILDMODE when the daemon supports it.  Reject invalid values of
BUILDMODE for old daemons.
* nix/nix-daemon/nix-daemon.cc (performOp) <wopBuildPaths>: Read the
build mode when the client supports it.
2015-12-02 19:37:59 +02:00
Eelco Dolstra
e134baae77 daemon: optimizePath: Detect some .links corruptions.
If automatic store optimisation is enabled, and a hard-linked file in
the store gets corrupted, then the corresponding .links entry will
also be corrupted. In that case, trying to repair with --repair or
--repair-path won't work, because the new "good" file will be replaced
by a hard link to the corrupted file. We can catch most of these cases
by doing a sanity-check on the file sizes.
2015-12-02 19:37:59 +02:00
Eelco Dolstra
14fb686a21 daemon: Fix namespace issue. 2015-12-02 19:37:59 +02:00
Eelco Dolstra
29d3242e5c daemon: Support SHA-512 hashes.
Fixes #679.

Note: on x86_64, SHA-512 is considerably faster than SHA-256 (198 MB/s
versus 131 MB/s).

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2015-12-02 19:37:59 +02:00
Eelco Dolstra
79aa1a8305 daemon: int2String -> std::to_string. 2015-12-02 19:37:59 +02:00
Eelco Dolstra
60c7c364f8 daemon: Filter build-chroot-dirs entries that conflict with derivation outputs.
Fixes https://github.com/NixOS/nixpkgs/issues/9504.

Note that this means we may have a non-functional /bin/sh in the
chroot while rebuilding Bash or one of its dependencies. Ideally those
packages don't rely on /bin/sh though.
2015-12-02 19:37:59 +02:00