aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2012-08-01nix-env: Ignore manifest.nix when recursing into ~/.nix-defexprEelco Dolstra
Channels are implemented using a profile now, and profiles contain a manifest.nix file. This should be ignored to prevent bogus packages from showing up in nix-env.
2012-08-01Report substituter errors to clients of the Nix daemonEelco Dolstra
2012-07-31Prevent an injection attack in passing untrusted options to substitutersEelco Dolstra
2012-07-31Pass all --option flags to the daemonEelco Dolstra
2012-07-31Add an option ‘build-fallback’ (equivalent to the --fallback flag)Eelco Dolstra
2012-07-30Refactor settings processingEelco Dolstra
Put all Nix configuration flags in a Settings object.
2012-07-30WhitespaceEelco Dolstra
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-30Remove unused variablesEelco Dolstra
2012-07-30Fix whitespaceEelco Dolstra
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-26Fix the substituter testsEelco 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-25prim_import: When importing .drvs, allocate the intermediate attrset on the ↵Shea Levy
heap just in case it escapes the stack frame.
2012-07-25import: If the path is a valid .drv file, parse it and generate a derivation ↵Shea Levy
attrset. The generated attrset has drvPath and outPath with the right string context, type 'derivation', outputName with the right name, all with a list of outputs, and an attribute for each output. I see three uses for this (though certainly there may be more): * Using derivations generated by something besides nix-instantiate (e.g. guix) * Allowing packages provided by channels to be used in nix expressions. If a channel installed a valid deriver for each package it provides into the store, then those could be imported and used as dependencies or installed in environment.systemPackages, for example. * Enable hydra to be consistent in how it treats inputs that are outputs of another build. Right now, if an input is passed as an argument to the job, it is passed as a derivation, but if it is accessed via NIX_PATH (i.e. through the <> syntax), then it is a path that can be imported. This is problematic because the build being depended upon may have been built with non-obvious arguments passed to its jobset file. With this feature, hydra can just set the name of that input to the path to its drv file in NIX_PATH
2012-07-23Handle platforms that don't support linking to a symlinkEelco Dolstra
E.g. Darwin doesn't allow this.
2012-07-23Unlink the right fileEelco Dolstra
2012-07-23Garbage collect unused links in /nix/store/.linksEelco Dolstra
Incremental optimisation requires creating links in /nix/store/.links to all files in the store. However, this means that if we delete a store path, no files are actually deleted because links in /nix/store/.links still exists. So we need to check /nix/store/.links for files with a link count of 1 and delete them.
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-23optimiseStore(): Use a content-addressed file store in /nix/store/.linksEelco Dolstra
optimiseStore() now creates persistent, content-addressed hard links in /nix/store/.links. For instance, if it encounters a file P with hash H, it will create a hard link P' = /nix/store/.link/<H> to P if P' doesn't already exist; if P' exist, then P is replaced by a hard link to P'. This is better than the previous in-memory map, because it had the tendency to unnecessarily replace hard links with a hard link to whatever happened to be the first file with a given hash it encountered. It also allows on-the-fly, incremental optimisation.
2012-07-23Use lutimes() if available to canonicalise the timestamp of symlinksEelco Dolstra
Also use utimes() instead of utime() if lutimes() is not available.
2012-07-18Use "#pragma once" to prevent repeated header file inclusionEelco Dolstra
2012-07-18Merge branch 'master' into no-manifestsEelco Dolstra
2012-07-17Add function queryPathFromHashPart()Eelco Dolstra
To implement binary caches efficiently, Hydra needs to be able to map the hash part of a store path (e.g. "gbg...zr7") to the full store path (e.g. "/nix/store/gbg...kzr7-subversion-1.7.5"). (The binary cache mechanism uses hash parts as a key for looking up store paths to ensure privacy.) However, doing a search in the Nix store for /nix/store/<hash>* is expensive since it requires reading the entire directory. queryPathFromHashPart() prevents this by doing a cheap database lookup.
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-17Remove dead codeEelco Dolstra
2012-07-17Update Nix 1.1 release notesEelco Dolstra
2012-07-17Allow disabling log compressionEelco Dolstra
2012-07-12builtins.storePath: resolve symlinksEelco Dolstra
Needed for Charon/Hydra interaction.
2012-07-11Update the other substitutersEelco Dolstra
2012-07-11Replace hasSubstitutes() with querySubstitutablePaths()Eelco Dolstra
querySubstitutablePaths() takes a set of paths, so this greatly reduces daemon <-> client latency.
2012-07-11Add a function queryValidPaths()Eelco Dolstra
queryValidPaths() combines multiple calls to isValidPath() in one. This matters when using the Nix daemon because it reduces latency. For instance, on "nix-env -qas \*" it reduces execution time from 5.7s to 4.7s (which is indistinguishable from the non-daemon case).
2012-07-11Rename queryValidPaths() to queryAllValidPaths()Eelco Dolstra
2012-07-11Implement querySubstitutablePathInfos() in the daemonEelco Dolstra
Also removed querySubstitutablePathInfo().
2012-07-11nix-env: Determine which paths have substitutes in parallelEelco Dolstra
2012-07-09prim_import(): prefetch substitute info in parallel using queryMissing()Eelco 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-06-18Support socket-based, on-demand activation of the Nix daemon with systemdEelco Dolstra
Systemd can start the Nix daemon on demand when the Nix daemon socket is first accessed. This is signalled through the LISTEN_FDS environment variable, so all we need to do is check for that and then use file descriptor 3 as the listen socket instead of creating one ourselves.