Commit graph

227 commits

Author SHA1 Message Date
Eelco Dolstra
5d4171f7fb * Synchronise terminology with the ICSE paper (e.g., slice -> closure,
fstate -> Nix expression).
* Fix src/test.cc.
2003-10-07 12:27:49 +00:00
Eelco Dolstra
e78f753aa8 * Include the right files in a distribution. 2003-10-02 12:22:19 +00:00
Eelco Dolstra
4193d62e08 * Nix now respects $TMPDIR for the creation of temporary build directories.
* Retry creation of a temporary directory (with a different name) in the 
  case of EEXIST.
2003-10-02 11:55:38 +00:00
Eelco Dolstra
1c7d6bf5fc * Removed references to char_traits so that boost/format also works on
GCC 2.95.
2003-09-11 10:23:55 +00:00
Eelco Dolstra
d930a9bc5a * Added some missing #includes. 2003-09-11 08:31:29 +00:00
Eelco Dolstra
803a924b77 * Make nicer dot graphs. Also show the inner structure of slices. 2003-09-03 14:49:58 +00:00
Eelco Dolstra
c0bbed0959 * Factored out dot graph generation into a separate file. 2003-09-03 11:20:18 +00:00
Eelco Dolstra
0d2bc68681 * Do not show the output of the builder unless the verbosity is at
least at debug level (-vvv).  The output is still appended to the 
  build log in /nix/var/log/nix.
2003-08-29 13:12:30 +00:00
Eelco Dolstra
b018517314 * Do not try to remove write permission from symlinks, since chmod()
follows symlinks.  (Note that the permissions on symlinks are
  ignored anyway.)
2003-08-28 10:51:14 +00:00
Eelco Dolstra
31be53cd0a * Fix the atrocious (exponential? factorial?) time complexity in
`nix --query --requisites'.
2003-08-25 14:56:11 +00:00
Eelco Dolstra
a88144215c * Remove write permission from output paths after they have been built.
* Point $HOME to a non-existing path when building to prevent certain tools (such as 
  wget) from falling back on /etc/passwd to locate the home directory (which we 
  don't want them to look at since it's not declared as an input).
2003-08-22 20:12:44 +00:00
Eelco Dolstra
956801fcc2 * Use maps and sets in the FState data type. This ensures normalisation of
slices and derivations w.r.t. order of paths, slice elements, etc.
2003-08-20 14:11:40 +00:00
Eelco Dolstra
624c48260f * Change the abstract syntax of slices. It used to be that ids were used as
keys to reference slice elements, e.g.,

    Slice(["1ef7..."], [("/nix/store/1ef7...-foo", "1ef7", ["8c99..."]), ...])

  This was wrong, since ids represent contents, not locations.  Therefore we
  now have:

    Slice(["/nix/store/1ef7..."], [("/nix/store/1ef7...-foo", "1ef7", ["/nix/store/8c99-..."]), ...])

* Fix a bug in the computation of slice closures that could cause slice
  elements to be duplicated.
2003-08-20 12:39:56 +00:00
Eelco Dolstra
ed0db2e0d8 * Fixed a serious bug in the computation of slices. Sometimes the slices
would not be properly closed under the path reference relation.
2003-08-20 11:30:45 +00:00
Eelco Dolstra
1472cc4825 * Pipe /dev/null into stdin. 2003-08-19 13:07:38 +00:00
Eelco Dolstra
2de8504791 * Delete the temporary directories of failed builds by default, and an
option `--keep-failed' to override this behaviour.
2003-08-19 09:04:47 +00:00
Eelco Dolstra
31e4aa6439 * Allow lists in package bindings, e.g.,
("srcs", [Relative("foo/bar.c"), Relative("foo/baz.h")])

  The result is an environment variable that contains the path names of the
  inputs separated by spaces (so this is not safe for values containing
  spaces).
2003-08-18 16:32:55 +00:00
Eelco Dolstra
ebbb6ce578 * Most shells initialise PATH to some default (/bin:/usr/bin:...)
when PATH is not set.  We don't want this, so fill it in with
  some dummy value.
2003-08-18 14:54:54 +00:00
Eelco Dolstra
96c7b98bf0 * Argument support in Fix. Arguments can be passed through the
builder using the `args' binding:

  ("args", ["bla", True, IncludeFix("aterm/aterm.fix")])

  Note that packages can also be declared as inputs by specifying them
  in the argument list.
2003-08-15 13:01:45 +00:00
Eelco Dolstra
555347744d * Derivation expressions now can specify arguments to be passed to the
builder.  Note that this unfortunately causes all Fix-computed
  hashes to change.
2003-08-15 12:32:37 +00:00
Eelco Dolstra
163db7367f * Fix can now read expressions from stdin (by saying `fix -'). 2003-08-15 09:21:19 +00:00
Eelco Dolstra
dc0ef2ca98 * Detect infinite loops using blackholing. 2003-08-14 12:37:31 +00:00
Eelco Dolstra
5cde23f869 * Function() takes a list of formals. 2003-08-14 09:49:31 +00:00
Eelco Dolstra
0a2de7f543 * Lam -> Function. Doh! 2003-08-14 09:29:07 +00:00
Eelco Dolstra
c602930e08 * deletePath(): some operating systems (e.g., Mac OS X) don't like it
when we delete entries from a directory while we are reading it.
  So read the directory into memory, then delete its contents.
2003-08-08 14:55:56 +00:00
Eelco Dolstra
236eb59293 * Allow locks on paths to be acquired recursively (that is, if the
process is already holding a lock on a path, it may acquire the lock
  again without blocking or failing).  (This might be dangerous, not
  sure).  Necessary for fast builds to work.
2003-08-06 09:34:04 +00:00
Eelco Dolstra
720f06e3b0 * A flag `--flat' to just compute the MD5 checksum of the contents of
a regular file.  I.e., `nix-hash --flat' is equivalent to the
  coreutils `md5sum' command (which doesn't exist on all systems).
2003-08-06 09:06:32 +00:00
Eelco Dolstra
37483672d4 * App -> Call.
* Allow booleans in package environment bindings (True maps to "1",
  False maps to "").
2003-08-06 09:05:04 +00:00
Eelco Dolstra
d34b4d4f28 * Conditionals. 2003-08-05 13:05:30 +00:00
Eelco Dolstra
4ce652640b * Cache result of fstatePaths(). TODO: do this in fstore.cc. 2003-08-05 12:29:47 +00:00
Eelco Dolstra
17f05dba77 * Allow the top-level expression to be a list of expressions that
normalise to Nix expression.
2003-08-05 11:13:38 +00:00
Eelco Dolstra
d6b6b2d3a8 * Delete obstructed paths prior to building. 2003-08-05 09:47:20 +00:00
Eelco Dolstra
d2e963f7a3 * Path locking in addToStore() and expandPath(). 2003-08-04 07:09:36 +00:00
Eelco Dolstra
c95b4ad290 * In normaliseFState(), wrap registration of the output paths and the
normal form in a single transaction to ensure that if we crash,
  either everything is registered or nothing is.  This is for
  recoverability: unregistered paths in the store can be deleted
  arbitrarily, while registered paths can only be deleted by running
  the garbage collector.
2003-08-01 15:41:47 +00:00
Eelco Dolstra
d99d04e644 * Defensive programming against POSIX locking idiocy.
* Simplified realiseSlice().
2003-08-01 15:06:23 +00:00
Eelco Dolstra
545145cd58 * normaliseFState() now locks all output paths prior to building, thus
ensuring that simultaneous invocations of Nix don't clobber
  each other's  builds.

* Fixed a bug in `make install'.
2003-08-01 14:11:19 +00:00
Eelco Dolstra
9df93f30bd * Don't use substitutes in addToStore(). 2003-08-01 09:01:51 +00:00
Eelco Dolstra
06434072e7 * Put the database verifier in a transaction. 2003-07-31 19:49:11 +00:00
Eelco Dolstra
06d3d7355d * Enclose most operations that update the database in transactions.
* Open all database tables (Db objects) at initialisation time, not
  every time they are used.  This is necessary because tables have to
  outlive all transactions that refer to them.
2003-07-31 16:05:35 +00:00
Eelco Dolstra
177a7782ae * Use a more reasonable log file size (256 KB instead of 10 MB).
* Checkpoint on exit.
2003-07-31 14:28:49 +00:00
Eelco Dolstra
4a013962bd * Started using Berkeley DB environments. This is necessary for
transaction support (but we don't actually use transactions yet).
2003-07-31 13:47:13 +00:00
Eelco Dolstra
758bd4673a * Set execute bit. 2003-07-31 13:13:27 +00:00
Eelco Dolstra
83075304e5 * Don't make the builder executable. 2003-07-30 09:49:47 +00:00
Eelco Dolstra
8846465934 * Get garbage collection and cache population to work *properly*.
Renamed `fstateRefs' to `fstateRequisites'.  The semantics of this
  function is that it returns a list of all paths necessary to realise
  a given expression.  For a derive expression, this is the union of
  requisites of the inputs; for a slice expression, it is the path of
  each element in the slice.  Also included are the paths of the
  expressions themselves.  Optionally, one can also include the
  requisites of successor expressions (to recycle intermediate
  results).

* `nix-switch' now distinguishes between an expression and its normal
  form.  Usually, only the normal form is registered as a root of the
  garbage collector.  With the `--source-root' flag, it will also
  register the original expression as a root.

* `nix-collect-garbage' now has a flag `--keep-successors' which
  causes successors not to be included in the list of garbage paths.

* `nix-collect-garbage' now has a flag `--invert' which will print all
  paths that should *not* be garbage collected.
2003-07-29 14:28:17 +00:00
Eelco Dolstra
dc14a3de46 * Nicer dot graphs. 2003-07-29 10:53:27 +00:00
Eelco Dolstra
79ba0431db * `fstateRefs' now works on derive expressions as well. TODO: make
this more efficient.
* A flag `-n' in 'nix --query' to normalise the argument.  Default is
  not to normalise.
2003-07-29 10:43:12 +00:00
Eelco Dolstra
5acb45446e * Let `nix --install' print out the id of the normal form.
* Some minor refactoring.
2003-07-29 09:45:03 +00:00
Eelco Dolstra
949c4fa1a8 * `nix --help'.
* `nix --query --graph' to print a dot dependency graph of derive
  expressions.
2003-07-28 12:19:23 +00:00
Eelco Dolstra
f21b341957 * Fix message. 2003-07-24 15:03:36 +00:00
Eelco Dolstra
0a0c1fcb4d * The `-v' flag no longer takes an argument; it should be repeated
instead (e.g., `-vvvv' for lots of output).  Default is to only
  print error messages.
2003-07-24 13:43:16 +00:00
Eelco Dolstra
3b521bb1bd * Do sync the database, since not doing so caused database changes not
to reach the disk at all.  Looks like a bug.
2003-07-24 13:35:17 +00:00
Eelco Dolstra
1a7468a57a * Debug levels. Use `--verbose / -v LEVEL' to display only messages
up to the given verbosity levels.  These currently are:

    lvlError = 0, 
    lvlNormal = 5,
    lvlDebug = 10,
    lvlDebugMore = 15

  although only lvlError and lvlDebug are actually used right now.
2003-07-24 08:53:43 +00:00
Eelco Dolstra
b75719b984 * Don't sync the database on close. This was killing performance.
(Of course, the real problem is that we open the database for
  *every* operation; we should only open it once.  And we should use
  transactions.)
2003-07-24 08:24:32 +00:00
Eelco Dolstra
39ce70025b * Incorporated Berkeley DB and ATerm into the source tree.
* `make dist'.
2003-07-23 15:53:34 +00:00
Eelco Dolstra
9202570f8c * libdb_cxx-4 -> libdb_cxx 2003-07-22 20:02:33 +00:00
Eelco Dolstra
e877c69d78 * Substitutes now should produce a path with the same id as they are
substituting for (obvious, really).

* For greater efficiency, nix-pull/unnar will place the output in a
  path that is probably the same as what is actually needed, thus
  preventing a path copy.

* Even if a output id is given in a Fix package expression, ensure
  that the resulting Nix derive expression has a different id.  This
  is because Nix expressions that are semantically equivalent (i.e.,
  build the same result) might be different w.r.t. efficiency or
  divergence.  It is absolutely vital for the substitute mechanism
  that such expressions are not used interchangeably.
2003-07-22 15:15:15 +00:00
Eelco Dolstra
df648c4967 * nix --query --expansion' (-qe') to get any path with content
corresponding to the given id.
2003-07-22 10:24:22 +00:00
Eelco Dolstra
d5ee6f8700 * In `--query --generators', print out paths, not ids.
(There should really be a switch for this).
2003-07-21 21:31:03 +00:00
Eelco Dolstra
2616e6a6f3 * Check for errors. 2003-07-21 20:58:34 +00:00
Eelco Dolstra
9f4ad99e92 * Canonicalise path. 2003-07-21 20:58:21 +00:00
Eelco Dolstra
249988a787 * Allow the output/expression id to be forced to a certain
value; this potentially dangerous feature enables better 
  sharing for those paths for which the content is known in 
  advance (e.g., because a content hash is given).
* Fast builds: if we can expand all output paths of a derive 
  expression, we don't have to build.
2003-07-21 20:07:12 +00:00
Eelco Dolstra
49231fbe41 * Changes to the command line syntax of Nix.
* A function to find all Nix expressions whose output ids are
  completely contained in some set.  Useful for uploading relevant Nix
  expressions to a shared cache.
2003-07-21 14:46:01 +00:00
Eelco Dolstra
401452e57a * Memoize the evaluation of Fix expressions to speed up computation. 2003-07-21 08:55:49 +00:00
Eelco Dolstra
7984cfc7c1 * Argh, another short-write problem. Added wrappers around
read()/write() to fix this once and for all.
2003-07-20 21:11:43 +00:00
Eelco Dolstra
667a6afb9d * Remove accidentally added file. 2003-07-20 19:30:53 +00:00
Eelco Dolstra
6f1a0f948d * Refactorings. 2003-07-20 19:29:38 +00:00
Eelco Dolstra
b3fc38bf6a * For debugging: `nix --verify' to check the consistency of the
database and store.
2003-07-17 12:27:55 +00:00
Eelco Dolstra
71cc3ceae5 * Preserve the executable bit. 2003-07-17 11:25:14 +00:00
Eelco Dolstra
54664b6fb7 * The write() system call can write less than the requested
number of bytes, e.g., in case of a signal like SIGSTOP.  
  This caused `nix --dump' to fail sometimes.

  Note that this bug went unnoticed because the call to `nix 
  --dump' is in a pipeline, and the shell ignores non-zero 
  exit codes from all but the last element in the pipeline.  
  Is there any way to check the result of the initial elements
  in the pipeline?  (In other words, is it at all possible to 
  write reliable shell scripts?)
2003-07-16 21:24:02 +00:00
Eelco Dolstra
6822fd7bf4 * Bug fix: slices are transitive, so if we detect that an
input path is referenced in an output paths, we also have to 
  add all ids referenced by that input path.
* Better debug assertions to catch these sorts of errors.
2003-07-16 20:33:29 +00:00
Eelco Dolstra
9d56ca219f * Substitute fixes. 2003-07-16 20:00:51 +00:00
Eelco Dolstra
b9ecadee6e * Fix the -qr query. 2003-07-16 11:05:59 +00:00
Eelco Dolstra
c11bbcfd26 * Fix self-referential outputs.
* Fix -qp query.
2003-07-16 08:30:26 +00:00
Eelco Dolstra
d41d085b77 * Get Fix and Nix to work again. 2003-07-15 22:28:27 +00:00
Eelco Dolstra
7b3f44e05b * The new normaliser now passes the unit tests. 2003-07-15 21:24:05 +00:00
Eelco Dolstra
f5b6fa5256 * Basic work on allowing derive expressions to build multiple paths.
This is not entirely trivial since this introduces the possibility
  of mutual recursion.
* Made normal forms self-contained.
* Use unique ids, not content hashes, for content referencing.
2003-07-15 16:28:54 +00:00
Eelco Dolstra
3509299aca * After building, scan for actual file system references as
opposed to declared references.  This prunes the reference
  graph, thus allowing better garbage collection and more
  efficient derivate distribution.
2003-07-14 10:23:11 +00:00
Eelco Dolstra
135b7d54db * Don't check for staleness by default. 2003-07-13 21:43:57 +00:00
Eelco Dolstra
e6363b05ae * Pass $(prefix) and other variables through -D..., not
through config.h, to prevent silly Autoconf problems.
2003-07-13 19:26:00 +00:00
Eelco Dolstra
9c620e4afa * Generate the scripts so that we can substitute the prefix
etc. correctly.
* Fixed nix-switch.
2003-07-13 18:58:03 +00:00
Eelco Dolstra
73b163c1a1 * Fix a bug that caused Fix not to be deterministic (due to addToStore
returning different paths if the hash of the path to be added was
  already available in the store under a different name).
2003-07-11 08:41:03 +00:00
Eelco Dolstra
c834a5c597 * Fix handling of pipes (read(2) may not return the required
number of bytes in one call).
2003-07-11 08:16:15 +00:00
Eelco Dolstra
e5fbf58041 * A command to register successor fstate expressions.
Unifying substitutes and successors isn't very feasible for now,
  since substitutes are only used when no path with a certain is
  known.  Therefore, a normal form of some expression stored as a
  substitute would not be used unless the expression itself was
  missing.
2003-07-10 18:48:11 +00:00
Eelco Dolstra
1d1c3691d2 * The policy-free derivate sharing now *almost* works. :-) For any
hash for which no local expansion is available, Nix can execute a
  `substitute' which should produce a path with such a hash.

  This is policy-free since Nix does not in any way specify how the
  substitute should work, i.e., it's an arbitrary (unnormalised)
  fstate expression.  For example, `nix-pull' registers substitutes
  that fetch Nix archives from the network (through `wget') and unpack
  them, but any other method is possible as well.  This is an
  improvement over the old Nix sharing scheme, which had a policy
  (fetching through `wget') built in.

  The sharing scheme doesn't work completely yet because successors
  from fstate rewriting have to be registered on the receiving side.
  Probably the whole successor stuff can be folded up into the
  substitute mechanism; this would be a nice simplification.
2003-07-10 15:11:48 +00:00
Eelco Dolstra
d072485d28 * Get `nix-push' working again. It now uses Nix/Fix to create Nix
archives (using the package in corepkgs/nar).
* queryPathByHash -> expandHash, and it takes an argument specifying
  the target path (which may be empty).
* Install the core Fix packages in $prefix/share/fix.  TODO: bootstrap
  Nix and install Nix as a Fix package.
2003-07-10 13:41:28 +00:00
Eelco Dolstra
5d4b90b689 * Actually go through the search directories when looking for files. 2003-07-10 09:21:40 +00:00
Eelco Dolstra
6011bd0da2 * Outline of the new scheme for derivate distribution. 2003-07-09 16:12:40 +00:00
Eelco Dolstra
2b95a9dc05 * When computing the set of paths referenced by an expression, also
include the paths of the subterms.
2003-07-09 15:02:03 +00:00
Eelco Dolstra
9a99dc736d * Canonicalise paths so that Fix produces identical Nix
expressions for identical inputs.
2003-07-08 20:26:22 +00:00
Eelco Dolstra
cab3f4977a * A path canonicaliser that doesn't depend on the existence of paths
(i.e., it doesn't use realpath(3), which is broken in any case).
  Therefore it doesn't resolve symlinks.
2003-07-08 19:58:41 +00:00
Eelco Dolstra
333f4963de * The output of a Derive() node is not a referenced path. 2003-07-08 15:33:06 +00:00
Eelco Dolstra
40274c1f4f * A command to query the paths referenced by an fstate expression.
* Use a temporary directory for build actions.
2003-07-08 13:22:08 +00:00
Eelco Dolstra
a279137327 * Get --dump' and --delete' to work again. 2003-07-08 10:00:46 +00:00
Eelco Dolstra
85a913a3e7 * Renamed id' -> name' to remove the implication of uniqueness. 2003-07-08 09:59:00 +00:00
Eelco Dolstra
0b38b43bab * deletePath() now removes the path from the hash2paths mapping. 2003-07-08 09:54:47 +00:00
Eelco Dolstra
ab644ad10b * BaseName() primitive for the generation of more sensible names
(especially in fetchurl.fix).
2003-07-08 09:53:46 +00:00
Eelco Dolstra
a5a90f501e * Get rid of the `netsources' database.
* Rename the `refs' database to `hash2paths'.
2003-07-08 08:35:06 +00:00
Eelco Dolstra
be96c2189c * --realise' -> --install'. 2003-07-07 09:29:40 +00:00
Eelco Dolstra
5895c160c4 * Make dbRefs a mapping from Hash to [Path]. 2003-07-07 09:25:26 +00:00
Eelco Dolstra
609a224848 * Fixed `make check' as well. 2003-07-07 07:44:57 +00:00