aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build.cc
AgeCommit message (Collapse)Author
2012-09-19Remove setting of the immutable bitEelco Dolstra
Using the immutable bit is problematic, especially in conjunction with store optimisation. For instance, if the garbage collector deletes a file, it has to clear its immutable bit, but if the file has additional hard links, we can't set the bit afterwards because we don't know the remaining paths. So now that we support having the entire Nix store as a read-only mount, we may as well drop the immutable bit. Unfortunately, we have to keep the code to clear the immutable bit for backwards compatibility.
2012-09-19Templatise tokenizeString()Eelco Dolstra
2012-09-18Keep build directory if not all expected outputs were producedEelco Dolstra
Fixes issue #123 in Nixpkgs.
2012-09-13In startBuilder(), only print the new paths we're buildingEelco Dolstra
2012-09-12Build hook: Pass the timeout to the remote builderEelco Dolstra
Note that this will only work if the client has a very recent Nix version (post 15e1b2c223494ecb5efefc3ea0e3b926a6b1d7dc), otherwise the --option flag will just be ignored. Fixes #50.
2012-09-11Fix "non-zero padding" errorEelco Dolstra
Probably it's not a good idea to pass a temporary object to StringSource.
2012-09-11Support building a derivation if some outputs are already valid (non-chroot ↵Eelco Dolstra
case) This uses scary hash rewriting. Fixes #21.
2012-09-11Remove debug lineEelco Dolstra
2012-09-11Support building a derivation if some outputs are already validEelco Dolstra
This handles the chroot and build hook cases, which are easy. Supporting the non-chroot-build case will require more work (hash rewriting!). Issue #21.
2012-08-27Fix stupid type error in calling std::maxEelco Dolstra
2012-08-27Merge branch 'master' into no-manifestsEelco Dolstra
2012-08-20Check if MS_PRIVATE is definedEelco Dolstra
http://hydra.nixos.org/build/2955671
2012-08-20In the chroot, make all mounted filesystems privateEelco Dolstra
This is required on systemd, which mounts filesystems as "shared" subtrees. Changes to shared trees in a private mount namespace are propagated to the outside world, which is bad.
2012-08-20Don't bind-mount /proc since we mount our ownEelco Dolstra
2012-08-19Fix 1755 permission on temporary directories left behind by ‘-K’Eelco Dolstra
2012-08-01Drop the block count in the garbage collectorEelco Dolstra
2012-07-30Refactor settings processingEelco Dolstra
Put all Nix configuration flags in a Settings object.
2012-07-30Pass configuration settings to the substitutersEelco Dolstra
Previously substituters could read nix.conf themselves, but this didn't take --option flags into account.
2012-07-27Let build.cc verify the expected hash of a substituter's outputEelco Dolstra
Since SubstitutionGoal::finished() in build.cc computes the hash anyway, we can prevent the inefficiency of computing the hash twice by letting the substituter tell Nix about the expected hash, which can then verify it.
2012-07-27Remove more tabsEelco Dolstra
2012-07-27Remove trailing whitespace / tabsEelco Dolstra
2012-07-26Merge branch 'master' into no-manifestsEelco Dolstra
2012-07-26Set permissions on temporary build directories to 0700Eelco Dolstra
Fixes #39.
2012-07-23Automatically optimise the Nix store when a new path is addedEelco Dolstra
Auto-optimisation is enabled by default. It can be turned off by setting auto-optimise-store to false in nix.conf.
2012-07-18Merge branch 'master' into no-manifestsEelco Dolstra
2012-07-17Return an exit code of 100 for cached failed buildsEelco Dolstra
Exit code 100 should be returned for all permanent failures. This includes cached failures. Fixes #34.
2012-07-17Update Nix 1.1 release notesEelco Dolstra
2012-07-17Allow disabling log compressionEelco Dolstra
2012-07-08build.cc: Don't use hasSubstitute()Eelco Dolstra
Instead make a single call to querySubstitutablePathInfo() per derivation output. This is faster and prevents having to implement the "have" function in the binary cache substituter.
2012-07-06download-from-binary-cache: parallelise fetching of NAR info filesEelco Dolstra
Getting substitute information using the binary cache substituter has non-trivial latency overhead. A package or NixOS system configuration can have hundreds of dependencies, and in the worst case (when the local info cache is empty) we have to do a separate HTTP request for each of these. If the ping time to the server is t, getting N info files will take tN seconds; e.g., with a ping time of 0.1s to nixos.org, sequentially downloading 1000 info files (a typical NixOS config) will take at least 100 seconds. To fix this problem, the binary cache substituter can now perform requests in parallel. This required changing the substituter interface to support a function querySubstitutablePathInfos() that queries multiple paths at the same time, and rewriting queryMissing() to take advantage of parallelism. (Due to local caching, parallelising queryMissing() is sufficient for most use cases, since it's almost always called before building a derivation and thus fills the local info cache.) For example, parallelism speeds up querying all 1056 paths in a particular NixOS system configuration from 116s to 2.6s. It works so well because the eccentricity of the top-level derivation in the dependency graph is only 9. So we only need 10 round-trips (when using an unlimited number of parallel connections) to get everything. Currently we do a maximum of 150 parallel connections to the server. Thus it's important that the binary cache server (e.g. nixos.org) has a high connection limit. Alternatively we could use HTTP pipelining, but WWW::Curl doesn't support it and libcurl has a hard-coded limit of 5 requests per pipeline.
2012-06-27nix-store -r: do substitutions in parallelEelco Dolstra
I.e. when multiple non-derivation arguments are passed to ‘nix-store -r’ to be substituted, do them in parallel.
2012-06-27Mount an empty /dev/shm tmpfs in the chrootEelco Dolstra
This ensures that whatever the builder writes in /dev/shm is automatically cleaned up.
2012-06-27Check the return code of the clone() callEelco Dolstra
2012-06-25When using chroots, use a private PID namespaceEelco Dolstra
In a private PID namespace, processes have PIDs that are separate from the rest of the system. The initial child gets PID 1. Processes in the chroot cannot see processes outside of the chroot. This improves isolation between builds. However, processes on the outside can see processes in the chroot and send signals to them (if they have appropriate rights). Since the builder gets PID 1, it serves as the reaper for zombies in the chroot. This might turn out to be a problem. In that case we'll need to have a small PID 1 process that sits in a loop calling wait().
2012-06-25Use a private UTS namespace to provide a deterministic host/domain name to ↵Eelco Dolstra
builders In chroot builds, set the host name to "localhost" and the domain name to "(none)" (the latter being the kernel's default). This improves determinism a bit further. P.S. I have to idea what UTS stands for.
2012-06-23Improve error messageEelco Dolstra
2012-06-23In chroot builds, use a private SysV IPC namespaceEelco Dolstra
This improves isolation a bit further, and it's just one extra flag in the unshare() call. P.S. It would be very cool to use CLONE_NEWPID (to put the builder in a private PID namespace) as well, but that's slightly more risky since having a builder start as PID 1 may cause problems.
2012-06-23In chroot builds, use a private network namespaceEelco Dolstra
On Linux it's possible to run a process in its own network namespace, meaning that it gets its own set of network interfaces, disjunct from the rest of the system. We use this to completely remove network access to chroot builds, except that they get a private loopback interface. This means that: - Builders cannot connect to the outside network or to other processes on the same machine, except processes within the same build. - Vice versa, other processes cannot connect to processes in a chroot build, and open ports/connections do not show up in "netstat". - If two concurrent builders try to listen on the same port (e.g. as part of a test), they no longer conflict with each other. This was inspired by the "PrivateNetwork" flag in systemd.
2012-05-30Compress build logs on the fly using bzip2Eelco Dolstra
2012-05-29Add option ‘build-keep-log’ to enable/disable writing of build logsEelco Dolstra
Fixes #26.
2012-04-30* Add an option ‘build-use-substitutes’, which can be set to ‘false’Eelco Dolstra
to disable use of substitutes; i.e., force building from source. Fixes Nix/221.
2012-04-30Handle EPERM when creating a hard link for the chrootEelco Dolstra
There is a race condition when doing parallel builds with chroots and the immutable bit enabled. One process may call makeImmutable() before the other has called link(), in which case link() will fail with EPERM. We could retry or wrap the operation in a lock, but since this condition is rare and I'm lazy, we just use the existing copy fallback. Fixes #9.
2012-04-15Close almost all file descriptors in the builderEelco Dolstra
This regression was accidentally introduced in 35355fc1fcffbe859395e360c0a6a1463f137d63.
2012-04-05On Linux, pretend we're building on Linux 2.6Eelco Dolstra
Setting the UNAME26 personality causes "uname" to return "2.6.x", regardless of the kernel version. This improves determinism in a few misbehaved packages.
2012-03-05Set the close-on-exec flag on file descriptorsEelco Dolstra
2012-03-05Don't leak a file descriptor in commonChildInit()Eelco Dolstra
2012-03-01Fix an uninitialised variableEelco Dolstra
The variable ‘useChroot’ was not initialised properly. This caused random failures if using the build hook. Seen on Mac OS X 10.7 with Clang. Thanks to KolibriFX for finding this :-)
2012-02-18Fix chroots buildsEelco Dolstra
Chroots are initialised by hard-linking inputs from the Nix store to the chroot. This doesn't work if the input has its immutable bit set, because it's forbidden to create hard links to immutable files. So temporarily clear the immutable bit when creating and destroying the chroot. Note that making regular files in the Nix store immutable isn't very reliable, since the bit can easily become cleared: for instance, if we run the garbage collector after running ‘nix-store --optimise’. So maybe we should only make directories immutable.
2012-02-09Use data() instead of c_str() where appropriateEelco Dolstra
2011-12-30* Reject a build if there is a cycle among the outputs. This isEelco Dolstra
necessary because existing code assumes that the references graph is acyclic.