Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1ed34081e | ||
|
|
17e20716c0 | ||
|
|
5d48dd6912 | ||
|
|
af54a60204 | ||
|
|
7d386d5c29 | ||
|
|
fa50c0849e | ||
|
|
321be4649d | ||
|
|
0920fe3038 | ||
|
|
08de98f8b6 | ||
|
|
15646244ba | ||
|
|
a2e33d200e | ||
|
|
056cd1d3b7 | ||
|
|
638ce339a5 | ||
|
|
292d6468ec | ||
|
|
8f6254e823 | ||
|
|
593bc23d8b | ||
|
|
b584253af4 | ||
|
|
f5d5ffe536 | ||
|
|
00aadf478b | ||
|
|
151e61fa5a | ||
|
|
4d2946c516 | ||
|
|
24286e15c9 | ||
|
|
2746a879e2 | ||
|
|
91dc023665 | ||
|
|
b113edeab7 | ||
|
|
e4883211f9 | ||
|
|
795d9f8b08 | ||
|
|
a29c8ac51c | ||
|
|
ec32627621 | ||
|
|
8052aef486 | ||
|
|
66c7f34759 | ||
|
|
05a5362d63 | ||
|
|
d051cd40e1 | ||
|
|
3093af58a7 | ||
|
|
b302e5f63b | ||
|
|
83ae1723da | ||
|
|
72bc9a522f | ||
|
|
5e2cf44a4d | ||
|
|
84007a0958 | ||
|
|
c9fbd2dfd5 | ||
|
|
155d7c8dfa | ||
|
|
c4cb6ea2bc | ||
|
|
88fb4f6e53 | ||
|
|
2db9748221 | ||
|
|
37ee6cef99 | ||
|
|
3f3a3ae87b | ||
|
|
72c857f0eb | ||
|
|
be1a917beb | ||
|
|
daf0a923c7 | ||
|
|
15c60ca1b6 | ||
|
|
112ee89501 | ||
|
|
bafb2357d1 | ||
|
|
85ae781765 | ||
|
|
23bb902d1f | ||
|
|
41ec982f31 | ||
|
|
3454c685ee | ||
|
|
6ba26f27c3 | ||
|
|
0b70231b9d | ||
|
|
1bc6afefac | ||
|
|
e8411948ff | ||
|
|
5e4a2272bf | ||
|
|
19479899fb | ||
|
|
1d08093b48 | ||
|
|
8e9fd57ef9 | ||
|
|
ace8872706 | ||
|
|
4fc00cbec1 | ||
|
|
2fa3304933 | ||
|
|
25db622454 | ||
|
|
3426d19547 | ||
|
|
a8306cb98f | ||
|
|
5087c8f645 | ||
|
|
efa5fa1a91 | ||
|
|
1f48aa0be7 | ||
|
|
aa5a5084e4 | ||
|
|
8c0b42f857 | ||
|
|
c8d3882cdc | ||
|
|
aea436503e | ||
|
|
a9858c9f26 | ||
|
|
f044ccf702 | ||
|
|
a7bbe73971 | ||
|
|
ef093aac8f | ||
|
|
256eeab711 | ||
|
|
fd927c5d25 | ||
|
|
22371cbd3f | ||
|
|
bcce9c1ff5 | ||
|
|
d4779abc04 | ||
|
|
759c953196 | ||
|
|
d7238bc84e | ||
|
|
b6df68c942 | ||
|
|
21655a70f5 | ||
|
|
f79e9c2d22 | ||
|
|
8e459d919d | ||
|
|
7cce0c34e1 | ||
|
|
2c5a8bf49f | ||
|
|
b275f2ed3b | ||
|
|
a4d2b22c8c | ||
|
|
87bf541f23 | ||
|
|
b0c9baf1b5 | ||
|
|
153429520a | ||
|
|
2be8ac48bb | ||
|
|
bf3863b546 | ||
|
|
03f1d1ecb5 | ||
|
|
59b94ee18a | ||
|
|
a520b1cbc3 | ||
|
|
c4ac2a164a | ||
|
|
df101d6fca | ||
|
|
ac4d39f9db | ||
|
|
f958bcdf1f | ||
|
|
db3e644c1c | ||
|
|
f8cd904e05 | ||
|
|
f0f7a9f299 | ||
|
|
7823db2137 | ||
|
|
777e13b94b | ||
|
|
79bb0008ec | ||
|
|
e6253b58cd | ||
|
|
3f3c4cce5a | ||
|
|
84c617966b | ||
|
|
c2fc2c13c9 | ||
|
|
a784fd5792 | ||
|
|
8ce3dd4887 | ||
|
|
8330c8202a | ||
|
|
b5539e7a30 | ||
|
|
9d2669d218 | ||
|
|
beda10f5a2 | ||
|
|
a5619f1dff | ||
|
|
7f0ed370da | ||
|
|
dbf547645d | ||
|
|
86b7efbdbe | ||
|
|
0dfdafdf6d | ||
|
|
f34de12140 | ||
|
|
fbc48a469c | ||
|
|
76c0e85929 | ||
|
|
6f5a5ea5ea | ||
|
|
1ad9d11247 | ||
|
|
00fe1a506f | ||
|
|
92e832348d | ||
|
|
6551b36790 | ||
|
|
0616b7feea | ||
|
|
618aa69b01 | ||
|
|
06a75a7e0c | ||
|
|
b8675aee54 | ||
|
|
73ab2ed4fd | ||
|
|
7c0fa4474f | ||
|
|
7abf9911d9 | ||
|
|
49bafe1faf | ||
|
|
66e94d3275 | ||
|
|
d445da7a7b | ||
|
|
9d25466b34 | ||
|
|
6d46e647ba | ||
|
|
9b44480612 | ||
|
|
c4f7ae4aa5 | ||
|
|
1c9c0a5a46 | ||
|
|
d9f30fe7c7 | ||
|
|
47c003cb59 | ||
|
|
619f20775d | ||
|
|
c625718513 | ||
|
|
c5baaafae6 | ||
|
|
abd1878b26 | ||
|
|
3648d1c732 | ||
|
|
cdb50886f4 | ||
|
|
3c4bc7276a | ||
|
|
4f72b408a5 | ||
|
|
840551ebdb | ||
|
|
1109ea0680 | ||
|
|
47f19b6293 | ||
|
|
4db7ef3fcc | ||
|
|
3778586b2a | ||
|
|
8baf50f108 | ||
|
|
699989b216 | ||
|
|
3a4a4aaa88 | ||
|
|
f899e8ce4d | ||
|
|
b1c5f3c10d | ||
|
|
291030b900 | ||
|
|
447089a5f6 | ||
|
|
08719c6c97 | ||
|
|
55e11bc0d3 | ||
|
|
9a404e45c9 | ||
|
|
16f9b133ec | ||
|
|
ff9af107d3 | ||
|
|
3495d153b3 | ||
|
|
698e880c9f | ||
|
|
23fbc72f5d | ||
|
|
4c4fe7a114 | ||
|
|
46a71c857c | ||
|
|
30b31a8f61 | ||
|
|
b594215531 | ||
|
|
5346536b62 | ||
|
|
7959354379 | ||
|
|
abe8c8c2aa | ||
|
|
1ff986d51a | ||
|
|
2f0b93904b | ||
|
|
4a373a3e9a | ||
|
|
f83c5e3e5f | ||
|
|
0e68af0ce3 | ||
|
|
9ff3657095 | ||
|
|
0e09cc12c0 | ||
|
|
94175e978a | ||
|
|
68f2fadb78 | ||
|
|
392b7e0f8e | ||
|
|
833f2fc92d | ||
|
|
cf0287c09e | ||
|
|
f3c9783846 | ||
|
|
a81b621202 | ||
|
|
0a753e182a | ||
|
|
df7a718786 | ||
|
|
397c8ba898 | ||
|
|
528f1d1867 | ||
|
|
06c5a7075d | ||
|
|
cff6fd22eb | ||
|
|
feaab52203 | ||
|
|
00d4f907e1 | ||
|
|
31fd72ee17 | ||
|
|
16d971bce7 | ||
|
|
0d3a1a8582 | ||
|
|
0c804c6775 | ||
|
|
a3ca74a1c3 | ||
|
|
078e20885e | ||
|
|
905d5b91fa | ||
|
|
83ffd4f282 | ||
|
|
5d2b424804 | ||
|
|
dc05f29cf6 | ||
|
|
7b0e29b4dc | ||
|
|
62d9b31d0a | ||
|
|
f6a30ab264 | ||
|
|
2a4bac5459 | ||
|
|
bd0ce1a4be | ||
|
|
80f8c38384 | ||
|
|
c38ba181ed | ||
|
|
4da9316c8f | ||
|
|
6d5877ea12 | ||
|
|
12e805cfb0 | ||
|
|
ba73f94b3b | ||
|
|
66c115ef5f | ||
|
|
c3ee8c9166 | ||
|
|
6e8c19714a | ||
|
|
d1d87badf6 | ||
|
|
604c45e960 | ||
|
|
e7ea52d3b3 | ||
|
|
b857267893 | ||
|
|
496934a99c | ||
|
|
c9cb1fa21f | ||
|
|
60e86b124f | ||
|
|
af7e6fe22e | ||
|
|
9486dda115 | ||
|
|
ab0bc4999a | ||
|
|
40d9eb14df | ||
|
|
7a02d95418 | ||
|
|
06208d1d86 | ||
|
|
2e9042bd1e | ||
|
|
e0b5a492f5 | ||
|
|
9898746ef3 | ||
|
|
fd7ac09f10 | ||
|
|
ac68840e79 | ||
|
|
2be8b5917a | ||
|
|
38946e1378 | ||
|
|
dfc9c64ead | ||
|
|
b1117ef29d | ||
|
|
ce92d1bf14 | ||
|
|
9f0f020929 | ||
|
|
8798fae304 | ||
|
|
45610ae675 | ||
|
|
3e5a019a07 | ||
|
|
06ae269c7c | ||
|
|
15801c88fa | ||
|
|
d2e3a132fe | ||
|
|
90e26d392c | ||
|
|
cfaea07444 | ||
|
|
569e7940f8 | ||
|
|
fa18f1f184 | ||
|
|
e17e95a828 | ||
|
|
80bb477cc4 | ||
|
|
0690c1c9c0 | ||
|
|
ff31324278 | ||
|
|
e2655aa332 | ||
|
|
ad0976f8d5 | ||
|
|
40986312bb | ||
|
|
adf9a45469 | ||
|
|
c8268ca991 | ||
|
|
7de1b2a698 | ||
|
|
1610444671 | ||
|
|
1b4184ccbb | ||
|
|
a2a9bacd82 | ||
|
|
449411e511 | ||
|
|
9210d4d530 | ||
|
|
f1c1a3c97f | ||
|
|
7db08cc924 | ||
|
|
403cb9327f | ||
|
|
9f8f39aa3c | ||
|
|
e537844f4e | ||
|
|
442b09ea33 | ||
|
|
933b3f677d | ||
|
|
b95a3dc45b | ||
|
|
4d728f6a36 | ||
|
|
f31661a3b5 | ||
|
|
7102455cba | ||
|
|
92eea8fc4e | ||
|
|
c4e7d324b8 | ||
|
|
9d95aafe8c | ||
|
|
143427f90b | ||
|
|
4a8948b7a6 | ||
|
|
c62433751d | ||
|
|
53e376d836 | ||
|
|
0eab306466 | ||
|
|
a0a7a4e087 | ||
|
|
0791282b2f | ||
|
|
ab5e8767fa | ||
|
|
c78bf11524 | ||
|
|
f7c7aad135 | ||
|
|
181aa3dc41 | ||
|
|
ebff82222c | ||
|
|
5fc7127643 | ||
|
|
c190f051ac | ||
|
|
1d61e473c8 | ||
|
|
0abe185688 | ||
|
|
d3d5e77810 | ||
|
|
1eb4da156c | ||
|
|
08b7319f5b | ||
|
|
6409c215e5 | ||
|
|
6baa2c4420 | ||
|
|
b9f4942bd2 | ||
|
|
5d4171f7fb | ||
|
|
563afb7fcc | ||
|
|
e78f753aa8 | ||
|
|
4193d62e08 | ||
|
|
6d478597c7 | ||
|
|
9fb94f4f2f | ||
|
|
9ba2397ea9 | ||
|
|
41730f5779 | ||
|
|
1c7d6bf5fc | ||
|
|
d930a9bc5a | ||
|
|
803a924b77 | ||
|
|
c0bbed0959 | ||
|
|
0d2bc68681 | ||
|
|
25304af72e | ||
|
|
b018517314 | ||
|
|
c4f1f49574 | ||
|
|
31be53cd0a | ||
|
|
920193beb1 | ||
|
|
a88144215c | ||
|
|
56b98c3857 | ||
|
|
956801fcc2 | ||
|
|
624c48260f | ||
|
|
710175e6a0 | ||
|
|
ed0db2e0d8 | ||
|
|
1472cc4825 | ||
|
|
2de8504791 | ||
|
|
31e4aa6439 | ||
|
|
ebbb6ce578 | ||
|
|
c32e01eab2 | ||
|
|
08f9cfe267 | ||
|
|
96c7b98bf0 | ||
|
|
555347744d | ||
|
|
e374dbf89b | ||
|
|
01e30360d4 | ||
|
|
163db7367f | ||
|
|
161aab582b | ||
|
|
a24cb19361 | ||
|
|
9ee3b7a37a | ||
|
|
dc0ef2ca98 | ||
|
|
2e16ff22ac | ||
|
|
5cde23f869 | ||
|
|
0a2de7f543 | ||
|
|
95b49f8044 | ||
|
|
68022552d2 | ||
|
|
c34a153ae5 | ||
|
|
b4f88d0ec3 | ||
|
|
469f1eba56 | ||
|
|
e405ca506e | ||
|
|
c602930e08 | ||
|
|
4b7b0bd12c | ||
|
|
74867e72f2 | ||
|
|
f8035d06f2 | ||
|
|
9ad39df282 | ||
|
|
d551062ec4 | ||
|
|
236eb59293 | ||
|
|
720f06e3b0 | ||
|
|
37483672d4 | ||
|
|
d34b4d4f28 | ||
|
|
b9c9b461ea | ||
|
|
4ce652640b | ||
|
|
fd30f52cfc | ||
|
|
17f05dba77 | ||
|
|
d6b6b2d3a8 | ||
|
|
d2e963f7a3 | ||
|
|
c95b4ad290 | ||
|
|
d99d04e644 | ||
|
|
545145cd58 | ||
|
|
9df93f30bd | ||
|
|
06434072e7 | ||
|
|
06d3d7355d | ||
|
|
177a7782ae | ||
|
|
4a013962bd | ||
|
|
758bd4673a | ||
|
|
9f4c19276d | ||
|
|
26ff1cdf89 | ||
|
|
64c617e984 | ||
|
|
2ac02440dc |
No files matched your search
+29
-2
@@ -1,3 +1,30 @@
|
||||
SUBDIRS = externals src scripts corepkgs
|
||||
SUBDIRS = externals src scripts corepkgs doc misc tests
|
||||
EXTRA_DIST = substitute.mk nix.spec nix.spec.in
|
||||
|
||||
EXTRA_DIST = boost/*.hpp boost/format/*.hpp substitute.mk
|
||||
include ./substitute.mk
|
||||
|
||||
nix.spec: nix.spec.in
|
||||
|
||||
rpm: nix.spec dist
|
||||
rpm $(EXTRA_RPM_FLAGS) -ta $(distdir).tar.gz
|
||||
|
||||
relname:
|
||||
echo -n $(distdir) > relname
|
||||
|
||||
install-data-local: init-state
|
||||
|
||||
if INIT_STATE
|
||||
init-state:
|
||||
$(INSTALL) -d $(DESTDIR)$(localstatedir)/nix
|
||||
$(INSTALL) -d $(DESTDIR)$(localstatedir)/nix/db
|
||||
$(INSTALL) -d $(DESTDIR)$(localstatedir)/log/nix
|
||||
$(INSTALL) -d $(DESTDIR)$(localstatedir)/nix/profiles
|
||||
$(INSTALL) -d $(DESTDIR)$(localstatedir)/nix/gcroots
|
||||
$(INSTALL) -d $(DESTDIR)$(localstatedir)/nix/gcroots/tmp
|
||||
rm -f $(DESTDIR)$(localstatedir)/nix/gcroots/profiles
|
||||
ln -s $(localstatedir)/nix/profiles $(DESTDIR)$(localstatedir)/nix/gcroots/profiles
|
||||
$(INSTALL) -d $(DESTDIR)$(prefix)/store
|
||||
# $(bindir)/nix-store --init
|
||||
else
|
||||
init-state:
|
||||
endif
|
||||
@@ -1,36 +1,5 @@
|
||||
Overview
|
||||
========
|
||||
*** Nix ***
|
||||
|
||||
Nix is a package manager, deployment system, and component glue
|
||||
mechanism.
|
||||
|
||||
|
||||
Prerequisites
|
||||
=============
|
||||
|
||||
* Berkeley DB 4.0.14
|
||||
* CWI ATerm 2.0
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
* When building from the Subversion repository, first do:
|
||||
|
||||
autoreconf -i
|
||||
|
||||
* To build, do:
|
||||
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
Note that this will install to /nix, which is the default prefix.
|
||||
You can specify another prefix, but this is not recommended if you
|
||||
want to use prebuilt packages from other sources.
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
TODO
|
||||
For installation and usage instructions, please read the manual, which
|
||||
can be found in `docs/manual/manual.html', and additionally at the Nix
|
||||
website at <http://www.cs.uu.nl/groups/ST/Trace/Nix>.
|
||||
+147
-5
@@ -1,20 +1,162 @@
|
||||
AC_INIT(nix, 0.2pre1)
|
||||
AC_CONFIG_SRCDIR(src/nix.cc)
|
||||
AC_INIT(nix, "0.6")
|
||||
AC_CONFIG_SRCDIR(README)
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
AM_INIT_AUTOMAKE
|
||||
|
||||
# Change to `1' to produce a `stable' release (i.e., the `preREVISION'
|
||||
# suffix is not added).
|
||||
STABLE=0
|
||||
|
||||
# Put the revision number in the version.
|
||||
if test "$STABLE" != "1"; then
|
||||
if REVISION=`test -d $srcdir/.svn && svnversion $srcdir 2> /dev/null`; then
|
||||
VERSION="${VERSION}pre${REVISION}"
|
||||
elif REVISION=`cat $srcdir/svn-revision 2> /dev/null`; then
|
||||
VERSION="${VERSION}pre${REVISION}"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PREFIX_DEFAULT(/nix)
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
# Construct a Nix system name (like "i686-linux").
|
||||
AC_MSG_CHECKING([for the canonical Nix system name])
|
||||
#machine_name=`uname -m`
|
||||
#sys_name=`uname -s | tr [A-Z] [a-z]`
|
||||
#system="${machine_name}-${sys_name}"
|
||||
AC_ARG_WITH(system, AC_HELP_STRING([--with-system=SYSTEM],
|
||||
[platform identifier (e.g., `i686-linux')]),
|
||||
system=$withval, system="$host_cpu-$host_os")
|
||||
AC_MSG_RESULT($system)
|
||||
AC_SUBST(system)
|
||||
AC_DEFINE_UNQUOTED(SYSTEM, ["$system"], [platform identifier (`cpu-os')])
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_PROG_RANLIB
|
||||
|
||||
# Check for pubsetbuf.
|
||||
AC_MSG_CHECKING([for pubsetbuf])
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <iostream>
|
||||
using namespace std;
|
||||
static char buf[1024];]],
|
||||
[[cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));]])],
|
||||
[AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PUBSETBUF, 1, [whether pubsetbuf is available])],
|
||||
AC_MSG_RESULT(no))
|
||||
AC_LANG_POP(C++)
|
||||
|
||||
# Check for <locale>
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_CHECK_HEADERS([locale])
|
||||
AC_LANG_POP(C++)
|
||||
|
||||
AC_DEFUN([NEED_PROG],
|
||||
[
|
||||
AC_PATH_PROG($1, $2)
|
||||
if test -z "$$1"; then
|
||||
AC_MSG_ERROR([$1 is required])
|
||||
fi
|
||||
])
|
||||
|
||||
NEED_PROG(curl, curl)
|
||||
NEED_PROG(bzip2, bzip2)
|
||||
NEED_PROG(bunzip2, bunzip2)
|
||||
NEED_PROG(shell, sh)
|
||||
AC_PATH_PROG(xmllint, xmllint, false)
|
||||
AC_PATH_PROG(xsltproc, xsltproc, false)
|
||||
AC_PATH_PROG(flex, flex, false)
|
||||
AC_PATH_PROG(bison, bison, false)
|
||||
NEED_PROG(perl, perl)
|
||||
|
||||
AC_ARG_WITH(docbook-catalog, AC_HELP_STRING([--with-docbook-catalog=PATH],
|
||||
[path of the DocBook XML DTD]),
|
||||
docbookcatalog=$withval, docbookcatalog=/docbook-dtd-missing)
|
||||
AC_SUBST(docbookcatalog)
|
||||
|
||||
AC_ARG_WITH(docbook-ebnf-catalog, AC_HELP_STRING([--with-docbook-ebnf-catalog=PATH],
|
||||
[path of the DocBook XML EBNF module DTD]),
|
||||
docbookebnfcatalog=$withval, docbookcatalog=/docbook-ebnf-dtd-missing)
|
||||
AC_SUBST(docbookebnfcatalog)
|
||||
|
||||
AC_ARG_WITH(docbook-xsl, AC_HELP_STRING([--with-docbook-xsl=PATH],
|
||||
[path of the DocBook XSL stylesheets]),
|
||||
docbookxsl=$withval, docbookxsl=/docbook-xsl-missing)
|
||||
AC_SUBST(docbookxsl)
|
||||
|
||||
AC_ARG_WITH(xml-flags, AC_HELP_STRING([--with-xml-flags=FLAGS],
|
||||
[extra flags to be passed to xmllint and xsltproc]),
|
||||
xmlflags=$withval, xmlflags=)
|
||||
AC_SUBST(xmlflags)
|
||||
|
||||
AC_ARG_WITH(store-dir, AC_HELP_STRING([--with-store-dir=PATH],
|
||||
[path of the Nix store]),
|
||||
storedir=$withval, storedir='${prefix}/store')
|
||||
AC_SUBST(storedir)
|
||||
|
||||
AC_ARG_WITH(bdb, AC_HELP_STRING([--with-bdb=PATH],
|
||||
[prefix of Berkeley DB]),
|
||||
bdb=$withval, bdb=)
|
||||
AM_CONDITIONAL(HAVE_BDB, test -n "$bdb")
|
||||
if test -z "$bdb"; then
|
||||
bdb_lib='-L${top_builddir}/externals/inst-bdb/lib -ldb_cxx'
|
||||
bdb_include='-I${top_builddir}/externals/inst-bdb/include'
|
||||
else
|
||||
bdb_lib="-L$bdb/lib -ldb_cxx"
|
||||
bdb_include="-I$bdb/include"
|
||||
fi
|
||||
AC_SUBST(bdb_lib)
|
||||
AC_SUBST(bdb_include)
|
||||
|
||||
AC_ARG_WITH(aterm, AC_HELP_STRING([--with-aterm=PATH],
|
||||
[prefix of CWI ATerm library]),
|
||||
aterm=$withval, aterm=)
|
||||
AM_CONDITIONAL(HAVE_ATERM, test -n "$aterm")
|
||||
if test -z "$aterm"; then
|
||||
aterm_lib='-L${top_builddir}/externals/inst-aterm/lib -lATerm'
|
||||
aterm_include='-I${top_builddir}/externals/inst-aterm/include'
|
||||
else
|
||||
aterm_lib="-L$aterm/lib -lATerm"
|
||||
aterm_include="-I$aterm/include"
|
||||
fi
|
||||
AC_SUBST(aterm_lib)
|
||||
AC_SUBST(aterm_include)
|
||||
|
||||
AC_CHECK_LIB(pthread, pthread_mutex_init)
|
||||
|
||||
AC_ARG_ENABLE(init-state, AC_HELP_STRING([--disable-init-state],
|
||||
[do not initialise DB etc. in `make install']),
|
||||
init_state=$enableval, init_state=yes)
|
||||
AM_CONDITIONAL(INIT_STATE, test "$init_state" = "yes")
|
||||
|
||||
AM_CONFIG_HEADER([config.h])
|
||||
AC_CONFIG_FILES([Makefile externals/Makefile src/Makefile scripts/Makefile
|
||||
corepkgs/Makefile corepkgs/fetchurl/Makefile
|
||||
corepkgs/nar/Makefile])
|
||||
AC_CONFIG_FILES([Makefile
|
||||
externals/Makefile
|
||||
src/Makefile
|
||||
src/bin2c/Makefile
|
||||
src/boost/Makefile
|
||||
src/boost/format/Makefile
|
||||
src/libutil/Makefile
|
||||
src/libstore/Makefile
|
||||
src/libmain/Makefile
|
||||
src/nix-store/Makefile
|
||||
src/nix-hash/Makefile
|
||||
src/libexpr/Makefile
|
||||
src/nix-instantiate/Makefile
|
||||
src/nix-env/Makefile
|
||||
src/log2xml/Makefile
|
||||
scripts/Makefile
|
||||
corepkgs/Makefile
|
||||
corepkgs/fetchurl/Makefile
|
||||
corepkgs/nar/Makefile
|
||||
corepkgs/buildenv/Makefile
|
||||
corepkgs/channels/Makefile
|
||||
corepkgs/nix-pull/Makefile
|
||||
doc/Makefile
|
||||
doc/manual/Makefile
|
||||
misc/Makefile
|
||||
misc/emacs/Makefile
|
||||
tests/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
@@ -1 +1 @@
|
||||
SUBDIRS = fetchurl nar
|
||||
SUBDIRS = fetchurl nar buildenv channels nix-pull
|
||||
@@ -0,0 +1,11 @@
|
||||
all-local: builder.pl
|
||||
|
||||
install-exec-local:
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/buildenv
|
||||
$(INSTALL_DATA) default.nix $(DESTDIR)$(datadir)/nix/corepkgs/buildenv
|
||||
$(INSTALL_PROGRAM) builder.pl $(DESTDIR)$(datadir)/nix/corepkgs/buildenv
|
||||
|
||||
include ../../substitute.mk
|
||||
|
||||
EXTRA_DIST = default.nix builder.pl.in
|
||||
Executable
+93
@@ -0,0 +1,93 @@
|
||||
#! @perl@ -w
|
||||
|
||||
use strict;
|
||||
use Cwd;
|
||||
use IO::Handle;
|
||||
|
||||
STDOUT->autoflush(1);
|
||||
|
||||
my $out = $ENV{"out"};
|
||||
mkdir "$out", 0755 || die "error creating $out";
|
||||
|
||||
|
||||
# For each activated package, create symlinks.
|
||||
|
||||
sub createLinks {
|
||||
my $srcDir = shift;
|
||||
my $dstDir = shift;
|
||||
|
||||
my @srcFiles = glob("$srcDir/*");
|
||||
|
||||
foreach my $srcFile (@srcFiles) {
|
||||
my $baseName = $srcFile;
|
||||
$baseName =~ s/^.*\///g; # strip directory
|
||||
my $dstFile = "$dstDir/$baseName";
|
||||
|
||||
if ($srcFile =~ /\/propagated-build-inputs$/ ||
|
||||
$srcFile =~ /\/nix-support$/)
|
||||
{
|
||||
# Do noting.
|
||||
}
|
||||
|
||||
elsif (-d $srcFile) {
|
||||
|
||||
lstat $dstFile;
|
||||
|
||||
if (-d _) {
|
||||
createLinks($srcFile, $dstFile);
|
||||
}
|
||||
|
||||
elsif (-l _) {
|
||||
my $target = readlink $dstFile or die;
|
||||
if (!-d $target) {
|
||||
die "collission between directory `$srcFile' and non-directory `$target'";
|
||||
}
|
||||
unlink $dstFile or die "error unlinking `$dstFile': $!";
|
||||
mkdir $dstFile, 0755 ||
|
||||
die "error creating directory `$dstFile': $!";
|
||||
createLinks($target, $dstFile);
|
||||
createLinks($srcFile, $dstFile);
|
||||
}
|
||||
|
||||
else {
|
||||
symlink($srcFile, $dstFile) ||
|
||||
die "error creating link `$dstFile': $!";
|
||||
}
|
||||
}
|
||||
|
||||
elsif (-l $dstFile) {
|
||||
my $target = readlink $dstFile;
|
||||
die "collission between `$srcFile' and `$target'";
|
||||
}
|
||||
|
||||
else {
|
||||
# print "linking $dstFile to $srcFile\n";
|
||||
symlink($srcFile, $dstFile) ||
|
||||
die "error creating link `$dstFile': $!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my %done;
|
||||
|
||||
sub addPkg {
|
||||
my $pkgDir = shift;
|
||||
|
||||
return if (defined $done{$pkgDir});
|
||||
$done{$pkgDir} = 1;
|
||||
|
||||
createLinks("$pkgDir", "$out");
|
||||
}
|
||||
|
||||
|
||||
my @args = split ' ', $ENV{"derivations"};
|
||||
|
||||
while (scalar @args > 0) {
|
||||
my $drvPath = shift @args;
|
||||
print "adding $drvPath\n";
|
||||
addPkg($drvPath);
|
||||
}
|
||||
|
||||
|
||||
symlink($ENV{"manifest"}, "$out/manifest") or die "cannot create manifest";
|
||||
@@ -0,0 +1,9 @@
|
||||
{system, derivations, manifest}:
|
||||
|
||||
derivation {
|
||||
name = "user-environment";
|
||||
system = system;
|
||||
builder = ./builder.pl;
|
||||
derivations = derivations;
|
||||
manifest = manifest;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
all-local: unpack.sh
|
||||
|
||||
install-exec-local:
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/channels
|
||||
$(INSTALL_DATA) unpack.nix $(DESTDIR)$(datadir)/nix/corepkgs/channels
|
||||
$(INSTALL_PROGRAM) unpack.sh $(DESTDIR)$(datadir)/nix/corepkgs/channels
|
||||
|
||||
include ../../substitute.mk
|
||||
|
||||
EXTRA_DIST = unpack.nix unpack.sh.in
|
||||
@@ -0,0 +1,7 @@
|
||||
{system, inputs}:
|
||||
|
||||
derivation {
|
||||
name = "channels";
|
||||
builder = ./unpack.sh;
|
||||
inherit system inputs;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#! @shell@ -e
|
||||
|
||||
export PATH=/bin:/usr/bin # !!! impure
|
||||
|
||||
mkdir $out
|
||||
mkdir $out/tmp
|
||||
cd $out/tmp
|
||||
|
||||
expr=$out/default.nix
|
||||
echo '[' > $expr
|
||||
|
||||
nr=0
|
||||
for i in $inputs; do
|
||||
echo "unpacking $i"
|
||||
@bunzip2@ < $i | tar xvf -
|
||||
mv * ../$nr # !!! hacky
|
||||
echo "(import ./$nr)" >> $expr
|
||||
nr=$(($nr + 1))
|
||||
done
|
||||
|
||||
echo ']' >> $expr
|
||||
|
||||
cd ..
|
||||
rmdir tmp
|
||||
@@ -1,10 +1,11 @@
|
||||
all-local: fetchurl.sh
|
||||
all-local: builder.sh
|
||||
|
||||
install-exec-local:
|
||||
$(INSTALL) -d $(datadir)/fix/fetchurl
|
||||
$(INSTALL_DATA) fetchurl.fix $(datadir)/fix/fetchurl
|
||||
$(INSTALL_PROGRAM) fetchurl.sh $(datadir)/fix/fetchurl
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/fetchurl
|
||||
$(INSTALL_DATA) default.nix $(DESTDIR)$(datadir)/nix/corepkgs/fetchurl
|
||||
$(INSTALL_PROGRAM) builder.sh $(DESTDIR)$(datadir)/nix/corepkgs/fetchurl
|
||||
|
||||
include ../../substitute.mk
|
||||
|
||||
EXTRA_DIST = fetchurl.fix fetchurl.sh
|
||||
EXTRA_DIST = default.nix builder.sh.in
|
||||
@@ -0,0 +1,19 @@
|
||||
#! @shell@ -e
|
||||
|
||||
export PATH=/bin:/usr/bin
|
||||
|
||||
echo "downloading $url into $out"
|
||||
|
||||
prefetch=@storedir@/nix-prefetch-url-$md5
|
||||
if test -f "$prefetch"; then
|
||||
echo "using prefetched $prefetch";
|
||||
mv $prefetch $out
|
||||
else
|
||||
@curl@ --fail --location --max-redirs 20 "$url" > "$out"
|
||||
fi
|
||||
|
||||
actual=$(@bindir@/nix-hash --flat $out)
|
||||
if test "$actual" != "$md5"; then
|
||||
echo "hash is $actual, expected $md5"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,8 @@
|
||||
{system, url, md5}:
|
||||
|
||||
derivation {
|
||||
name = baseNameOf (toString url);
|
||||
builder = ./builder.sh;
|
||||
id = md5;
|
||||
inherit system url md5;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
Function(["url", "md5"],
|
||||
Package(
|
||||
[ ("build", Relative("fetchurl/fetchurl.sh"))
|
||||
, ("url", Var("url"))
|
||||
, ("md5", Var("md5"))
|
||||
, ("name", BaseName(Var("url")))
|
||||
, ("id", Var("md5"))
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -1,10 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
echo "downloading $url into $out..."
|
||||
wget "$url" -O "$out" || exit 1
|
||||
|
||||
actual=$(md5sum -b $out | cut -c1-32)
|
||||
if ! test "$actual" == "$md5"; then
|
||||
echo "hash is $actual, expected $md5"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,12 +1,13 @@
|
||||
all-local: nar.sh unnar.sh
|
||||
|
||||
install-exec-local:
|
||||
$(INSTALL) -d $(datadir)/fix/nar
|
||||
$(INSTALL_DATA) nar.fix $(datadir)/fix/nar
|
||||
$(INSTALL_PROGRAM) nar.sh $(datadir)/fix/nar
|
||||
$(INSTALL_DATA) unnar.fix $(datadir)/fix/nar
|
||||
$(INSTALL_PROGRAM) unnar.sh $(datadir)/fix/nar
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/nar
|
||||
$(INSTALL_DATA) nar.nix $(DESTDIR)$(datadir)/nix/corepkgs/nar
|
||||
$(INSTALL_PROGRAM) nar.sh $(DESTDIR)$(datadir)/nix/corepkgs/nar
|
||||
$(INSTALL_DATA) unnar.nix $(DESTDIR)$(datadir)/nix/corepkgs/nar
|
||||
$(INSTALL_PROGRAM) unnar.sh $(DESTDIR)$(datadir)/nix/corepkgs/nar
|
||||
|
||||
include ../../substitute.mk
|
||||
|
||||
EXTRA_DIST = nar.fix nar.sh unnar.fix unnar.sh
|
||||
EXTRA_DIST = nar.nix nar.sh.in unnar.nix unnar.sh.in
|
||||
@@ -1,8 +0,0 @@
|
||||
Function(["path"],
|
||||
Package(
|
||||
[ ("name", "nar")
|
||||
, ("build", Relative("nar/nar.sh"))
|
||||
, ("path", Var("path"))
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,6 @@
|
||||
{system, path}: derivation {
|
||||
name = "nar";
|
||||
builder = ./nar.sh;
|
||||
system = system;
|
||||
path = path;
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
#! /bin/sh
|
||||
#! @shell@ -e
|
||||
|
||||
# !!! impure; fix this
|
||||
export PATH=/bin:/usr/bin
|
||||
|
||||
echo "packing $path into $out..."
|
||||
mkdir $out || exit 1
|
||||
tmp=$out/tmp
|
||||
@bindir@/nix --dump --path "$path" | bzip2 > $out/tmp || exit 1
|
||||
mkdir $out
|
||||
dst=$out/$(basename $path).nar.bz2
|
||||
@bindir@/nix-store --dump "$path" | @bzip2@ > $dst
|
||||
|
||||
md5=$(md5sum -b $tmp | cut -c1-32)
|
||||
md5=$(md5sum -b $dst | cut -c1-32)
|
||||
if test $? != 0; then exit 1; fi
|
||||
mv $out/tmp $out/$md5-`basename $path`.nar.bz2 || exit 1
|
||||
echo $md5 > $out/md5
|
||||
@@ -1,9 +0,0 @@
|
||||
Function(["nar", "name"],
|
||||
Package(
|
||||
[ ("name", Var("name"))
|
||||
, ("build", Relative("nar/unnar.sh"))
|
||||
, ("nar", Var("nar"))
|
||||
, ("id", Var("id"))
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
{system, narFile, outPath}: derivation {
|
||||
name = "unnar";
|
||||
builder = ./unnar.sh;
|
||||
system = system;
|
||||
narFile = narFile;
|
||||
outPath = outPath;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /bin/sh
|
||||
#! @shell@ -e
|
||||
|
||||
echo "unpacking $nar to $out..."
|
||||
bunzip2 < $nar | @bindir@/nix --restore "$out" || exit 1
|
||||
echo "unpacking $narFile to $out..."
|
||||
@bunzip2@ < $narFile | @bindir@/nix-store --restore "$out"
|
||||
@@ -0,0 +1,11 @@
|
||||
all-local: builder.sh
|
||||
|
||||
install-exec-local:
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull
|
||||
$(INSTALL_DATA) default.nix $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull
|
||||
$(INSTALL_PROGRAM) builder.sh $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull
|
||||
|
||||
include ../../substitute.mk
|
||||
|
||||
EXTRA_DIST = default.nix builder.sh.in
|
||||
@@ -0,0 +1,34 @@
|
||||
#! @shell@ -e
|
||||
|
||||
export PATH=/bin:/usr/bin
|
||||
|
||||
mkdir $out
|
||||
|
||||
cat > $out/fetch <<EOF
|
||||
#! @shell@ -e
|
||||
|
||||
export PATH=/bin:/usr/bin
|
||||
|
||||
echo "downloading \$2..."
|
||||
|
||||
export PRINT_PATH=1
|
||||
result=(\$(@bindir@/nix-prefetch-url \$2))
|
||||
|
||||
hash=\${result[0]}
|
||||
path=\${result[1]}
|
||||
|
||||
if test "\$hash" != "\$3"; then
|
||||
echo "hash is \$hash, expected \$3"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "unpacking into \$1..."
|
||||
|
||||
if ! @bunzip2@ < "\$path" | @bindir@/nix-store --restore "\$1"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
|
||||
chmod +x $out/fetch
|
||||
@@ -0,0 +1,7 @@
|
||||
{system}:
|
||||
|
||||
derivation {
|
||||
name = "nix-pull";
|
||||
builder = ./builder.sh;
|
||||
inherit system;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
SUBDIRS = manual
|
||||
@@ -0,0 +1,30 @@
|
||||
To produce a `stable' release from the trunk:
|
||||
|
||||
0. Make sure that the trunk builds in the release supervisor.
|
||||
|
||||
1. Branch the trunk, e.g., `svn cp .../trunk
|
||||
.../branches/0.5-release'.
|
||||
|
||||
2. Switch to the branch, e.g., `svn switch .../branches/0.5-release'.
|
||||
|
||||
3. In `configure.ac', change `STABLE=0' into `STABLE=1' and commit.
|
||||
|
||||
4. In the release supervisor, add a one-time job to build
|
||||
`.../branches/0.5-release'.
|
||||
|
||||
5. Make sure that the release succeeds.
|
||||
|
||||
6. Move the branch to a tag, e.g., `svn mv .../branches/0.5-release
|
||||
.../tags/0.5'.
|
||||
|
||||
Note that the branch should not be used for maintenance; it should
|
||||
be deleted after the release has been created. A maintenance
|
||||
branch (e.g., `.../branches/0.5') should be created from the
|
||||
original revision of the trunk (since maintenance releases should
|
||||
also be tested first; hence, we cannot have `STABLE=1'). The same
|
||||
procedure can then be followed to produce maintenance release; just
|
||||
substitute `.../branches/VERSION' for the trunk.
|
||||
|
||||
7. Switch back to the trunk.
|
||||
|
||||
8. Bump the version number in `configure.ac' (in AC_INIT).
|
||||
@@ -0,0 +1,50 @@
|
||||
ENV = SGML_CATALOG_FILES=$(docbookcatalog):$(docbookebnfcatalog)
|
||||
|
||||
XMLLINT = $(ENV) $(xmllint) $(xmlflags) --catalogs
|
||||
XSLTPROC = $(ENV) $(xsltproc) $(xmlflags) --catalogs \
|
||||
--param section.autolabel 1 \
|
||||
--param section.label.includes.component.label 1 \
|
||||
--param html.stylesheet \'style.css\'
|
||||
|
||||
man1_MANS = nix-env.1 nix-store.1 nix-instantiate.1 \
|
||||
nix-collect-garbage.1 nix-push.1 nix-pull.1 \
|
||||
nix-prefetch-url.1
|
||||
|
||||
SOURCES = manual.xml introduction.xml installation.xml overview.xml \
|
||||
$(man1_MANS:.1=.xml) \
|
||||
troubleshooting.xml bugs.xml opt-common.xml opt-common-syn.xml \
|
||||
quick-start.xml nix-lang-ref.xml style.css images
|
||||
|
||||
manual.is-valid: $(SOURCES) version.xml
|
||||
$(XMLLINT) --noout --valid manual.xml
|
||||
touch $@
|
||||
|
||||
version.xml:
|
||||
echo -n $(VERSION) > version.xml
|
||||
|
||||
man $(MANS): $(SOURCES) manual.is-valid
|
||||
$(XSLTPROC) $(docbookxsl)/manpages/docbook.xsl manual.xml
|
||||
|
||||
manual.html: $(SOURCES) manual.is-valid images
|
||||
$(XSLTPROC) --output manual.html $(docbookxsl)/html/docbook.xsl manual.xml
|
||||
|
||||
all-local: manual.html
|
||||
|
||||
install-data-local: manual.html
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/manual
|
||||
$(INSTALL_DATA) manual.html $(DESTDIR)$(datadir)/nix/manual
|
||||
$(INSTALL_DATA) style.css $(DESTDIR)$(datadir)/nix/manual
|
||||
cp -r images $(DESTDIR)$(datadir)/nix/manual/images
|
||||
|
||||
images:
|
||||
mkdir images
|
||||
cp $(docbookxsl)/images/*.png images
|
||||
mkdir images/callouts
|
||||
cp $(docbookxsl)/images/callouts/*.png images/callouts
|
||||
chmod +w -R images
|
||||
|
||||
KEEP = manual.html manual.is-valid version.xml $(MANS)
|
||||
|
||||
EXTRA_DIST = $(SOURCES) $(KEEP)
|
||||
|
||||
DISTCLEANFILES = $(KEEP)
|
||||
@@ -0,0 +1,115 @@
|
||||
<appendix>
|
||||
<title>Bugs / To-Do</title>
|
||||
|
||||
<itemizedlist>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
The man-pages generated from the DocBook documentation are ugly.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Generations properly form a tree. E.g., if after switching to
|
||||
generation 39, we perform an installation action, a generation
|
||||
43 is created which is a descendant of 39, not 42. So a
|
||||
rollback from 43 ought to go back to 39. This is not
|
||||
currently implemented; generations form a linear sequence.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Unify the concepts of successors and substitutes into a
|
||||
general notion of <emphasis>equivalent expressions</emphasis>.
|
||||
Expressions are equivalent if they have the same target paths
|
||||
with the same identifiers. However, even though they are
|
||||
functionally equivalent, they may differ stronly with respect
|
||||
to their <emphasis>performance characteristics</emphasis>.
|
||||
For example, realising a closure expression is more efficient
|
||||
that realising the derivation expression from which it was
|
||||
produced. On the other hand, distributing sources may be more
|
||||
efficient (storage- or bandwidth-wise) than distributing
|
||||
binaries. So we need to be able to attach weigths or
|
||||
priorities or performance annotations to expressions; Nix can
|
||||
then choose the most efficient expression dependent on the
|
||||
context.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<emphasis>Build management.</emphasis> In principle it is already
|
||||
possible to do build management using Nix (by writing builders that
|
||||
perform appropriate build steps), but the Nix expression language is
|
||||
not yet powerful enough to make this pleasant (?). The language should
|
||||
be extended with features from the <ulink
|
||||
url='http://www.cs.uu.nl/~eelco/maak/'>Maak build manager</ulink>.
|
||||
Another interesting idea is to write a <command>make</command>
|
||||
implementation that uses Nix as a back-end to support <ulink
|
||||
url='http://www.research.att.com/~bs/bs_faq.html#legacy'>legacy</ulink>
|
||||
build files.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
The current garbage collector is a hack. It should be
|
||||
integrated into <command>nix-store</command>. It should
|
||||
delete derivations in an order determined by topologically
|
||||
sorting derivations under the points-to relation. This
|
||||
ensures that no store paths ever exist that point to
|
||||
non-existant store paths.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
There are race conditions between the garbage collector and
|
||||
other Nix tools. For instance, when we run
|
||||
<command>nix-env</command> to build and install a derivation
|
||||
and run the garbage collector at the same time, the garbage
|
||||
collector may kick in exactly between the build and
|
||||
installation steps, i.e., before the newly built derivation
|
||||
has become reachable from a root of the garbage collector.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
One solution would be for these programs to properly register
|
||||
temporary roots for the collector. Another would be to use
|
||||
stop-the-world garbage collection: if any tool is running, the
|
||||
garbage collector blocks, and vice versa. These solutions do
|
||||
not solve the situation where multiple tools are involved,
|
||||
e.g.,
|
||||
|
||||
<screen>
|
||||
$ nix-store -r $(nix-instantiate foo.nix)</screen>
|
||||
|
||||
since even if <command>nix-instantiate</command> where to
|
||||
register a temporary root, it would be released by the time
|
||||
<command>nix-store</command> is started. A solution would be
|
||||
to write the intermediate value to a file that is used as a
|
||||
root to the collector, e.g.,
|
||||
|
||||
<screen>
|
||||
$ nix-instantiate foo.nix > /nix/var/nix/roots/bla
|
||||
$ nix-store -r $(cat /nix/var/nix/roots/bla)</screen>
|
||||
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
For security, <command>nix-push</command> manifests should be
|
||||
digitally signed, and <command>nix-pull</command> should
|
||||
verify the signatures. The actual NAR archives in the cache
|
||||
do not need to be signed, since the manifest contains
|
||||
cryptographic hashes of these files (and
|
||||
<filename>fetchurl.nix</filename> checks them).
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
</itemizedlist>
|
||||
|
||||
</appendix>
|
||||
@@ -0,0 +1,211 @@
|
||||
<chapter id='chap-installation'>
|
||||
<title>Installation</title>
|
||||
|
||||
<sect1>
|
||||
<title>Obtaining Nix</title>
|
||||
|
||||
<para>
|
||||
The easiest way to obtain Nix is to download a <ulink
|
||||
url='http://www.cs.uu.nl/groups/ST/Trace/Nix'>source
|
||||
distribution</ulink>. RPMs for SuSE and Red Hat are also
|
||||
available. These distributions are generated automatically.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Alternatively, the most recent sources of Nix can be obtained from its
|
||||
<ulink url='https://svn.cs.uu.nl:12443/repos/trace/nix/trunk'>Subversion
|
||||
repository</ulink>. For example, the following command will check out
|
||||
the latest revision into a directory called <filename>nix</filename>:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
$ svn checkout https://svn.cs.uu.nl:12443/repos/trace/nix/trunk nix</screen>
|
||||
|
||||
<para>
|
||||
Likewise, specific releases can be obtained from the <ulink
|
||||
url='https://svn.cs.uu.nl:12443/repos/trace/nix/tags'>tags
|
||||
directory</ulink> of the repository. If you don't have Subversion, you
|
||||
can also download an automatically generated <ulink
|
||||
url='https://svn.cs.uu.nl:12443/dist/trace/'>compressed
|
||||
tar-file</ulink> of the head revision of the trunk.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1>
|
||||
<title>Prerequisites</title>
|
||||
|
||||
<para>
|
||||
The following prerequisites only apply when you build from
|
||||
source. Binary releases (e.g., RPMs) have no prerequisites.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A fairly recent version of GCC/G++ is required. Version 2.95
|
||||
and higher should work.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To build this manual and the man-pages you need the
|
||||
<command>xmllint</command> and <command>xsltproc</command>
|
||||
programs, which are part of the <literal>libxml2</literal> and
|
||||
<literal>libxslt</literal> packages, respectively. You also
|
||||
need the <ulink
|
||||
url='http://docbook.sourceforge.net/projects/xsl/'>DocBook XSL
|
||||
stylesheets</ulink> and optionally the <ulink
|
||||
url='http://www.oasis-open.org/docbook/xml/4.2/docbook-xml-4.2.zip'>
|
||||
DocBook XML 4.2 DTD</ulink>. Note that these are only required
|
||||
if you modify the manual sources or when you are building from
|
||||
the Subversion repository.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To build the parser, very <emphasis>recent</emphasis> versions
|
||||
of Bison and Flex are required. (This is because Nix needs GLR
|
||||
support in Bison and reentrancy support in Flex.) For Bison,
|
||||
you need version 1.875c or higher (1.875 does
|
||||
<emphasis>not</emphasis> work), which can be obtained from the
|
||||
<ulink url='ftp://alpha.gnu.org/pub/gnu/bison'>GNU FTP
|
||||
server</ulink>. For Flex, you need version 2.5.31, which is
|
||||
available on <ulink
|
||||
url='http://lex.sourceforge.net/'>SourceForge</ulink>. Slightly
|
||||
older versions may also work, but ancient versions like the
|
||||
ubiquitous 2.5.4a won't. Note that these are only required if
|
||||
you modify the parser or when you are building from the
|
||||
Subversion repository.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Nix uses Sleepycat's Berkeley DB and CWI's ATerm library. These
|
||||
are included in the Nix source distribution. If you build from
|
||||
the Subversion repository, you must download them yourself and
|
||||
place them in the <filename>externals/</filename> directory.
|
||||
See <filename>externals/Makefile.am</filename> for the precise
|
||||
URLs of these packages.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<sect1>
|
||||
<title>Building Nix from source</title>
|
||||
|
||||
<para>
|
||||
After unpacking or checking out the Nix sources, issue the following
|
||||
commands:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
$ ./configure <replaceable>options...</replaceable>
|
||||
$ make
|
||||
$ make install</screen>
|
||||
|
||||
<para>
|
||||
When building from the Subversion repository, these should be preceded by
|
||||
the command:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
$ autoreconf -i</screen>
|
||||
|
||||
<para>
|
||||
The installation path can be specified by passing the
|
||||
<option>--prefix=<replaceable>prefix</replaceable></option> to
|
||||
<command>configure</command>. The default installation directory is
|
||||
<filename>/nix</filename>. You can change this to any location you like.
|
||||
You must have write permission to the <replaceable>prefix</replaceable>
|
||||
path.
|
||||
</para>
|
||||
|
||||
<warning>
|
||||
<para>
|
||||
It is advisable <emphasis>not</emphasis> to change the installation
|
||||
prefix from its default, since doing so will in all likelihood make it
|
||||
impossible to use derivations built on other systems.
|
||||
</para>
|
||||
</warning>
|
||||
|
||||
<para>
|
||||
If you want to rebuilt the documentation, pass the full path to the
|
||||
DocBook XML catalog file (<filename>docbook.cat</filename>) and to the
|
||||
DocBook XSL stylesheets using the
|
||||
<option>--with-docbook-catalog=<replaceable>path</replaceable></option>
|
||||
and <option>--with-docbook-xsl=<replaceable>path</replaceable></option>
|
||||
options.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
||||
<sect1>
|
||||
<title>Installing from RPMs</title>
|
||||
|
||||
<para>
|
||||
RPM packages of Nix can be downloaded from <ulink
|
||||
url='http://www.cs.uu.nl/groups/ST/Trace/Nix' />. These RPMs
|
||||
should work for most fairly recent releases of SuSE and Red Hat
|
||||
Linux. They have been known to work work on SuSE Linux 8.1 and
|
||||
9.0, and Red Hat 9.0. In fact, it should work on any RPM-based
|
||||
Linux distribution based on <literal>glibc</literal> 2.3 or
|
||||
later.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Once downloaded, the RPMs can be installed or upgraded using
|
||||
<command>rpm -U</command>. For example,
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
rpm -U nix-0.5pre664-1.i386.rpm</screen>
|
||||
|
||||
<para>
|
||||
The RPMs install into the directory <filename>/nix</filename>.
|
||||
Nix can be uninstalled using <command>rpm -e nix</command>.
|
||||
After this it will be necessary to manually remove the Nix store
|
||||
and other auxiliary data:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
rm -rf /nix/store
|
||||
rm -rf /nix/var</screen>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1>
|
||||
<title>Permissions</title>
|
||||
|
||||
<para>
|
||||
All Nix operations must be performed under the user ID that owns
|
||||
the Nix store and database
|
||||
(<filename><replaceable>prefix</replaceable>/store</filename>
|
||||
and
|
||||
<filename><replaceable>prefix</replaceable>/var/nix/db</filename>,
|
||||
respectively). When installed from the RPM packages, these
|
||||
directories are owned by <systemitem
|
||||
class='username'>root</systemitem>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1>
|
||||
<title>Using Nix</title>
|
||||
|
||||
<para>
|
||||
To use Nix, some environment variables should be set. In
|
||||
particular, <envar>PATH</envar> should contain the directories
|
||||
<filename><replaceable>prefix</replaceable>/bin</filename> and
|
||||
<filename>~/.nix-profile/bin</filename>. The first directory
|
||||
contains the Nix tools themselves, while
|
||||
<filename>~/.nix-profile</filename> is a symbolic link to the
|
||||
current <emphasis>user environment</emphasis> (an automatically
|
||||
generated package consisting of symlinks to installed packages).
|
||||
The simplest way to set the required environment variables is to
|
||||
include the file
|
||||
<filename><replaceable>prefix</replaceable>/etc/profile.d/nix.sh</filename>
|
||||
in your <filename>~/.bashrc</filename> (or similar), like this:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
. <replaceable>prefix</replaceable>/etc/profile.d/nix.sh</screen>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
@@ -0,0 +1,93 @@
|
||||
<chapter>
|
||||
<title>Introduction</title>
|
||||
|
||||
<epigraph>
|
||||
<para><quote>The number of Nix installations in the world has grown to 5,
|
||||
with more expected.</quote></para>
|
||||
</epigraph>
|
||||
|
||||
<para>
|
||||
Nix is a system for software deployment. It supports the
|
||||
creation and distribution of software packages, as well as the installation
|
||||
and subsequent management of these on target machines (i.e., it is also a
|
||||
package manager).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Nix solves some large problems that exist in most current deployment and
|
||||
package management systems. <emphasis>Dependency determination</emphasis>
|
||||
is a big one: the correct installation of a software component requires
|
||||
that all dependencies of that component (i.e., other components used by it)
|
||||
are also installed. Most systems have no way to verify that the specified
|
||||
dependencies of a component are actually sufficient.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Another big problem is the lack of support for concurrent availability of
|
||||
multiple <emphasis>variants</emphasis> of a component. It must be possible
|
||||
to have several versions of a component installed at the same time, or
|
||||
several instances of the same version built with different parameters.
|
||||
Unfortunately, components are in general not properly isolated from each
|
||||
other. For instance, upgrading a component that is a dependency for some
|
||||
other component might break the latter.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Nix solves these problems by building and storing packages in paths that
|
||||
are infeasible to predict in advance. For example, the artifacts of a
|
||||
package <literal>X</literal> might be stored in
|
||||
<filename>/nix/store/d58a0606ed616820de291d594602665d-X</filename>, rather
|
||||
than in, say, <filename>/usr/lib</filename>. The path component
|
||||
<filename>d58a...</filename> is actually a cryptographic hash of all the
|
||||
inputs (i.e., sources, requisites, and build flags) used in building
|
||||
<literal>X</literal>, and as such is very fragile: any change to the inputs
|
||||
will change the hash. Therefore it is not sensible to
|
||||
<emphasis>hard-code</emphasis> such a path into the build scripts of a
|
||||
package <literal>Y</literal> that uses <literal>X</literal> (as does happen
|
||||
with <quote>fixed</quote> paths such as <filename>/usr/lib</filename>).
|
||||
Rather, the build script of package <literal>Y</literal> is parameterised
|
||||
with the actual location of <literal>X</literal>, which is supplied by the
|
||||
Nix system.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
As stated above, the path name of a file system object contain a
|
||||
cryptographic hash of all inputs involved in building it. A change to any
|
||||
of the inputs will cause the hash to change--and by extension, the path
|
||||
name. These inputs include both sources (variation in time) and
|
||||
configuration options (variation in space). Therefore variants of the same
|
||||
package don't clash---they can co-exist peacefully within the same file
|
||||
system.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Other features:
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis>Transparent source/binary deployment.</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis>Unambiguous identification of configuration.</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis>Automatic storage management.</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis>Atomic upgrades and rollbacks.</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis>Support for many simultaneous configurations.</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis>Portability.</emphasis> Nix is quite portable. Contrary to
|
||||
build systems like those in, e.g., Vesta and ClearCase, it does not rely on
|
||||
operating system extensions.
|
||||
</para>
|
||||
|
||||
</chapter>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE book
|
||||
PUBLIC "-//OASIS//DTD DocBook EBNF Module V1.0//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/ebnf/1.0/dbebnf.dtd"
|
||||
[
|
||||
<!-- <!DOCTYPE book
|
||||
PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.docbook.org/xml/4.3/docbook-xml-4.3.zip" -->
|
||||
<!ENTITY introduction SYSTEM "introduction.xml">
|
||||
<!ENTITY quick-start SYSTEM "quick-start.xml">
|
||||
<!ENTITY installation SYSTEM "installation.xml">
|
||||
<!ENTITY overview SYSTEM "overview.xml">
|
||||
<!ENTITY opt-common SYSTEM "opt-common.xml">
|
||||
<!ENTITY opt-common-syn SYSTEM "opt-common-syn.xml">
|
||||
<!ENTITY nix-env SYSTEM "nix-env.xml">
|
||||
<!ENTITY nix-store SYSTEM "nix-store.xml">
|
||||
<!ENTITY nix-instantiate SYSTEM "nix-instantiate.xml">
|
||||
<!ENTITY nix-collect-garbage SYSTEM "nix-collect-garbage.xml">
|
||||
<!ENTITY nix-push SYSTEM "nix-push.xml">
|
||||
<!ENTITY nix-pull SYSTEM "nix-pull.xml">
|
||||
<!ENTITY nix-prefetch-url SYSTEM "nix-prefetch-url.xml">
|
||||
<!ENTITY nix-lang-ref SYSTEM "nix-lang-ref.xml">
|
||||
<!ENTITY troubleshooting SYSTEM "troubleshooting.xml">
|
||||
<!ENTITY bugs SYSTEM "bugs.xml">
|
||||
<!ENTITY version SYSTEM "version.xml">
|
||||
]>
|
||||
|
||||
<book>
|
||||
<title>Nix: A System for Software Deployment</title>
|
||||
|
||||
<subtitle>Draft (Version &version;)</subtitle>
|
||||
|
||||
<bookinfo>
|
||||
<author>
|
||||
<firstname>Eelco</firstname>
|
||||
<surname>Dolstra</surname>
|
||||
</author>
|
||||
<copyright>
|
||||
<year>2004</year>
|
||||
<holder>Eelco Dolstra</holder>
|
||||
</copyright>
|
||||
</bookinfo>
|
||||
|
||||
&introduction;
|
||||
&quick-start;
|
||||
&installation;
|
||||
&overview;
|
||||
|
||||
<appendix>
|
||||
<title>Command Reference</title>
|
||||
<sect1>
|
||||
<title>nix-env</title>
|
||||
&nix-env;
|
||||
</sect1>
|
||||
<sect1>
|
||||
<title>nix-store</title>
|
||||
&nix-store;
|
||||
</sect1>
|
||||
<sect1>
|
||||
<title>nix-instantiate</title>
|
||||
&nix-instantiate;
|
||||
</sect1>
|
||||
<sect1>
|
||||
<title>nix-collect-garbage</title>
|
||||
&nix-collect-garbage;
|
||||
</sect1>
|
||||
<sect1>
|
||||
<title>nix-push</title>
|
||||
&nix-push;
|
||||
</sect1>
|
||||
<sect1>
|
||||
<title>nix-pull</title>
|
||||
&nix-pull;
|
||||
</sect1>
|
||||
<sect1>
|
||||
<title>nix-prefetch-url</title>
|
||||
&nix-prefetch-url;
|
||||
</sect1>
|
||||
</appendix>
|
||||
|
||||
&nix-lang-ref;
|
||||
|
||||
&troubleshooting;
|
||||
&bugs;
|
||||
|
||||
</book>
|
||||
@@ -0,0 +1,75 @@
|
||||
<refentry>
|
||||
<refnamediv>
|
||||
<refname>nix-collect-garbage</refname>
|
||||
<refpurpose>determine the set of unreachable store paths</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>nix-collect-garbage</command>
|
||||
<arg><option>--invert</option></arg>
|
||||
<arg><option>--no-successors</option></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The command <command>nix-collect-garbage</command> determines
|
||||
the paths in the Nix store that are garbage, that is, not
|
||||
reachable from outside of the store. These paths can be safely
|
||||
deleted without affecting the integrity of the system.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Options</title>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--invert</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Causes the set of <emphasis>reachable</emphasis> paths to
|
||||
be printed, rather than the unreachable paths. These are
|
||||
the paths that may <emphasis>not</emphasis> be deleted.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--no-successors</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Causes <command>nix-collect-garbage</command> not to
|
||||
follow successor relations. By default, if a derivation
|
||||
store expression is reachable, its successor (i.e., a
|
||||
closure store expression) is also considered to be
|
||||
reachable. This option is always safe, but garbage
|
||||
collecting successors may cause undesirable rebuilds later
|
||||
on.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<para>
|
||||
To delete all unreachable paths, do the following:
|
||||
|
||||
<screen>
|
||||
$ nix-collect-garbage | xargs nix-store --delete</screen>
|
||||
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refentry>
|
||||
@@ -0,0 +1,859 @@
|
||||
<refentry>
|
||||
<refnamediv>
|
||||
<refname>nix-env</refname>
|
||||
<refpurpose>manipulate or query Nix user environments</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>nix-env</command>
|
||||
&opt-common-syn;
|
||||
<arg>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--file</option></arg>
|
||||
<arg choice='plain'><option>-f</option></arg>
|
||||
</group>
|
||||
<replaceable>path</replaceable>
|
||||
</arg>
|
||||
<arg>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--profile</option></arg>
|
||||
<arg choice='plain'><option>-p</option></arg>
|
||||
</group>
|
||||
<replaceable>path</replaceable>
|
||||
</arg>
|
||||
<arg><option>--dry-run</option></arg>
|
||||
<arg choice='plain'><replaceable>operation</replaceable></arg>
|
||||
<arg rep='repeat'><replaceable>options</replaceable></arg>
|
||||
<arg rep='repeat'><replaceable>arguments</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The command <command>nix-env</command> is used to manipulate Nix
|
||||
user environments. User environments are sets of software
|
||||
components available to a user at some point in time. In other
|
||||
words, they are a synthesised view of the programs available in
|
||||
the Nix store. There may be many user environments: different
|
||||
users can have different environments, and individual users can
|
||||
switch between different environments.
|
||||
</para>
|
||||
|
||||
<!-- <para>
|
||||
Environments are manipulated by operations such as the
|
||||
installation and removal of components (hereafter called
|
||||
<emphasis>derivations</emphasis>). These operations are not
|
||||
destructive: rather than overwrite the current environment, they
|
||||
create a new environment to which we can then atomically
|
||||
<emphasis>switch</emphasis> by flipping a symlink.
|
||||
</para> -->
|
||||
|
||||
<para>
|
||||
<command>nix-env</command> takes exactly one
|
||||
<emphasis>operation</emphasis> flag which indicates the
|
||||
subcommand to be performed. These are documented below.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Common options</title>
|
||||
|
||||
<para>
|
||||
This section lists the options that are common to all
|
||||
operations. These options are allowed for every subcommand,
|
||||
though they may not always have an effect.
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
|
||||
&opt-common;
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--file</option> / <option>-f</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the Nix expression (designated below as the
|
||||
<emphasis>active Nix expression</emphasis>) used by the
|
||||
<option>--install</option>, <option>--upgrade</option>,
|
||||
and <option>--query --available</option> operations to
|
||||
obtain derivations. The default is
|
||||
<filename>~/.nix-defexpr</filename>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--profile</option> / <option>-p</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the profile to be used by those operations that
|
||||
operate on a profile (designated below as the
|
||||
<emphasis>active profile</emphasis>). A profile is
|
||||
sequence of user environments called
|
||||
<emphasis>generations</emphasis>, one of which is the
|
||||
<emphasis>current generation</emphasis>. The default
|
||||
profile is the target of the symbolic link
|
||||
<filename>~/.nix-profile</filename> (see below).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--dry-run</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
For the <option>--install</option>,
|
||||
<option>--upgrade</option>, <option>--uninstall</option>,
|
||||
<option>--switch-generation</option> and
|
||||
<option>--rollback</option> operations, this flag will
|
||||
cause <command>nix-env</command> to print what
|
||||
<emphasis>would</emphasis> be done if this flag had not
|
||||
been specified, without actually doing it.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Files</title>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><filename>~/.nix-defexpr</filename></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The default Nix expression used by the
|
||||
<option>--install</option>, <option>--upgrade</option>,
|
||||
and <option>--query --available</option> operations to
|
||||
obtain derivations. It is generally a symbolic link to
|
||||
some other location set using the
|
||||
<option>--import</option> operation. The
|
||||
<option>--file</option> option may be used to override
|
||||
this default.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><filename>~/.nix-profile</filename></term>
|
||||
<listitem>
|
||||
<para>
|
||||
A symbolic link to the user's current profile. By
|
||||
default, this symlink points to
|
||||
<filename><replaceable>prefix</replaceable>/var/nix/profiles/default</filename>.
|
||||
The <envar>PATH</envar> environment variable should
|
||||
include <filename>~/.nix-profile/bin</filename> for the
|
||||
user environment to be visible to the user.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--install</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-env</command>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--install</option></arg>
|
||||
<arg choice='plain'><option>-i</option></arg>
|
||||
</group>
|
||||
<group choice='opt'>
|
||||
<arg choice='plain'><option>--preserve-installed</option></arg>
|
||||
<arg choice='plain'><option>-P</option></arg>
|
||||
</group>
|
||||
<arg choice='plain' rep='repeat'><replaceable>drvnames</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The install operation creates a new user environment, based on
|
||||
the current generation of the active profile, to which the
|
||||
derivations designated by <replaceable>drvnames</replaceable>
|
||||
in the active Nix expression are added.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Currently installed derivations with a name equal to the name
|
||||
of a derivation being added are removed unless the option
|
||||
<option>--preserve-installed</option> is specified.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Flags</title>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--preserve-installed</option> / <option>-P</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Do not remove derivations with a name matching one of
|
||||
the derivations being installed. Usually, trying to
|
||||
have two versions of the same package installed in the
|
||||
same generation of a profile will lead to an error in
|
||||
building the generation, due to file name clashes
|
||||
between the two versions. However, this is not the case
|
||||
for all packages.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-env --install gcc-3.3.2 <lineannotation>(install specific version)</lineannotation>
|
||||
installing `gcc-3.3.2'
|
||||
uninstalling `gcc-3.1' <lineannotation>(previously installed version is removed)</lineannotation>
|
||||
|
||||
$ nix-env --install gcc <lineannotation>(just pick any version)</lineannotation>
|
||||
|
||||
$ nix-env -f ~/foo.nix -i '*' <lineannotation>(install everything in <filename>foo.nix</filename>)</lineannotation></screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--upgrade</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-env</command>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--upgrade</option></arg>
|
||||
<arg choice='plain'><option>-u</option></arg>
|
||||
</group>
|
||||
<group choice='opt'>
|
||||
<arg choice='plain'><option>--lt</option></arg>
|
||||
<arg choice='plain'><option>--leq</option></arg>
|
||||
<arg choice='plain'><option>--always</option></arg>
|
||||
</group>
|
||||
<arg choice='plain' rep='repeat'><replaceable>drvnames</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The upgrade operation creates a new user environment, based on
|
||||
the current generation of the active profile, in which all
|
||||
derivations designated by <replaceable>drvnames</replaceable>
|
||||
for which there are newer versions in the active Nix
|
||||
expression are replaced by those newer versions. Matching
|
||||
derivations for which there are no newer versions are left
|
||||
untouched; this is not an error. It is also not an error if
|
||||
an element of <replaceable>drvnames</replaceable> matches no
|
||||
installed derivations.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If multiple derivations in the active Nix expression match an
|
||||
installed derivation, the one with the highest version is
|
||||
selected.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Flags</title>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--lt</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Only upgrade a derivation to newer versions. This is
|
||||
the default.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--leq</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
In addition to upgrading to newer versions, also
|
||||
<quote>upgrade</quote> to derivations that have the same
|
||||
version. Version are not a unique identification of a
|
||||
derivation, so there may be many derivations that have
|
||||
the same version. This flag may be useful to force
|
||||
<quote>synchronisation</quote> between the installed and
|
||||
available derivations.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--always</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
In addition to upgrading to newer versions, also
|
||||
<quote>upgrade</quote> to derivations that have the same
|
||||
or a lower version. I.e., derivations may actually be
|
||||
downgraded depending on what is available in the active
|
||||
Nix expression.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-env --upgrade gcc
|
||||
upgrading `gcc-3.3.1' to `gcc-3.4'
|
||||
|
||||
$ nix-env -u gcc-3.3.2 --always <lineannotation>(switch to a specific version)</lineannotation>
|
||||
upgrading `gcc-3.4' to `gcc-3.3.2'
|
||||
|
||||
$ nix-env --upgrade pan
|
||||
<lineannotation>(no upgrades available, so nothing happens)</lineannotation>
|
||||
|
||||
$ nix-env -u '*' <lineannotation>(try to upgrade everything)</lineannotation>
|
||||
upgrading `hello-2.1.2' to `hello-2.1.3'
|
||||
upgrading `mozilla-1.2' to `mozilla-1.4'</screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Versions</title>
|
||||
|
||||
<para>
|
||||
The upgrade operation determines whether a derivation
|
||||
<varname>y</varname> is an upgrade of a derivation
|
||||
<varname>x</varname> by looking at their respective
|
||||
<literal>name</literal> attributes. The names (e.g.,
|
||||
<literal>gcc-3.3.1</literal> are split into two parts: the
|
||||
package name (<literal>gcc</literal>), and the version
|
||||
(<literal>3.3.1</literal>). The version part starts after the
|
||||
first dash not following by a letter. <varname>x</varname> is
|
||||
considered an upgrade of <varname>y</varname> if their package
|
||||
names match, and the version of <varname>y</varname> is higher
|
||||
that that of <varname>x</varname>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The versions are compared by splitting them into contiguous
|
||||
components of numbers and letters. E.g.,
|
||||
<literal>3.3.1pre5</literal> is split into <literal>[3, 3, 1,
|
||||
"pre", 5]</literal>. These lists are then compared
|
||||
lexicographically (from left to right). Corresponding
|
||||
components <varname>a</varname> and <varname>b</varname> are
|
||||
compared as follows. If they are both numbers, integer
|
||||
comparison is used. If <varname>a</varname> is an empty
|
||||
string and <varname>b</varname> is a number,
|
||||
<varname>a</varname> is considered less than
|
||||
<varname>b</varname>. The special string component
|
||||
<literal>pre</literal> (for <emphasis>pre-release</emphasis>)
|
||||
is considered to be less than other components. String
|
||||
components are considered less than number components.
|
||||
Otherwise, they are compared lexicographically (i.e., using
|
||||
case-sensitive string comparison).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This is illustrated by the following examples:
|
||||
|
||||
<screen>
|
||||
1.0 < 2.3
|
||||
2.1 < 2.3
|
||||
2.3 = 2.3
|
||||
2.5 > 2.3
|
||||
3.1 > 2.3
|
||||
2.3.1 > 2.3
|
||||
2.3.1 > 2.3a
|
||||
2.3pre1 < 2.3
|
||||
2.3pre3 < 2.3pre12
|
||||
2.3a < 2.3c
|
||||
2.3pre1 < 2.3c
|
||||
2.3pre1 < 2.3q</screen>
|
||||
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--uninstall</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-env</command>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--uninstall</option></arg>
|
||||
<arg choice='plain'><option>-e</option></arg>
|
||||
</group>
|
||||
<arg choice='plain' rep='repeat'><replaceable>drvnames</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The uninstall operation creates a new user environment, based
|
||||
on the current generation of the active profile, from which the
|
||||
derivations designated by <replaceable>drvnames</replaceable>
|
||||
are removed.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-env --uninstall gcc
|
||||
$ nix-env -e '*' <lineannotation>(remove everything)</lineannotation></screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--query</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-env</command>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--query</option></arg>
|
||||
<arg choice='plain'><option>-q</option></arg>
|
||||
</group>
|
||||
<group choice='opt'>
|
||||
<arg choice='plain'><option>--installed</option></arg>
|
||||
<arg choice='plain'><option>--available</option></arg>
|
||||
<arg choice='plain'><option>-a</option></arg>
|
||||
</group>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--name</option></arg>
|
||||
<arg choice='plain'><option>--expr</option></arg>
|
||||
<arg choice='plain'><option>--status</option></arg>
|
||||
<arg choice='plain'><option>-s</option></arg>
|
||||
</group>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The query operation displays information about either the
|
||||
derivations that are installed in the current generation of
|
||||
the active profile (<option>--installed</option>), or the
|
||||
derivations that are available for installation in the active
|
||||
Nix expression (<option>--available</option>).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The derivations are sorted by their <literal>name</literal>
|
||||
attributes.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Source selection</title>
|
||||
|
||||
<para>
|
||||
The following flags specify the set of derivations on which
|
||||
the query operates.
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--installed</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The query operates on the derivations that are installed
|
||||
in the current generation of the active profile. This
|
||||
is the default
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--available</option> / <option>-a</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The query operates on the derivations that are available
|
||||
in the active Nix expression.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Queries</title>
|
||||
|
||||
<para>
|
||||
The following flags specify what information to display about
|
||||
the selected derivations. Only one type of query may be
|
||||
specified.
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--name</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Prints the <literal>name</literal> attribute of each
|
||||
derivation. This is the default.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--expr</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Prints the store expression in the Nix store that
|
||||
described the derivation.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--status</option> / <option>-s</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Prints the <emphasis>status</emphasis> of each
|
||||
derivation, followed by its <literal>name</literal>
|
||||
attribute. The status consists of three characters.
|
||||
The first is <literal>I</literal> or
|
||||
<literal>-</literal>, indicating whether the derivation
|
||||
is currently installed in the current generation of the
|
||||
active profile. This is by definition the case for
|
||||
<option>--installed</option>, but not for
|
||||
<option>--available</option>. The second is
|
||||
<literal>P</literal> or <literal>-</literal>, indicating
|
||||
whether the derivation is present on the system. This
|
||||
indicates whether installation of an available
|
||||
derivation will require the derivation to be built. The
|
||||
third is <literal>S</literal> or <literal>-</literal>,
|
||||
indicating whether a substitute is available for the
|
||||
derivation.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-env -q <lineannotation>(show installed derivations)</lineannotation>
|
||||
MozillaFirebird-0.7
|
||||
bison-1.875c
|
||||
docbook-xml-4.2
|
||||
...
|
||||
|
||||
$ nix-env -qa <lineannotation>(show available derivations)</lineannotation>
|
||||
GConf-2.4.0.1
|
||||
MPlayer-1.0pre3
|
||||
MozillaFirebird-0.7
|
||||
ORBit2-2.8.3
|
||||
...
|
||||
|
||||
$ nix-env -qas <lineannotation>(show status of available derivations)</lineannotation>
|
||||
-P- GConf-2.4.0.1 <lineannotation>(not installed but present)</lineannotation>
|
||||
--S MPlayer-1.0pre3 <lineannotation>(not present, but there is a substitute for fast installation)</lineannotation>
|
||||
--S MozillaFirebird-0.7 <lineannotation>(i.e., this is not the installed Firebird, even though the version is the same!)</lineannotation>
|
||||
IP- bison-1.875c <lineannotation>(installed and by definition present)</lineannotation>
|
||||
...
|
||||
|
||||
$ nix-env -f ./foo.nix -qa <lineannotation>(show available derivations in the Nix expression <filename>foo.nix</filename>)</lineannotation>
|
||||
foo-1.2.3</screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--switch-profile</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-env</command>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--switch-profile</option></arg>
|
||||
<arg choice='plain'><option>-S</option></arg>
|
||||
</group>
|
||||
<arg choice='req'><replaceable>path</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
This operation makes <replaceable>path</replaceable> the
|
||||
current profile for the user. That is, the symlink
|
||||
<filename>~/.nix-profile</filename> is made to point to
|
||||
<replaceable>path</replaceable>.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-env -S ~/my-profile</screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--list-generations</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-env</command>
|
||||
<arg choice='req'><option>--list-generations</option></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
This operation print a list of all the currently existing
|
||||
generations for the active profile. These may be switched to
|
||||
using the <option>--switch-generation</option> operation. It
|
||||
also prints the creation date of the generation, and indicates
|
||||
the current generation.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-env --list-generations
|
||||
95 2004-02-06 11:48:24
|
||||
96 2004-02-06 11:49:01
|
||||
97 2004-02-06 16:22:45
|
||||
98 2004-02-06 16:24:33 (current)</screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--switch-generation</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-env</command>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--switch-generation</option></arg>
|
||||
<arg choice='plain'><option>-G</option></arg>
|
||||
</group>
|
||||
<arg choice='req'><replaceable>generation</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
This operation makes generation number
|
||||
<replaceable>generation</replaceable> the current generation
|
||||
of the active profile. That is, if the
|
||||
<filename><replaceable>profile</replaceable></filename> is the
|
||||
path to the active profile, then the symlink
|
||||
<filename><replaceable>profile</replaceable></filename> is
|
||||
made to point to
|
||||
<filename><replaceable>profile</replaceable>-<replaceable>generation</replaceable>-link</filename>,
|
||||
which is in turn a symlink to the actual user environment in
|
||||
the Nix store.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Switching will fail if the specified generation does not
|
||||
exist.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-env -G 42
|
||||
switching from generation 50 to 42</screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--rollback</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-env</command>
|
||||
<arg choice='req'><option>--rollback</option></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
This operation switches to the <quote>previous</quote>
|
||||
generation of the active profile, that is, the highest
|
||||
numbered generation lower than the current generation, if it
|
||||
exists. It is just a convenience wrapper around
|
||||
<option>--list-generations</option> and
|
||||
<option>--switch-generation</option>.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-env --rollback
|
||||
switching from generation 92 to 91
|
||||
|
||||
$ nix-env --rolback
|
||||
error: no generation older than the current (91) exists</screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--import</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-env</command>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--import</option></arg>
|
||||
<arg choice='plain'><option>-I</option></arg>
|
||||
</group>
|
||||
<arg choice='req'><replaceable>path</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
This operation makes <replaceable>path</replaceable> the
|
||||
default active Nix expression for the user. That is, the
|
||||
symlink <filename>~/.nix-userenv</filename> is made to point
|
||||
to <replaceable>path</replaceable>.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-env -I ~/nixpkgs-0.5/</screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
</refentry>
|
||||
@@ -0,0 +1,65 @@
|
||||
<refentry>
|
||||
<refnamediv>
|
||||
<refname>nix-instantiate</refname>
|
||||
<refpurpose>instantiate store expressions from Nix expressions</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>nix-instantiate</command>
|
||||
&opt-common-syn;
|
||||
<arg choice='plain' rep='repeat'><replaceable>files</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The command <command>nix-instantiate</command> generates
|
||||
(low-level) store expressions from (high-level) Nix expressions.
|
||||
It loads and evaluates the Nix expressions in each of
|
||||
<replaceable>files</replaceable>. Each top-level expression
|
||||
should evaluate to a derivation, a list of derivations, or a set
|
||||
of derivations. The paths of the resulting store expressions
|
||||
are printed on standard output.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This command is generally used for testing Nix expression before
|
||||
they are used with <command>nix-env</command>.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Options</title>
|
||||
|
||||
<variablelist>
|
||||
|
||||
&opt-common;
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-instantiate gcc.nix <lineannotation>(instantiate)</lineannotation>
|
||||
/nix/store/468abdcb93aa22bb721142615b97698b-d-gcc-3.3.2.store
|
||||
|
||||
$ nix-store -r $(nix-instantiate gcc.nix) <lineannotation>(build)</lineannotation>
|
||||
|
||||
$ nix-store -r $(nix-instantiate gcc.nix) <lineannotation>(print output path)</lineannotation>
|
||||
/nix/store/9afa718cddfdfe94b5b9303d0430ceb1-gcc-3.3.2
|
||||
|
||||
$ ls -l /nix/store/9afa718cddfdfe94b5b9303d0430ceb1-gcc-3.3.2
|
||||
dr-xr-xr-x 2 eelco users 360 2003-12-01 16:12 bin
|
||||
dr-xr-xr-x 3 eelco users 72 2003-12-01 16:12 include
|
||||
...</screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refentry>
|
||||
@@ -0,0 +1,277 @@
|
||||
<chapter>
|
||||
<title>Nix Language Reference</title>
|
||||
|
||||
<sect1>
|
||||
<title>Grammar</title>
|
||||
|
||||
<productionset>
|
||||
<title>Expressions</title>
|
||||
|
||||
<production id="nix.expr">
|
||||
<lhs>Expr</lhs>
|
||||
<rhs>
|
||||
<nonterminal def="#nix.expr_function" />
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.expr_function">
|
||||
<lhs>ExprFunction</lhs>
|
||||
<rhs>
|
||||
'{' <nonterminal def="#nix.formals" /> '}' ':' <nonterminal def="#nix.expr_function" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_assert" />
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.expr_assert">
|
||||
<lhs>ExprAssert</lhs>
|
||||
<rhs>
|
||||
'assert' <nonterminal def="#nix.expr" /> ';' <nonterminal def="#nix.expr_assert" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_if" />
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.expr_if">
|
||||
<lhs>ExprIf</lhs>
|
||||
<rhs>
|
||||
'if' <nonterminal def="#nix.expr" /> 'then' <nonterminal def="#nix.expr" />
|
||||
'else' <nonterminal def="#nix.expr" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_op" />
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.expr_op">
|
||||
<lhs>ExprOp</lhs>
|
||||
<rhs>
|
||||
'!' <nonterminal def="#nix.expr_op" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_op" /> '==' <nonterminal def="#nix.expr_op" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_op" /> '!=' <nonterminal def="#nix.expr_op" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_op" /> '&&' <nonterminal def="#nix.expr_op" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_op" /> '||' <nonterminal def="#nix.expr_op" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_op" /> '->' <nonterminal def="#nix.expr_op" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_op" /> '//' <nonterminal def="#nix.expr_op" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_op" /> '~' <nonterminal def="#nix.expr_op" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_op" /> '?' <nonterminal def="#nix.id" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_app" />
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.expr_app">
|
||||
<lhs>ExprApp</lhs>
|
||||
<rhs>
|
||||
<nonterminal def="#nix.expr_app" /> '.' <nonterminal def="#nix.expr_select" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_select" />
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.expr_select">
|
||||
<lhs>ExprSelect</lhs>
|
||||
<rhs>
|
||||
<nonterminal def="#nix.expr_select" /> <nonterminal def="#nix.id" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.expr_simple" />
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.expr_simple">
|
||||
<lhs>ExprSimple</lhs>
|
||||
<rhs>
|
||||
<nonterminal def="#nix.id" /> |
|
||||
<nonterminal def="#nix.int" /> |
|
||||
<nonterminal def="#nix.str" /> |
|
||||
<nonterminal def="#nix.path" /> |
|
||||
<nonterminal def="#nix.uri" />
|
||||
<sbr />|
|
||||
'true' | 'false' | 'null'
|
||||
<sbr />|
|
||||
'(' <nonterminal def="#nix.expr" /> ')'
|
||||
<sbr />|
|
||||
'{' <nonterminal def="#nix.bind" />* '}'
|
||||
<sbr />|
|
||||
'let' '{' <nonterminal def="#nix.bind" />* '}'
|
||||
<sbr />|
|
||||
'rec' '{' <nonterminal def="#nix.bind" />* '}'
|
||||
<sbr />|
|
||||
'[' <nonterminal def="#nix.expr_select" />* ']'
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.bind">
|
||||
<lhs>Bind</lhs>
|
||||
<rhs>
|
||||
<nonterminal def="#nix.id" /> '=' <nonterminal def="#nix.expr" /> ';'
|
||||
<sbr />|
|
||||
'inherit' ('(' <nonterminal def="#nix.expr" /> ')')? <nonterminal def="#nix.id" />* ';'
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.formals">
|
||||
<lhs>Formals</lhs>
|
||||
<rhs>
|
||||
<nonterminal def="#nix.formal" /> ',' <nonterminal def="#nix.formals" />
|
||||
| <nonterminal def="#nix.formal" />
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.formal">
|
||||
<lhs>Formal</lhs>
|
||||
<rhs>
|
||||
<nonterminal def="#nix.id" />
|
||||
<sbr />|
|
||||
<nonterminal def="#nix.id" /> '?' <nonterminal def="#nix.expr" />
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
</productionset>
|
||||
|
||||
<productionset>
|
||||
<title>Terminals</title>
|
||||
|
||||
<production id="nix.id">
|
||||
<lhs>Id</lhs>
|
||||
<rhs>[a-zA-Z\_][a-zA-Z0-9\_\']*</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.int">
|
||||
<lhs>Int</lhs>
|
||||
<rhs>[0-9]+</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.str">
|
||||
<lhs>Str</lhs>
|
||||
<rhs>\"[^\n\"]*\"</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.path">
|
||||
<lhs>Path</lhs>
|
||||
<rhs>[a-zA-Z0-9\.\_\-\+]*(\/[a-zA-Z0-9\.\_\-\+]+)+</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.uri">
|
||||
<lhs>Uri</lhs>
|
||||
<rhs>[a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*\']+</rhs>
|
||||
</production>
|
||||
|
||||
<production id="nix.ws">
|
||||
<lhs>Whitespace</lhs>
|
||||
<rhs>
|
||||
[ \t\n]+
|
||||
<sbr />|
|
||||
\#[^\n]*
|
||||
<sbr />|
|
||||
\/\*(.|\n)*\*\/
|
||||
</rhs>
|
||||
</production>
|
||||
|
||||
</productionset>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
||||
|
||||
<sect1>
|
||||
<title>Semantics</title>
|
||||
|
||||
|
||||
|
||||
<sect2>
|
||||
<title>Built-in functions</title>
|
||||
|
||||
<para>
|
||||
The Nix language provides the following built-in function
|
||||
(<quote>primops</quote>):
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><function>import</function>
|
||||
<replaceable>e</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Evaluates the expression <replaceable>e</replaceable>,
|
||||
which must yield a path value. The Nix expression
|
||||
stored at this path in the file system is then read,
|
||||
parsed, and evaluated. Returns the result of the
|
||||
evaluation of the Nix expression just read.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Example: <literal>import ./foo.nix</literal> evaluates
|
||||
the expression stored in <filename>foo.nix</filename>
|
||||
(in the directory containing the expression in which the
|
||||
<function>import</function> occurs).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><function>derivation</function>
|
||||
<replaceable>e</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Evaluates the expression <replaceable>e</replaceable>,
|
||||
which must yield an attribute set. [...]
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><function>baseNameOf</function>
|
||||
<replaceable>e</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Evaluates the expression <replaceable>e</replaceable>,
|
||||
which must yield a string value, and returns a string
|
||||
representing its <emphasis>base name</emphasis>. This
|
||||
is the substring following the last path separator
|
||||
(<literal>/</literal>).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Example: <literal>baseNameOf "/foo/bar"</literal>
|
||||
returns <literal>"bar"</literal>, and
|
||||
<literal>baseNameOf "/foo/bar/"</literal> returns
|
||||
<literal>""</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><function>toString</function>
|
||||
<replaceable>e</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Evaluates the expression <replaceable>e</replaceable>
|
||||
and coerces it into a string, if possible. Only
|
||||
strings, paths, and URIs can be so coerced.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Example: <literal>toString
|
||||
http://www.cs.uu.nl/</literal> returns
|
||||
<literal>"http://www.cs.uu.nl/"</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
||||
</chapter>
|
||||
@@ -0,0 +1,54 @@
|
||||
<refentry>
|
||||
<refnamediv>
|
||||
<refname>nix-prefetch-url</refname>
|
||||
<refpurpose>copy a file from a URL into the store and print its MD5 hash</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>nix-prefetch-url</command>
|
||||
<arg choice='plain'><replaceable>url</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The command <command>nix-prefetch-url</command> downloads the
|
||||
file referenced by the URL <replaceable>url</replaceable>,
|
||||
prints its MD5 cryptographic hash code, and copies it into the
|
||||
Nix store. The file name in the store is
|
||||
<filename><replaceable>hash</replaceable>-<replaceable>basename</replaceable></filename>,
|
||||
where <replaceable>basename</replaceable> is everything
|
||||
following the final slash in <replaceable>url</replaceable>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This command is just a convenience to Nix expression writers.
|
||||
Often a Nix expressions fetch some source distribution from the
|
||||
network using the <literal>fetchurl</literal> expression
|
||||
contained in <literal>nixpkgs</literal>. However,
|
||||
<literal>fetchurl</literal> requires an MD5 hash. If you don't
|
||||
know the hash, you would have to download the file first, and
|
||||
then <literal>fetchurl</literal> would download it again when
|
||||
you build your Nix expression. Since
|
||||
<literal>fetchurl</literal> uses the same name for the
|
||||
downloaded file as <command>nix-prefetch-url</command>, the
|
||||
redundant download can be avoided.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-prefetch-url ftp://ftp.nluug.nl/pub/gnu/make/make-3.80.tar.bz2
|
||||
...
|
||||
file has hash 0bbd1df101bc0294d440471e50feca71
|
||||
...</screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refentry>
|
||||
@@ -0,0 +1,43 @@
|
||||
<refentry>
|
||||
<refnamediv>
|
||||
<refname>nix-pull</refname>
|
||||
<refpurpose>pull substitutes from a network cache</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>nix-pull</command>
|
||||
<arg choice='plain'><replaceable>url</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The command <command>nix-pull</command> obtains a list of
|
||||
pre-built store paths from the URL
|
||||
<replaceable>url</replaceable>, and for each of these store
|
||||
paths, registers a substitute derivation that downloads and
|
||||
unpacks it into the Nix store. This is used to speed up
|
||||
installations: if you attempt to install something that has
|
||||
already been built and stored into the network cache, Nix can
|
||||
transparently re-use the pre-built store paths.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The file at <replaceable>url</replaceable> must be compatible
|
||||
with the files created by <replaceable>nix-push</replaceable>.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<screen>
|
||||
$ nix-pull http://catamaran.labs.cs.uu.nl/dist/nix/nixpkgs-0.5pre753/MANIFEST</screen>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refentry>
|
||||
@@ -0,0 +1,138 @@
|
||||
<refentry>
|
||||
<refnamediv>
|
||||
<refname>nix-push</refname>
|
||||
<refpurpose>push store paths onto a network cache</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>nix-push</command>
|
||||
<arg choice='plain'><replaceable>archives-put-url</replaceable></arg>
|
||||
<arg choice='plain'><replaceable>archives-get-url</replaceable></arg>
|
||||
<arg choice='plain'><replaceable>manifest-put-url</replaceable></arg>
|
||||
<arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The command <command>nix-push</command> builds a set of store
|
||||
expressions (if necessary), and then packages and uploads all
|
||||
store paths in the resulting closures to a server. A network
|
||||
cache thus populated can subsequently be used to speed up
|
||||
software deployment on other machines using the
|
||||
<command>nix-pull</command> command.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<command>nix-push</command> performs the following actions.
|
||||
|
||||
<orderedlist>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
The store expressions stored in
|
||||
<replaceable>paths</replaceable> are realised (using
|
||||
<literal>nix-store --realise</literal>).
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
All paths in the closure of the store expressions stored
|
||||
in <replaceable>paths</replaceable> are determined (using
|
||||
<literal>nix-store --query --requisites
|
||||
--include-successors</literal>). It should be noted that
|
||||
since the <option>--include-successors</option> flag is
|
||||
used, if you specify a derivation store expression, you
|
||||
get a combined source/binary distribution. If you only
|
||||
want a binary distribution, you should specify the closure
|
||||
store expression that result from realising these (see
|
||||
below).
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
All store paths determined in the previous step are
|
||||
packaged and compressed into a <command>bzip</command>ped
|
||||
NAR archive (extension <filename>.nar.bz2</filename>).
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
A <emphasis>manifest</emphasis> is created that contains
|
||||
information on the store paths, their eventual URLs in the
|
||||
cache, and cryptographic hashes of the contents of the NAR
|
||||
archives.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Each store path is uploaded to the remote directory
|
||||
specified by <replaceable>archives-put-url</replaceable>.
|
||||
HTTP PUT requests are used to do this. However, before a
|
||||
file <varname>x</varname> is uploaded to
|
||||
<literal><replaceable>archives-put-url</replaceable>/<varname>x</varname></literal>,
|
||||
<command>nix-push</command> first determines whether this
|
||||
upload is unnecessary by issuing a HTTP HEAD request on
|
||||
<literal><replaceable>archives-get-url</replaceable>/<varname>x</varname></literal>.
|
||||
This allows a cache to be shared between many partially
|
||||
overlapping <command>nix-push</command> invocations.
|
||||
(We use two URLs because the upload URL typically
|
||||
refers to a CGI script, while the download URL just refers
|
||||
to a file system directory on the server.)
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
The manifest is uploaded using an HTTP PUT request to
|
||||
<replaceable>manifest-put-url</replaceable>. The
|
||||
corresponding URL to download the manifest can then be
|
||||
used by <command>nix-pull</command>.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
</orderedlist>
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
|
||||
<para>
|
||||
To upload files there typically is some CGI script on the server
|
||||
side. This script should be be protected with a password. The
|
||||
following example uploads the store paths resulting from
|
||||
building the Nix expressions in <filename>foo.nix</filename>,
|
||||
passing appropriate authentication information:
|
||||
|
||||
<screen>
|
||||
$ nix-push \
|
||||
http://foo@bar:server.domain/cgi-bin/upload.pl/cache \
|
||||
http://server.domain/cache \
|
||||
http://foo@bar:server.domain/cgi-bin/upload.pl/MANIFEST \
|
||||
$(nix-instantiate foo.nix)</screen>
|
||||
|
||||
This will push both sources and binaries (and any build-time
|
||||
dependencies used in the build, such as compilers).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If we just want to push binaries, not sources and build-time
|
||||
dependencies, we can do:
|
||||
|
||||
<screen>
|
||||
$ nix-push <replaceable>urls</replaceable> $(nix-instantiate $(nix-store -r foo.nix))</screen>
|
||||
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refentry>
|
||||
@@ -0,0 +1,505 @@
|
||||
<refentry>
|
||||
<refnamediv>
|
||||
<refname>nix-store</refname>
|
||||
<refpurpose>manipulate or query the Nix store</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>nix-store</command>
|
||||
&opt-common-syn;
|
||||
<arg choice='plain'><replaceable>operation</replaceable></arg>
|
||||
<arg rep='repeat'><replaceable>options</replaceable></arg>
|
||||
<arg rep='repeat'><replaceable>arguments</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The command <command>nix-store</command> performs primitive
|
||||
operations on the Nix store. You generally do not need to run
|
||||
this command manually.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<command>nix-store</command> takes exactly one
|
||||
<emphasis>operation</emphasis> flag which indicates the
|
||||
subcommand to be performed. These are documented below.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Common options</title>
|
||||
|
||||
<para>
|
||||
This section lists the options that are common to all
|
||||
operations. These options are allowed for every subcommand,
|
||||
though they may not always have an effect.
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
|
||||
&opt-common;
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Environment variables</title>
|
||||
|
||||
<para>
|
||||
The following environment variables affect the behaviour of
|
||||
<command>nix-store</command>.
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><envar>TMPDIR</envar>=<replaceable>path</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Use the directory <replaceable>path</replaceable> to store
|
||||
temporary files. In particular, this includes temporary
|
||||
build directories; these can take up substantial amounts
|
||||
of disk space. The default is <filename>/tmp</filename>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--realise</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-store</command>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--realise</option></arg>
|
||||
<arg choice='plain'><option>-r</option></arg>
|
||||
</group>
|
||||
<arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The operation <option>--install</option> realises in the file
|
||||
system the store expressions stored in
|
||||
<replaceable>paths</replaceable>. If these expressions are
|
||||
derivation expressions, they are first
|
||||
<emphasis>normalised</emphasis> into a closure expression.
|
||||
This may happen in two ways. First, the corresponding closure
|
||||
expression (the <emphasis>successor</emphasis>) may already
|
||||
known (either because the build has already been performed, or
|
||||
because a successor was explicitly registered through the
|
||||
<option>--successor</option> operation). Otherwise, the build
|
||||
action described by the derivation is performed, and a closure
|
||||
expression is computed by scanning the result of the build for
|
||||
references to other paths in the store.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The paths of the closure expression corresponding to each
|
||||
expression in <replaceable>paths</replaceable> is printed on
|
||||
standard output.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--delete</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-store</command>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--delete</option></arg>
|
||||
<arg choice='plain'><option>-d</option></arg>
|
||||
</group>
|
||||
<arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The operation <option>--delete</option> unconditionally deletes the
|
||||
paths <replaceable>paths</replaceable> from the Nix store. It is an
|
||||
error to attempt to delete paths outside of the store.
|
||||
</para>
|
||||
|
||||
<warning>
|
||||
<para>
|
||||
This operation should almost never be called directly, since no
|
||||
attempt is made to verify that no references exist to the paths to
|
||||
be deleted. Therefore, careless deletion can result in an
|
||||
inconsistent system. Deletion of paths in the store is done by the
|
||||
garbage collector (which uses <option>--delete</option> to delete
|
||||
unreferenced paths).
|
||||
</para>
|
||||
</warning>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--query</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-store</command>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--query</option></arg>
|
||||
<arg choice='plain'><option>-q</option></arg>
|
||||
</group>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--list</option></arg>
|
||||
<arg choice='plain'><option>-l</option></arg>
|
||||
<arg choice='plain'><option>--requisites</option></arg>
|
||||
<arg choice='plain'><option>-R</option></arg>
|
||||
<arg choice='plain'><option>--predecessors</option></arg>
|
||||
<arg choice='plain'><option>--graph</option></arg>
|
||||
</group>
|
||||
<arg><option>--normalise</option></arg>
|
||||
<arg><option>-n</option></arg>
|
||||
<arg><option>--force-realise</option></arg>
|
||||
<arg><option>-f</option></arg>
|
||||
<arg choice='plain' rep='repeat'><replaceable>args</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The operation <option>--query</option> displays various bits
|
||||
of information about store expressions or store paths. The
|
||||
queries are described below. At most one query can be
|
||||
specified. The default query is <option>--list</option>.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
<refsection>
|
||||
<title>Common query options</title>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--normalise</option> / <option>-n</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
For those queries that take a Nix store expression, this
|
||||
option causes those expressions to be normalised first.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--force-realise</option> / <option>-f</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
For those queries that take a Nix store expression, this
|
||||
option causes those expressions to be realised first.
|
||||
This is just a short-cut for the common idiom
|
||||
</para>
|
||||
<screen>
|
||||
nix-store --realise /nix/store/bla.store
|
||||
x=`nix-store --query --normalise /nix/store/bla.store`
|
||||
<emphasis>(do something with the path $x</emphasis></screen>
|
||||
<para>
|
||||
which using this flag can be written as
|
||||
</para>
|
||||
<screen>
|
||||
x=`nix-store --query --normalise --force-realise /nix/store/bla.store`
|
||||
<emphasis>(do something with the path $x</emphasis></screen>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
<refsection id='nixref-queries'>
|
||||
<title>Queries</title>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--list</option> / <option>-l</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Prints out the <emphasis>output paths</emphasis> of the
|
||||
store expressions indicated by the identifiers
|
||||
<replaceable>args</replaceable>. In the case of a
|
||||
derivation expression, these are the paths that will be
|
||||
produced when the derivation is realised. In the case
|
||||
of a closure expression, these are the paths that were
|
||||
produced the derivation expression of which the closure
|
||||
expression is a successor.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--requisites</option> / <option>-R</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Prints out the requisite paths of the store expressions
|
||||
indicated by the identifiers
|
||||
<replaceable>args</replaceable>. The requisite paths of
|
||||
a Nix expression are the paths that need to be present
|
||||
in the system to be able to realise the expression.
|
||||
That is, they form the <emphasis>closure</emphasis> of
|
||||
the expression in the file system (i.e., no path in the
|
||||
set of requisite paths points to anything outside the
|
||||
set of requisite paths).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The notion of requisite paths is very useful when one
|
||||
wants to distribute store expressions. Since they form a
|
||||
closure, they are the only paths one needs to distribute
|
||||
to another system to be able to realise the expression
|
||||
on the other system.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This query is generally used to implement various kinds
|
||||
of deployment. A <emphasis>source deployment</emphasis>
|
||||
is obtained by distributing the requisite paths of a
|
||||
derivation expression. A <emphasis>binary
|
||||
deployment</emphasis> is obtained by distributing the
|
||||
requisite paths of a closure expression. A
|
||||
<emphasis>cache deployment</emphasis> is obtained by
|
||||
distributing the requisite paths of a derivation
|
||||
expression and specifying the option
|
||||
<option>--include-successors</option>. This will
|
||||
include not just the paths of a source and binary
|
||||
deployment, but also all expressions and paths of
|
||||
subterms of the source. This is useful if one wants to
|
||||
realise on the target system a Nix expression that is
|
||||
similar but not quite the same as the one being
|
||||
distributed, since any common subterms will be reused.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This query has a number of options:
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--exclude-exprs</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Excludes the paths of store expressions. This
|
||||
causes the closure property to be lost, that is,
|
||||
the resulting set of paths is not enough to ensure
|
||||
realisibility.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--include-successors</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Also include the requisites of successors (normal forms).
|
||||
Only the requisites of <emphasis>known</emphasis>
|
||||
successors are included, i.e., the normal forms of
|
||||
derivation expressions that have never been normalised will
|
||||
not be included.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Note that not just the successor of a derivation expression
|
||||
will be included, but also the successors of all input
|
||||
expressions of that derivation expression. I.e., all
|
||||
normal forms of subterms involved in the normalisation of
|
||||
the top-level term are included.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--predecessors</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
For each store expression stored at paths
|
||||
<replaceable>args</replaceable>, prints its
|
||||
<emphasis>predecessors</emphasis>. A derivation
|
||||
expression <varname>p</varname> is a predecessor of a
|
||||
store expression <varname>q</varname> iff
|
||||
<varname>q</varname> is a successor of
|
||||
<varname>p</varname>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--graph</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Prints a graph of the closure of the store expressions
|
||||
identified by <replaceable>args</replaceable> in the
|
||||
format of the <command>dot</command> tool of AT&T's
|
||||
GraphViz package.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--successor</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-store</command>
|
||||
<arg choice='req'><option>--successor</option></arg>
|
||||
<arg choice='plain'
|
||||
rep='repeat'><replaceable>srcpath</replaceable> <replaceable>sucpath</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The operation <option>--successor</option> registers that the
|
||||
closure expression in <replaceable>sucpath</replaceable> is a
|
||||
successor of the derivation expression in
|
||||
<replaceable>srcpath</replaceable>. This is used to implement
|
||||
binary deployment.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--substitute</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-store</command>
|
||||
<arg choice='req'><option>--substitute</option></arg>
|
||||
<arg choice='plain'
|
||||
rep='repeat'><replaceable>srcpath</replaceable> <replaceable>subpath</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The operation <option>--substitute</option> registers that the
|
||||
store path <replaceable>srcpath</replaceable> can be built by
|
||||
realising the derivation expression in
|
||||
<replaceable>subpath</replaceable>. This is used to implement
|
||||
binary deployment.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<refsection>
|
||||
<title>Operation <option>--verify</option></title>
|
||||
|
||||
<refsection>
|
||||
<title>Synopsis</title>
|
||||
<cmdsynopsis>
|
||||
<command>nix-store</command>
|
||||
<arg choice='req'><option>--verify</option></arg>
|
||||
</cmdsynopsis>
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
The operation <option>--verify</option> verifies the internal
|
||||
consistency of the Nix database, and the consistency between
|
||||
the Nix database and the Nix store. Any inconsistencies
|
||||
encountered are automatically repaired. Inconsistencies are
|
||||
generally the result of the Nix store or database being
|
||||
modified by non-Nix tools, or of bugs in Nix itself.
|
||||
</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
|
||||
<!--
|
||||
local variables:
|
||||
sgml-parent-document: ("book.xml" "refentry")
|
||||
end:
|
||||
-->
|
||||
@@ -0,0 +1,18 @@
|
||||
<arg><option>--help</option></arg>
|
||||
<arg><option>--version</option></arg>
|
||||
<arg rep='repeat'><option>--verbose</option></arg>
|
||||
<arg rep='repeat'><option>-v</option></arg>
|
||||
<arg><option>--build-output</option></arg>
|
||||
<arg><option>-B</option></arg>
|
||||
<arg>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--max-jobs</option></arg>
|
||||
<arg choice='plain'><option>-j</option></arg>
|
||||
</group>
|
||||
<replaceable>number</replaceable>
|
||||
</arg>
|
||||
<arg><option>--keep-going</option></arg>
|
||||
<arg><option>-k</option></arg>
|
||||
<arg><option>--keep-failed</option></arg>
|
||||
<arg><option>-K</option></arg>
|
||||
<arg><option>--fallback</option></arg>
|
||||
@@ -0,0 +1,174 @@
|
||||
<varlistentry>
|
||||
<term><option>--help</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Prints out a summary of the command syntax and exits.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--version</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Prints out the Nix version number on standard output and exits.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--verbose</option> / <option>-v</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Increases the level of verbosity of diagnostic messages printed
|
||||
on standard error. For each Nix operation, the information
|
||||
printed on standard output is well-defined; any diagnostic
|
||||
information is printed on standard error, never on standard
|
||||
output.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This option may be specified repeatedly. Currently, the
|
||||
following verbosity levels exist:
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>0</term>
|
||||
<listitem>
|
||||
<para>
|
||||
<quote>Errors only</quote>: only print messages explaining
|
||||
why the Nix invocation failed.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>1</term>
|
||||
<listitem>
|
||||
<para>
|
||||
<quote>Informational</quote>: print
|
||||
<emphasis>useful</emphasis> messages about what Nix is
|
||||
doing.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>2</term>
|
||||
<listitem>
|
||||
<para>
|
||||
<quote>Talkative</quote>: print more informational messages.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>3</term>
|
||||
<listitem>
|
||||
<para>
|
||||
<quote>Chatty</quote>: print even more informational messages.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>4</term>
|
||||
<listitem>
|
||||
<para>
|
||||
<quote>Debug</quote>: print debug information:
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>5</term>
|
||||
<listitem>
|
||||
<para>
|
||||
<quote>Vomit</quote>: print vast amounts of debug
|
||||
information.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--build-output</option> / <option>-B</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Causes the output written by build actions to standard output
|
||||
and standard error to be echoed to standard error, regardless of
|
||||
verbosity level. By default, it is only echoed at a verbosity
|
||||
level of at least 4 (<quote>Debug</quote>), and is suppressed at
|
||||
lower levels. Note that it is always written to a log file in
|
||||
<filename><replaceable>prefix</replaceable>/nix/var/log/nix</filename>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--max-jobs</option> / <option>-j</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Sets the maximum number of build jobs that Nix will perform in
|
||||
parallel to the specified number. The default is 1. A higher
|
||||
value is useful on SMP systems or to exploit I/O latency.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--keep-going</option> / <option>-k</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Keep going in case of failed builds, to the greatest extent
|
||||
possible. That is, if building an input of some derivation
|
||||
fails, Nix will still build the other inputs, but not the
|
||||
derivation itself. Without this option, Nix stops if any build
|
||||
fails (except for builds of substitutes), possibly killing
|
||||
builds in progress (in case of parallel or distributed builds).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--keep-failed</option> / <option>-K</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies that in case of a build failure, the temporary
|
||||
directory (usually in <filename>/tmp</filename>) in which the
|
||||
build takes place should not be deleted. The path of the build
|
||||
directory is printed as an informational message.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--fallback</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Whenever Nix attempts to realise a derivation for which a
|
||||
closure is already known, but this closure cannot be realised,
|
||||
fall back on normalising the derivation.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The most common scenario in which this is useful is when we have
|
||||
registered substitutes in order to perform binary distribution
|
||||
from, say, a network repository. If the repository is down, the
|
||||
realisation of the derivation will fail. When this option is
|
||||
specified, Nix will build the derivation instead. Thus,
|
||||
binary installation falls back on a source installation. This
|
||||
option is not the default since it is generally not desirable
|
||||
for a transient failure in obtaining the substitutes to lead to
|
||||
a full build from source (with the related consumption of
|
||||
resources).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -0,0 +1,450 @@
|
||||
<chapter id='chap-overview'>
|
||||
<title>Overview</title>
|
||||
|
||||
<para>
|
||||
This chapter provides a guided tour of Nix.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<sect1>
|
||||
<title>Basic package management</title>
|
||||
|
||||
<para>
|
||||
Let's start from the perspective of an end user. Common operations at
|
||||
this level are to install and remove packages, ask what packages are
|
||||
installed or available for installation, and so on. These are operations
|
||||
on the <emphasis>user environment</emphasis>: the set of packages that a
|
||||
user <quote>sees</quote>. In a command line Unix environment, this means
|
||||
the set of programs that are available through the <envar>PATH</envar>
|
||||
environment variable. (In other environments it might mean the set of
|
||||
programs available on the desktop, through the start menu, and so on.)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The terms <quote>installation</quote> and <quote>uninstallation</quote>
|
||||
are used in this context to denote the act of adding or removing packages
|
||||
from the user environment. In Nix, these operations are dissociated from
|
||||
the physical copying or deleting of files. Installation requires that
|
||||
the files constituting the package are present, but they may be present
|
||||
beforehand. Likewise, uninstallation does not actually delete any files;
|
||||
this is done automatically by running a garbage collector.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
User environments are manipulated through the <command>nix-env</command>
|
||||
command. The query operation can be used to see what packages are
|
||||
currently installed.
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
$ nix-env -q
|
||||
MozillaFirebird-0.7
|
||||
sylpheed-0.9.7
|
||||
pan-0.14.2</screen>
|
||||
|
||||
<para>
|
||||
(<option>-q</option> is actually short for <option>--query
|
||||
--installed</option>.) The package names are symbolic: they don't have
|
||||
any particular significance to Nix (as they shouldn't, since they are not
|
||||
unique—there can be many derivations with the same name). Note that
|
||||
these packages have many dependencies (e.g., Mozilla uses the
|
||||
<literal>gtk+</literal> package) but these have not been installed in the
|
||||
user environment, though they are present on the system. Generally,
|
||||
there is no need to install such packages; only packages containing
|
||||
programs should be installed.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To install packages, a <emphasis>Nix expression</emphasis> is required
|
||||
that tells Nix how to build that package. There is a <ulink
|
||||
url='https://svn.cs.uu.nl:12443/dist/trace/trace-nixpkgs-trunk.tar.bz2'>set
|
||||
of standard of Nix expressions</ulink> for many common packages.
|
||||
Assuming that you have downloaded and unpacked these, you can view the
|
||||
set of available packages:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
$ nix-env -qaf pkgs/system/i686-linux.nix
|
||||
gettext-0.12.1
|
||||
sylpheed-0.9.7
|
||||
aterm-2.0
|
||||
gtk+-1.2.10
|
||||
apache-httpd-2.0.48
|
||||
pan-0.14.2
|
||||
...</screen>
|
||||
|
||||
<para>
|
||||
The Nix expression in the file <filename>i686-linux.nix</filename> yields
|
||||
the set of packages for a Linux system running on x86 hardware. For
|
||||
other platforms, copy and modify this file for your platform as
|
||||
appropriate. [TODO: improve this]
|
||||
</para>
|
||||
|
||||
<para>
|
||||
It is also possible to see the <emphasis>status</emphasis> of available
|
||||
packages, i.e., whether they are installed into the user environment
|
||||
and/or present in the system:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
$ nix-env -qasf pkgs/system/i686-linux.nix
|
||||
-P gettext-0.12.1
|
||||
IP sylpheed-0.9.7
|
||||
-- aterm-2.0
|
||||
-P gtk+-1.2.10</screen>
|
||||
|
||||
<para>
|
||||
This reveals that the <literal>sylpheed</literal> package is already
|
||||
installed, or more precisely, that exactly the same instantiation of
|
||||
<literal>sylpheed</literal> is installed. This guarantees that the
|
||||
available package is exactly the same as the installed package with
|
||||
regard to sources, dependencies, build flags, and so on. Similarly, we
|
||||
see that the <literal>gettext</literal> and <literal>gtk+</literal>
|
||||
packages are present but not installed in the user environment, while the
|
||||
<literal>aterm</literal> package is not installed or present at all (so,
|
||||
if we were to install it, it would have to be built or downloaded first).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The install operation is used install available packages from a Nix
|
||||
environment. To install the <literal>pan</literal> package (a
|
||||
newsreader), you would do:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
$ nix-env -if pkgs/system/i686-linux.nix pan</screen>
|
||||
|
||||
<para>
|
||||
Since installation may take a long time, depending on whether any
|
||||
packages need to be built or downloaded, it's a good idea to make
|
||||
<command>nix-env</command> run verbosely by using the <option>-v</option>
|
||||
(<option>--verbose</option>) option. This option may be repeated to
|
||||
increase the level of verbosity. A good value is 3
|
||||
(<option>-vvv</option>).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
In fact, if you run this command verbosely you will observe that Nix
|
||||
starts to build many packages, including large and fundamental ones such
|
||||
as <literal>glibc</literal> and <literal>gcc</literal>. I.e., you are
|
||||
performing a source installation. This is generally undesirable, since
|
||||
installation from sources may require large amounts of disk and CPU
|
||||
resources. Therefore a <quote>binary</quote> installation is generally
|
||||
preferable.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Rather than provide different mechanisms to create and perform
|
||||
the installation of binary packages, Nix supports binary deployment
|
||||
<emphasis>transparently</emphasis> through a generic mechanism of
|
||||
<emphasis>substitute expressions</emphasis>. If an request is made to
|
||||
build some Nix expression, Nix will first try to build any substitutes
|
||||
for that expression. These substitutes presumably perform an identical
|
||||
build operation with respect to the result, but require less resources.
|
||||
For instance, a substitute that downloads a pre-built package from the
|
||||
network requires less CPU and disk resources, and possibly less time.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Nix's use of cryptographic hashes makes this entirely safe. It is not
|
||||
possible, for instance, to accidentally substitute a build of some
|
||||
package for a Solaris or Windows system for a build on a SuSE/x86 system.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
While the substitute mechanism is a generic mechanism, Nix provides two
|
||||
standard tools called <command>nix-pull</command> and
|
||||
<command>nix-push</command> that maintain and use a shared cache of
|
||||
prebuilt derivations on some network site (reachable through HTTP). If
|
||||
you attempt to install some package that someone else has previously
|
||||
built and <quote>pushed</quote> into the cache, and you have done a
|
||||
<quote>pull</quote> to register substitutes that download these prebuilt
|
||||
packages, then the installation will automatically use these.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For example, to pull from our <ulink
|
||||
url='http://losser.st-lab.cs.uu.nl/~eelco/nix-dist/'>cache</ulink> of
|
||||
prebuilt packages (at the time of writing, for SuSE Linux/x86), use the
|
||||
following command:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
$ nix-pull http://catamaran.labs.cs.uu.nl/dist/nix/nixpkgs-<replaceable>version</replaceable>/MANIFEST
|
||||
obtaining list of Nix archives at http://catamaran.labs.cs.uu.nl/dist/nix/nixpkgs-<replaceable>version</replaceable>/MANIFEST...
|
||||
...</screen>
|
||||
|
||||
<para>
|
||||
If <command>nix-pull</command> is run without any arguments, it will pull
|
||||
from the URLs specified in the file
|
||||
<filename><replaceable>prefix</replaceable>/etc/nix/prebuilts.conf</filename>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Assuming that the <literal>pan</literal> installation produced no errors,
|
||||
it can be used immediately, that is, it now appears in a directory in the
|
||||
<envar>PATH</envar> environment variable. Specifically,
|
||||
<envar>PATH</envar> includes the entry
|
||||
<filename><replaceable>prefix</replaceable>/var/nix/profiles/default/bin</filename>,
|
||||
where
|
||||
<filename><replaceable>prefix</replaceable>/var/nix/profiles/default</filename>
|
||||
is just a symlink to the current user environment:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
$ ls -l /nix/var/nix/profiles/
|
||||
...
|
||||
lrwxrwxrwx 1 eelco ... default-15-link -> /nix/store/1871...12b0-user-environment
|
||||
lrwxrwxrwx 1 eelco ... default-16-link -> /nix/store/59ba...df6b-user-environment
|
||||
lrwxrwxrwx 1 eelco ... default -> default-16-link</screen>
|
||||
|
||||
<para>
|
||||
That is, <filename>default</filename> in this example is a link
|
||||
to <filename>default-16-link</filename>, which is the current
|
||||
user environment. Before the installation, it pointed to
|
||||
<filename>default-15-link</filename>. Note that this means that
|
||||
you can atomically roll-back to the previous user environment by
|
||||
pointing the symlink <filename>default</filename> at
|
||||
<filename>default-15-link</filename> again. This also shows
|
||||
that operations such as installation are atomic in the Nix
|
||||
system: any arbitrarily complex set of installation,
|
||||
uninstallation, or upgrade actions eventually boil down to the
|
||||
single operation of pointing a symlink somewhere else (which can
|
||||
be implemented atomically in Unix).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
What's in a user environment? It's just a set of symlinks to the files
|
||||
that constitute the installed packages. For instance:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
$ ls -l /nix/var/nix/profiles/default-16-link/bin
|
||||
lrwxrwxrwx 1 eelco ... MozillaFirebird -> /nix/store/35f8...4ae6-MozillaFirebird-0.7/bin/MozillaFirebird
|
||||
lrwxrwxrwx 1 eelco ... svn -> /nix/store/3829...fb5d-subversion-0.32.1/bin/svn
|
||||
...</screen>
|
||||
|
||||
<para>
|
||||
Note that, e.g., <filename>svn</filename> =
|
||||
<filename>/nix/var/nix/profiles/default/bin/svn</filename> =
|
||||
<filename>/nix/var/nix/profiles/default-16-link/bin/svn</filename> =
|
||||
<filename>/nix/store/59ba...df6b-user-environment/bin/svn</filename> =
|
||||
<filename>/nix/store/3829...fb5d-subversion-0.32.1/bin/svn</filename>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Naturally, packages can also be uninstalled:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
$ nix-env -e pan</screen>
|
||||
|
||||
<para>
|
||||
This means that the package is removed from the user
|
||||
environment. It is <emphasis>not</emphasis> yet removed from
|
||||
the system. When a package is uninstalled from a user
|
||||
environment, it may still be used by other packages, or may
|
||||
still be present in other user environments. Deleting it under
|
||||
such conditions would break those other packages or user
|
||||
environments. To prevent this, packages are only
|
||||
<quote>physically</quote> deleted by running the Nix garbage
|
||||
collector, which searches for all packages in the Nix store that
|
||||
are no longer <quote>reachable</quote> from outside the store.
|
||||
Thus, uninstalling a package is always safe: it cannot break
|
||||
other packages.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Upgrading packages is easy. Given a Nix expression that
|
||||
contains newer versions of installed packages (that is, packages
|
||||
with the same package name, but a higher version number),
|
||||
<command>nix-env -u</command> will replace the installed package
|
||||
in the user environment with the newer package. For example,
|
||||
|
||||
<screen>
|
||||
$ nix-env -uf pkgs/system/i686-linux.nix pan</screen>
|
||||
|
||||
looks for a newer version of Pan, and installs it if found.
|
||||
Also useful is the ability to upgrade <emphasis>all</emphasis>
|
||||
packages:
|
||||
|
||||
<screen>
|
||||
$ nix-env -uf pkgs/system/i686-linux.nix '*'</screen>
|
||||
|
||||
The asterisk matches all installed packages<footnote><para>No,
|
||||
we don't support arbitrary regular
|
||||
expressions</para></footnote>. Note that <literal>*</literal>
|
||||
must be quoted to prevent shell globbing.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
||||
|
||||
<!--######################################################################-->
|
||||
|
||||
<sect1>
|
||||
<title>Writing Nix expressions</title>
|
||||
|
||||
<sect2>
|
||||
<title>A simple Nix expression</title>
|
||||
|
||||
<para>
|
||||
This section shows how to write simple Nix expressions—the things
|
||||
that describe how to build a package.
|
||||
</para>
|
||||
|
||||
<example id='ex-hello-nix'>
|
||||
<title>Nix expression for GNU Hello</title>
|
||||
<programlisting>
|
||||
{stdenv, fetchurl, perl}: <co id='ex-hello-nix-co-1' />
|
||||
|
||||
derivation { <co id='ex-hello-nix-co-2' />
|
||||
name = "hello-2.1.1"; <co id='ex-hello-nix-co-3' />
|
||||
system = stdenv.system; <co id='ex-hello-nix-co-4' />
|
||||
builder = ./builder.sh; <co id='ex-hello-nix-co-5' />
|
||||
src = fetchurl { <co id='ex-hello-nix-co-6' />
|
||||
url = ftp://ftp.nluug.nl/pub/gnu/hello/hello-2.1.1.tar.gz;
|
||||
md5 = "70c9ccf9fac07f762c24f2df2290784d";
|
||||
};
|
||||
stdenv = stdenv; <co id='ex-hello-nix-co-7' />
|
||||
perl = perl;
|
||||
}</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
A simple Nix expression is shown in <xref linkend='ex-hello-nix' />. It
|
||||
describes how to the build the <ulink
|
||||
url='http://www.gnu.org/directory/GNU/hello.html'>GNU Hello
|
||||
package</ulink>. This package has several dependencies. First, it
|
||||
requires a number of other packages, such as a C compiler, standard
|
||||
Unix shell tools, and Perl. Rather than have this Nix expression refer
|
||||
to and use specific versions of these packages, it should be generic;
|
||||
that is, it should be a <emphasis>function</emphasis> that takes the
|
||||
required packages as inputs and yield a build of the GNU Hello package
|
||||
as a result. This Nix expression defines a function with three
|
||||
arguments <xref linkend='ex-hello-nix-co-1' />, namely:
|
||||
<orderedlist>
|
||||
<listitem><para><varname>stdenv</varname>, which should be a
|
||||
<emphasis>standard environment package</emphasis>. The standard
|
||||
environment is a set of tools and other components that would be
|
||||
expected in a fairly minimal Unix-like environment: a C compiler
|
||||
and linker, Unix shell tools, and so on.</para>
|
||||
</listitem>
|
||||
<listitem><para><varname>fetchurl</varname>, which should be a
|
||||
function that given parameters <varname>url</varname> and
|
||||
<varname>md5</varname>, will fetch a file from the specified
|
||||
location and check that this file has the given MD5 hash code.
|
||||
The hash is required because build operations must be
|
||||
<emphasis>pure</emphasis>: given the same inputs they should
|
||||
always yield the same output. Since network resources can change
|
||||
at any time, we must in some way guarantee what the result will
|
||||
be.</para>
|
||||
</listitem>
|
||||
<listitem><para><varname>perl</varname>, which should be a Perl
|
||||
interpreter.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The remainder of the file is the body of the function, which happens to
|
||||
be a <emphasis>derivation</emphasis> <xref
|
||||
linkend='ex-hello-nix-co-2' />, which is the built-in function
|
||||
<varname>derivation</varname> applied to a set of attributes that
|
||||
encode all the necessary information for building the GNU Hello
|
||||
package.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Build script (<filename>builder.sh</filename>) for GNU
|
||||
Hello</title>
|
||||
<programlisting>
|
||||
#! /bin/sh
|
||||
|
||||
buildinputs="$perl"
|
||||
. $stdenv/setup || exit 1
|
||||
|
||||
tar xvfz $src || exit 1
|
||||
cd hello-* || exit 1
|
||||
./configure --prefix=$out || exit 1
|
||||
make || exit 1
|
||||
make install || exit 1</programlisting>
|
||||
</example>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
<title>A more complex Nix expression</title>
|
||||
|
||||
<example id='ex-svn-nix'>
|
||||
<title>Nix expression for Subversion</title>
|
||||
<programlisting>
|
||||
{ localServer ? false <co id='ex-svn-nix-co-1' />
|
||||
, httpServer ? false
|
||||
, sslSupport ? false
|
||||
, swigBindings ? false
|
||||
, stdenv, fetchurl
|
||||
, openssl ? null, httpd ? null, db4 ? null, expat, swig ? null
|
||||
}:
|
||||
|
||||
assert !isNull expat; <co id='ex-svn-nix-co-2' />
|
||||
assert localServer -> !isNull db4;
|
||||
assert httpServer -> !isNull httpd && httpd.expat == expat; <co id='ex-svn-nix-co-3' />
|
||||
assert sslSupport -> !isNull openssl && (httpServer -> httpd.openssl == openssl);
|
||||
assert swigBindings -> !isNull swig;
|
||||
|
||||
derivation {
|
||||
name = "subversion-0.32.1";
|
||||
system = stdenv.system;
|
||||
|
||||
builder = ./builder.sh;
|
||||
src = fetchurl {
|
||||
url = http://svn.collab.net/tarballs/subversion-0.32.1.tar.gz;
|
||||
md5 = "b06717a8ef50db4b5c4d380af00bd901";
|
||||
};
|
||||
|
||||
localServer = localServer;
|
||||
httpServer = httpServer;
|
||||
sslSupport = sslSupport;
|
||||
swigBindings = swigBindings;
|
||||
|
||||
stdenv = stdenv;
|
||||
openssl = if sslSupport then openssl else null; <co id='ex-svn-nix-co-4' />
|
||||
httpd = if httpServer then httpd else null;
|
||||
expat = expat;
|
||||
db4 = if localServer then db4 else null;
|
||||
swig = if swigBindings then swig else null;
|
||||
}</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
This example shows several features. Default parameters <xref
|
||||
linkend='ex-svn-nix-co-1'/> can be used to simplify call sites: if an
|
||||
argument that has a default is omitted, its default value is used.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You can use <emphasis>assertions</emphasis> to test whether arguments
|
||||
satisfy certain constraints. The simple assertion <xref
|
||||
linkend='ex-svn-nix-co-2'/> tests whether the
|
||||
<varname>expat</varname> argument is not a null value. The more
|
||||
complex assertion <xref linkend='ex-svn-nix-co-3'/> says that if
|
||||
Subversion is built with Apache support, then <varname>httpd</varname>
|
||||
(the Apache package) must not be null and it must have been built using
|
||||
the same instance of the <varname>expat</varname> library as was passed
|
||||
to the Subversion expression. This is since the Subversion code is
|
||||
dynamically linked against the Apache code and they both use Expat,
|
||||
they must be linked against the same instance—otherwise a
|
||||
conflict might occur.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
||||
</chapter>
|
||||
@@ -0,0 +1,141 @@
|
||||
<chapter>
|
||||
<title>Quick Start</title>
|
||||
|
||||
<para>
|
||||
This chapter is for impatient people who don't like reading
|
||||
documentation. For more in-depth information you are kindly
|
||||
referred to <xref linkend='chap-installation' /> and <xref
|
||||
linkend='chap-overview' />.
|
||||
</para>
|
||||
|
||||
<orderedlist>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Download a source tarball or RPM from <ulink
|
||||
url='http://www.cs.uu.nl/groups/ST/Trace/Nix'/>.
|
||||
Build source distributions using the regular sequence:
|
||||
|
||||
<screen>
|
||||
$ tar xvfj nix-<replaceable>version</replaceable>.tar.bz2
|
||||
$ ./configure
|
||||
$ make
|
||||
$ make install <lineannotation>(as root)</lineannotation></screen>
|
||||
|
||||
This will install Nix in <filename>/nix</filename>. You
|
||||
should also add <filename>/nix/etc/profile.d/nix.sh</filename>
|
||||
to your <filename>~/.bashrc</filename> (or some other login
|
||||
file).
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Get some Nix expressions for pre-built packages by downloading
|
||||
the latest <literal>nixpkgs</literal> distribution (from the
|
||||
same location), and unpack them.
|
||||
|
||||
<screen>
|
||||
$ wget http://<replaceable>...</replaceable>/nix/nixpkgs-<replaceable>version</replaceable>/nixpkgs-<replaceable>version</replaceable>.tar.bz2
|
||||
$ tar xfj nixpkgs-<replaceable>version</replaceable>.tar.bz2</screen>
|
||||
|
||||
This will unpack the distribution into a directory
|
||||
<filename>nixpkgs-<replaceable>version</replaceable>/</filename>.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Pull the Nix cache. This ensures that when you install
|
||||
packages they are downloaded in pre-built form from the
|
||||
network, rather than built from source.
|
||||
|
||||
<screen>
|
||||
$ nix-pull http://<replaceable>...</replaceable>/nix/nixpkgs-<replaceable>version</replaceable>/MANIFEST</screen>
|
||||
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Note that currently we only pre-build for Linux on x86
|
||||
platforms.
|
||||
</para>
|
||||
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
See what's available:
|
||||
|
||||
<screen>
|
||||
$ nix-env -qaf nixpkgs-<replaceable>version</replaceable>/
|
||||
MozillaFirebird-0.7
|
||||
hello-2.1.1
|
||||
docbook-xml-4.2
|
||||
libxslt-1.1.0
|
||||
<replaceable>...</replaceable></screen>
|
||||
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Install some packages:
|
||||
|
||||
<screen>
|
||||
$ nix-env -iBf nixpkgs-<replaceable>version</replaceable>/ hello MozillaFirebird <replaceable>...</replaceable> </screen>
|
||||
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Test that they work:
|
||||
|
||||
<screen>
|
||||
$ which hello
|
||||
/home/eelco/.nix-profile/bin/hello
|
||||
$ hello
|
||||
Hello, world!
|
||||
$ MozillaFirebird
|
||||
<lineannotation>(read Slashdot or something)</lineannotation></screen>
|
||||
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Uninstall a package:
|
||||
|
||||
<screen>
|
||||
$ nix-env -e hello</screen>
|
||||
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
If a new release of <literal>nixpkgs</literal> comes along,
|
||||
you can upgrade all installed packages to the latest versions
|
||||
by downloading and unpacking the new release and doing:
|
||||
|
||||
<screen>
|
||||
$ nix-env -uBf nixpkgs-<replaceable>version</replaceable>/ '*'</screen>
|
||||
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
You should periodically run the Nix garbage collector to get
|
||||
rid of unused packages, since uninstalls or upgrades don't
|
||||
actual delete them:
|
||||
|
||||
<screen>
|
||||
$ nix-collect-garbage | xargs nix-store --delete</screen>
|
||||
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
</orderedlist>
|
||||
|
||||
</chapter>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
|
||||
<uri pathSuffix=".xml" typeId="DocBook"/>
|
||||
</locatingRules>
|
||||
@@ -0,0 +1,226 @@
|
||||
/* Copied from http://bakefile.sourceforge.net/, which appears
|
||||
licensed under the GNU GPL. */
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Basic headers and text:
|
||||
***************************************************************************/
|
||||
|
||||
body
|
||||
{
|
||||
font-family: sans-serif;
|
||||
background: white;
|
||||
|
||||
margin: 2em 1em 2em 1em;
|
||||
}
|
||||
|
||||
h1,h2,h3
|
||||
{
|
||||
color: #005aa0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
h1 /* title */
|
||||
{
|
||||
font-size: 200%;
|
||||
}
|
||||
|
||||
h2 /* chapters, appendices, subtitle */
|
||||
{
|
||||
font-size: 180%;
|
||||
}
|
||||
|
||||
/* Extra space between chapters, appendices. */
|
||||
div.chapter > div.titlepage h2, div.appendix > div.titlepage h2
|
||||
{
|
||||
margin-top: 1.5em;
|
||||
/* border-top: solid #005aa0; */
|
||||
}
|
||||
|
||||
div.sect1 h2 /* sections */
|
||||
{
|
||||
font-size: 150%;
|
||||
}
|
||||
|
||||
div.refnamediv h2, div.refsynopsisdiv h2, div.refsection h2 /* refentry parts */
|
||||
{
|
||||
font-size: 125%;
|
||||
}
|
||||
|
||||
div.refsection h3
|
||||
{
|
||||
font-size: 110%;
|
||||
}
|
||||
|
||||
h3 /* subsections */
|
||||
{
|
||||
font-size: 125%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Program listings:
|
||||
***************************************************************************/
|
||||
|
||||
div.example
|
||||
{
|
||||
border: 1px solid #6185a0;
|
||||
padding: 6px 6px;
|
||||
margin-left: 3em;
|
||||
margin-right: 3em;
|
||||
background: #eeeeee;
|
||||
}
|
||||
|
||||
pre.programlisting
|
||||
{
|
||||
color: #600000;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Screen dumps:
|
||||
***************************************************************************/
|
||||
|
||||
pre.screen
|
||||
{
|
||||
border: 1px solid #6185a0;
|
||||
padding: 6px 6px;
|
||||
margin-left: 3em;
|
||||
margin-right: 3em;
|
||||
color: #600000;
|
||||
background: #eeeeee;
|
||||
font-family: monospace;
|
||||
/* font-size: 90%; */
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Notes, warnings etc:
|
||||
***************************************************************************/
|
||||
|
||||
.note,.warning
|
||||
{
|
||||
border: 1px solid #6185a0;
|
||||
padding: 0px 1em;
|
||||
background: #fffff5;
|
||||
}
|
||||
|
||||
div.note,div.warning
|
||||
{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.note h3,div.warning h3
|
||||
{
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.navfooter *
|
||||
{
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Links colors and highlighting:
|
||||
***************************************************************************/
|
||||
|
||||
a:link { color: #0048b3; }
|
||||
a:visited { color: #002a6a; }
|
||||
a:hover { background: #ffffcd; }
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Table of contents:
|
||||
***************************************************************************/
|
||||
|
||||
.toc
|
||||
{
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Special elements:
|
||||
***************************************************************************/
|
||||
|
||||
tt
|
||||
{
|
||||
color: #400000;
|
||||
}
|
||||
|
||||
.term
|
||||
{
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
|
||||
div.variablelist dd
|
||||
{
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.default
|
||||
{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.availability
|
||||
{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.varname
|
||||
{
|
||||
color: #400000;
|
||||
}
|
||||
|
||||
|
||||
div.informaltable table
|
||||
{
|
||||
border: 1px solid #6185a0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.informaltable td
|
||||
{
|
||||
border: 0;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
div.informaltable td.default
|
||||
{
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div.informaltable th
|
||||
{
|
||||
text-align: left;
|
||||
color: #005aa0;
|
||||
border: 0;
|
||||
padding: 5px;
|
||||
background: #fffff5;
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
td.varname, td.tagname, td.paramname
|
||||
{
|
||||
font-weight: bold;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
div.epigraph
|
||||
{
|
||||
font-style: italic;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
table.productionset table.productionset
|
||||
{
|
||||
font-family: monospace;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<appendix>
|
||||
<title>Troubleshooting</title>
|
||||
|
||||
<para>
|
||||
(Nothing.)
|
||||
</para>
|
||||
|
||||
</appendix>
|
||||
|
||||
<!--
|
||||
local variables:
|
||||
sgml-parent-document: ("book.xml" "appendix")
|
||||
end:
|
||||
-->
|
||||
@@ -0,0 +1,30 @@
|
||||
rec {
|
||||
|
||||
inherit (import ../../../lib) compileC makeLibrary;
|
||||
|
||||
sources = [
|
||||
./afun.c
|
||||
./aterm.c
|
||||
./bafio.c
|
||||
./byteio.c
|
||||
./gc.c
|
||||
./hash.c
|
||||
./list.c
|
||||
./make.c
|
||||
./md5c.c
|
||||
./memory.c
|
||||
./tafio.c
|
||||
./version.c
|
||||
];
|
||||
|
||||
compile = fn: compileC {
|
||||
main = fn;
|
||||
localIncludes = "auto";
|
||||
};
|
||||
|
||||
libATerm = makeLibrary {
|
||||
libraryName = "ATerm";
|
||||
objects = map {function = compile; list = sources;};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
import test/default.nix
|
||||
@@ -0,0 +1,16 @@
|
||||
let {
|
||||
|
||||
inherit (import ../../../lib) compileC link;
|
||||
|
||||
inherit (import ../aterm) libATerm;
|
||||
|
||||
compile = fn: compileC {
|
||||
main = fn;
|
||||
localIncludes = "auto";
|
||||
cFlags = "-I../aterm";
|
||||
};
|
||||
|
||||
fib = link {objects = compile ./fib.c; libraries = libATerm;};
|
||||
|
||||
body = [fib];
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
[ (import ./trivial)
|
||||
(import ./simple-header)
|
||||
(import ./not-so-simple-header)
|
||||
(import ./not-so-simple-header-auto)
|
||||
(import ./aterm)
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
#define WHAT "World"
|
||||
@@ -0,0 +1,11 @@
|
||||
let {
|
||||
|
||||
inherit (import ../../lib) compileC findIncludes link;
|
||||
|
||||
hello = link {programName = "hello"; objects = compileC {
|
||||
main = ./foo/hello.c;
|
||||
localIncludes = "auto";
|
||||
};};
|
||||
|
||||
body = [hello];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#define HELLO "Hello"
|
||||
|
||||
#include "../../bar/hello.h"
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "fnord/indirect.h"
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf(HELLO " " WHAT "\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
#define WHAT "World"
|
||||
@@ -0,0 +1,14 @@
|
||||
let {
|
||||
|
||||
inherit (import ../../lib) compileC link;
|
||||
|
||||
hello = link {programName = "hello"; objects = compileC {
|
||||
main = ./foo/hello.c;
|
||||
localIncludes = [
|
||||
[./foo/fnord/indirect.h "fnord/indirect.h"]
|
||||
[./bar/hello.h "fnord/../../bar/hello.h"]
|
||||
];
|
||||
};};
|
||||
|
||||
body = [hello];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#define HELLO "Hello"
|
||||
|
||||
#include "../../bar/hello.h"
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "fnord/indirect.h"
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf(HELLO " " WHAT "\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
let {
|
||||
|
||||
inherit (import ../../lib) compileC link;
|
||||
|
||||
hello = link {objects = compileC {
|
||||
main = ./hello.c;
|
||||
localIncludes = [ [./hello.h "hello.h"] ];
|
||||
};};
|
||||
|
||||
body = [hello];
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "hello.h"
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf("Hello " WHAT "\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
#define WHAT "World"
|
||||
@@ -0,0 +1,8 @@
|
||||
let {
|
||||
|
||||
inherit (import ../../lib) compileC link;
|
||||
|
||||
hello = link {objects = compileC {main = ./hello.c;};};
|
||||
|
||||
body = [hello];
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf("Hello World\n");
|
||||
return 0;
|
||||
}
|
||||
Vendored
+30
-9
@@ -1,10 +1,13 @@
|
||||
# Berkeley DB
|
||||
|
||||
DB = db-4.0.14
|
||||
DB_URL = http://www.sleepycat.com/update/snapshot/db-4.0.14.tar.gz
|
||||
DB = db-4.2.52
|
||||
|
||||
$(DB).tar.gz:
|
||||
wget $(DB_URL)
|
||||
@echo "Nix requires Berkeley DB to build."
|
||||
@echo "Please download version 4.2.52 from"
|
||||
@echo " http://www.sleepycat.com/update/snapshot/db-4.2.52.tar.gz"
|
||||
@echo "and place it in the externals/ directory."
|
||||
false
|
||||
|
||||
$(DB): $(DB).tar.gz
|
||||
gunzip < $(DB).tar.gz | tar xvf -
|
||||
@@ -13,23 +16,32 @@ have-db:
|
||||
$(MAKE) $(DB)
|
||||
touch have-db
|
||||
|
||||
if HAVE_BDB
|
||||
build-db:
|
||||
else
|
||||
build-db: have-db
|
||||
(pfx=`pwd` && \
|
||||
cd $(DB)/build_unix && \
|
||||
CC=$(CC) CXX=$(CXX) ../dist/configure --prefix=$$pfx/inst \
|
||||
--enable-cxx --disable-shared && \
|
||||
CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" \
|
||||
../dist/configure --prefix=$$pfx/inst-bdb \
|
||||
--enable-cxx --disable-shared --disable-cryptography \
|
||||
--disable-replication --disable-verify && \
|
||||
make && \
|
||||
make install)
|
||||
touch build-db
|
||||
endif
|
||||
|
||||
|
||||
# CWI ATerm
|
||||
|
||||
ATERM = aterm-2.0
|
||||
ATERM_URL = http://www.cwi.nl/projects/MetaEnv/aterm/aterm-2.0.tar.gz
|
||||
ATERM = aterm-2.1
|
||||
|
||||
$(ATERM).tar.gz:
|
||||
wget $(ATERM_URL)
|
||||
@echo "Nix requires the CWI ATerm library to build."
|
||||
@echo "Please download version 2.1 from"
|
||||
@echo " http://www.cwi.nl/projects/MetaEnv/aterm/aterm-2.1.tar.gz"
|
||||
@echo "and place it in the externals/ directory."
|
||||
false
|
||||
|
||||
$(ATERM): $(ATERM).tar.gz
|
||||
gunzip < $(ATERM).tar.gz | tar xvf -
|
||||
@@ -38,15 +50,24 @@ have-aterm:
|
||||
$(MAKE) $(ATERM)
|
||||
touch have-aterm
|
||||
|
||||
if HAVE_ATERM
|
||||
build-aterm:
|
||||
else
|
||||
build-aterm: have-aterm
|
||||
(pfx=`pwd` && \
|
||||
cd $(ATERM) && \
|
||||
./configure --prefix=$$pfx/inst && \
|
||||
CC="$(CC)" ./configure --prefix=$$pfx/inst-aterm \
|
||||
--with-cflags="-DNDEBUG -DXGC_VERBOSE -DXHASHPEM -DWITH_STATS $(CFLAGS)" && \
|
||||
make && \
|
||||
make install)
|
||||
touch build-aterm
|
||||
endif
|
||||
|
||||
|
||||
all: build-db build-aterm
|
||||
|
||||
EXTRA_DIST = $(DB).tar.gz $(ATERM).tar.gz
|
||||
|
||||
ext-clean:
|
||||
$(RM) -f have-db build-db have-aterm build-aterm
|
||||
$(RM) -rf $(DB) $(ATERM)
|
||||
@@ -0,0 +1,73 @@
|
||||
. $stdenv/setup
|
||||
|
||||
mainName=$(basename $main | cut -c34-)
|
||||
|
||||
echo "compiling \`$mainName'..."
|
||||
|
||||
# Turn $localIncludes into an array.
|
||||
localIncludes=($localIncludes)
|
||||
|
||||
# Determine how many `..' levels appear in the header file references.
|
||||
# E.g., if there is some reference `../../foo.h', then we have to
|
||||
# insert two extra levels in the directory structure, so that `a.c' is
|
||||
# stored at `dotdot/dotdot/a.c', and a reference from it to
|
||||
# `../../foo.h' resolves to `dotdot/dotdot/../../foo.h' == `foo.h'.
|
||||
n=0
|
||||
maxDepth=0
|
||||
for ((n = 0; n < ${#localIncludes[*]}; n += 2)); do
|
||||
target=${localIncludes[$((n + 1))]}
|
||||
|
||||
# Split the target name into path components using some IFS magic.
|
||||
savedIFS="$IFS"
|
||||
IFS=/
|
||||
components=($target)
|
||||
depth=0
|
||||
for ((m = 0; m < ${#components[*]}; m++)); do
|
||||
c=${components[m]}
|
||||
if test "$c" = ".."; then
|
||||
depth=$((depth + 1))
|
||||
fi
|
||||
done
|
||||
IFS="$savedIFS"
|
||||
|
||||
if test $depth -gt $maxDepth; then
|
||||
maxDepth=$depth;
|
||||
fi
|
||||
done
|
||||
|
||||
# Create the extra levels in the directory hierarchy.
|
||||
prefix=
|
||||
for ((n = 0; n < maxDepth; n++)); do
|
||||
prefix="dotdot/$prefix"
|
||||
done
|
||||
|
||||
# Create symlinks to the header files.
|
||||
for ((n = 0; n < ${#localIncludes[*]}; n += 2)); do
|
||||
source=${localIncludes[n]}
|
||||
target=${localIncludes[$((n + 1))]}
|
||||
|
||||
# Create missing directories. We use IFS magic to split the path
|
||||
# into path components.
|
||||
savedIFS="$IFS"
|
||||
IFS=/
|
||||
components=($prefix$target)
|
||||
fullPath=(.)
|
||||
for ((m = 0; m < ${#components[*]} - 1; m++)); do
|
||||
fullPath=("${fullPath[@]}" ${components[m]})
|
||||
if ! test -d "${fullPath[*]}"; then
|
||||
mkdir "${fullPath[*]}"
|
||||
fi
|
||||
done
|
||||
IFS="$savedIFS"
|
||||
|
||||
ln -s $source $prefix$target
|
||||
done
|
||||
|
||||
# Create a symlink to the main file.
|
||||
if ! test "$(readlink $prefix$mainName)" = $main; then
|
||||
ln -s $main $prefix$mainName
|
||||
fi
|
||||
|
||||
mkdir $out
|
||||
test "$prefix" && cd $prefix
|
||||
gcc -Wall $cFlags -c $mainName -o $out/$mainName.o
|
||||
@@ -0,0 +1,46 @@
|
||||
rec {
|
||||
|
||||
inherit (import /home/eelco/nixpkgs/pkgs/system/i686-linux.nix) stdenv;
|
||||
|
||||
compileC = {main, localIncludes ? [], cFlags ? ""}: stdenv.mkDerivation {
|
||||
name = "compile-c";
|
||||
builder = ./compile-c.sh;
|
||||
localIncludes =
|
||||
if localIncludes == "auto" then
|
||||
import (findIncludes {
|
||||
main = toString main;
|
||||
hack = curTime;
|
||||
inherit cFlags;
|
||||
})
|
||||
else
|
||||
localIncludes;
|
||||
inherit main cFlags;
|
||||
};
|
||||
|
||||
/*
|
||||
runCommand = {command}: {
|
||||
name = "run-command";
|
||||
builder = ./run-command.sh;
|
||||
inherit command;
|
||||
};
|
||||
*/
|
||||
|
||||
findIncludes = {main, hack, cFlags ? ""}: stdenv.mkDerivation {
|
||||
name = "find-includes";
|
||||
builder = ./find-includes.sh;
|
||||
inherit main hack cFlags;
|
||||
};
|
||||
|
||||
link = {objects, programName ? "program", libraries ? []}: stdenv.mkDerivation {
|
||||
name = "link";
|
||||
builder = ./link.sh;
|
||||
inherit objects programName libraries;
|
||||
};
|
||||
|
||||
makeLibrary = {objects, libraryName ? []}: stdenv.mkDerivation {
|
||||
name = "library";
|
||||
builder = ./make-library.sh;
|
||||
inherit objects libraryName;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
. $stdenv/setup
|
||||
|
||||
echo "finding includes of \`$(basename $main)'..."
|
||||
|
||||
makefile=$NIX_BUILD_TOP/makefile
|
||||
|
||||
mainDir=$(dirname $main)
|
||||
(cd $mainDir && gcc $cFlags -MM $(basename $main) -MF $makefile) || false
|
||||
|
||||
echo "[" >$out
|
||||
|
||||
while read line; do
|
||||
line=$(echo "$line" | sed 's/.*://')
|
||||
for i in $line; do
|
||||
fullPath=$(readlink -f $mainDir/$i)
|
||||
echo " [ $fullPath \"$i\" ]" >>$out
|
||||
done
|
||||
done < $makefile
|
||||
|
||||
echo "]" >>$out
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
. $stdenv/setup
|
||||
|
||||
objs=
|
||||
for i in $objects; do
|
||||
obj=$(echo $i/*.o)
|
||||
objs="$objs $obj"
|
||||
done
|
||||
|
||||
libs=
|
||||
for i in $libraries; do
|
||||
lib=$(echo $i/*.a)
|
||||
name=$(echo $(basename $lib) | sed -e 's/^lib//' -e 's/.a$//')
|
||||
libs="$libs -L$(dirname $lib) -l$name"
|
||||
done
|
||||
|
||||
echo "linking object files into \`$programName'..."
|
||||
|
||||
mkdir $out
|
||||
gcc -o $out/$programName $objs $libs
|
||||
@@ -0,0 +1,15 @@
|
||||
. $stdenv/setup
|
||||
|
||||
objs=
|
||||
for i in $objects; do
|
||||
obj=$(echo $i/*.o)
|
||||
objs="$objs $obj"
|
||||
done
|
||||
|
||||
echo "archiving object files into library \`$libraryName'..."
|
||||
|
||||
outPath=$out/lib${libraryName}.a
|
||||
|
||||
mkdir $out
|
||||
ar crs $outPath $objs
|
||||
ranlib $outPath
|
||||
@@ -0,0 +1 @@
|
||||
SUBDIRS = emacs
|
||||
@@ -0,0 +1,5 @@
|
||||
EXTRA_DIST = nix-mode.el
|
||||
|
||||
install-data-local:
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/emacs/site-lisp
|
||||
$(INSTALL_DATA) nix-mode.el $(DESTDIR)$(datadir)/emacs/site-lisp
|
||||
@@ -0,0 +1,10 @@
|
||||
The Nix Emacs mode supports syntax highlighting, somewhat sensible
|
||||
indenting, and refilling of comments.
|
||||
|
||||
To enable Nix mode in Emacs, add something like this to your ~/.emacs
|
||||
file:
|
||||
|
||||
(load "/nix/share/emacs/site-lisp/nix-mode.el")
|
||||
|
||||
This automatically causes Nix mode to be activated for all files with
|
||||
extension `.nix'.
|
||||
@@ -0,0 +1,109 @@
|
||||
(defun nix-mode ()
|
||||
"Major mode for editing Nix expressions.
|
||||
|
||||
The following commands may be useful:
|
||||
|
||||
'\\[newline-and-indent]'
|
||||
Insert a newline and move the cursor to align with the previous
|
||||
non-empty line.
|
||||
|
||||
'\\[fill-paragraph]'
|
||||
Refill a paragraph so that all lines are at most `fill-column'
|
||||
lines long. This should do the right thing for comments beginning
|
||||
with `#'. However, this command doesn't work properly yet if the
|
||||
comment is adjacent to code (i.e., no intervening empty lines).
|
||||
In that case, select the text to be refilled and use
|
||||
`\\[fill-region]' instead.
|
||||
|
||||
The hook `nix-mode-hook' is run when Nix mode is started.
|
||||
|
||||
\\{nix-mode-map}
|
||||
"
|
||||
|
||||
(interactive)
|
||||
|
||||
(kill-all-local-variables)
|
||||
|
||||
(setq major-mode 'nix-mode)
|
||||
(setq mode-name "Nix")
|
||||
|
||||
(use-local-map nix-mode-map)
|
||||
|
||||
(set-syntax-table nix-mode-syntax-table)
|
||||
|
||||
;; Font lock support.
|
||||
(setq font-lock-defaults '(nix-keywords nil nil nil nil))
|
||||
|
||||
;; Automatic indentation [C-j].
|
||||
(make-local-variable 'indent-line-function)
|
||||
(setq indent-line-function 'nix-indent-line)
|
||||
|
||||
;; Indenting of comments.
|
||||
(make-local-variable 'comment-start)
|
||||
(setq comment-start "# ")
|
||||
(make-local-variable 'comment-end)
|
||||
(setq comment-end "")
|
||||
(make-local-variable 'comment-start-skip)
|
||||
(setq comment-start-skip "\\(^\\|\\s-\\);?#+ *")
|
||||
|
||||
;; Filling of comments.
|
||||
(make-local-variable 'adaptive-fill-mode)
|
||||
(setq adaptive-fill-mode t)
|
||||
(make-local-variable 'paragraph-start)
|
||||
(setq paragraph-start "[ \t]*\\(#+[ \t]*\\)?$")
|
||||
(make-local-variable 'paragraph-separate)
|
||||
(setq paragraph-separate paragraph-start)
|
||||
|
||||
(run-hooks 'nix-mode-hook)
|
||||
)
|
||||
|
||||
|
||||
(defvar nix-mode-map nil
|
||||
"Keymap for Nix mode.")
|
||||
|
||||
(setq nix-mode-map (make-sparse-keymap))
|
||||
;(define-key nix-mode-map [tab] 'tab-to-tab-stop)
|
||||
|
||||
|
||||
(defvar nix-keywords
|
||||
'("\\<if\\>" "\\<then\\>" "\\<else\\>" "\\<assert\\>"
|
||||
"\\<let\\>" "\\<rec\\>" "\\<inherit\\>"
|
||||
("\\<true\\>" . font-lock-builtin-face)
|
||||
("\\<false\\>" . font-lock-builtin-face)
|
||||
("\\<null\\>" . font-lock-builtin-face)
|
||||
("\\<import\\>" . font-lock-builtin-face)
|
||||
("\\<derivation\\>" . font-lock-builtin-face)
|
||||
("\\<baseNameOf\\>" . font-lock-builtin-face)
|
||||
("\\<toString\\>" . font-lock-builtin-face)
|
||||
("\\<isNull\\>" . font-lock-builtin-face)
|
||||
("\\<\\([a-zA-Z_][a-zA-Z0-9_']*\\)[ \t]*="
|
||||
(1 font-lock-variable-name-face nil nil))
|
||||
("[a-zA-Z][a-zA-Z0-9\\+-\\.]*:[a-zA-Z0-9%/\\?:@&=\\+\\$,_\\.!~\\*'-]+"
|
||||
. font-lock-constant-face)
|
||||
("[a-zA-Z0-9._\\+-]*\\(/[a-zA-Z0-9._\\+-]+\\)+"
|
||||
. font-lock-constant-face)
|
||||
))
|
||||
|
||||
|
||||
(defvar nix-mode-syntax-table nil
|
||||
"Syntax table for Nix mode.")
|
||||
|
||||
(if nix-mode-syntax-table
|
||||
nil
|
||||
(progn
|
||||
(setq nix-mode-syntax-table (make-syntax-table))
|
||||
(modify-syntax-entry ?/ ". 14" nix-mode-syntax-table)
|
||||
(modify-syntax-entry ?* ". 23" nix-mode-syntax-table)
|
||||
(modify-syntax-entry ?# "< b" nix-mode-syntax-table)
|
||||
(modify-syntax-entry ?\n "> b" nix-mode-syntax-table)
|
||||
))
|
||||
|
||||
|
||||
(defun nix-indent-line ()
|
||||
"Indent current line in a Nix expression."
|
||||
(interactive)
|
||||
(indent-relative-maybe))
|
||||
|
||||
|
||||
(setq auto-mode-alist (cons '("\\.nix\\'" . nix-mode) auto-mode-alist))
|
||||
(setq auto-mode-alist (cons '("\\.nix.in\\'" . nix-mode) auto-mode-alist))
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
Summary: The Nix software deployment system
|
||||
Name: nix
|
||||
Version: @version@
|
||||
Release: 1
|
||||
License: GPL
|
||||
Group: WeetNiet
|
||||
URL: http://www.cs.uu.nl/groups/ST/twiki/bin/view/Trace/NixDeploymentSystem
|
||||
Source0: %{name}-@version@.tar.gz
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
|
||||
%define _prefix /nix
|
||||
Prefix: %{_prefix}
|
||||
Requires: /usr/bin/perl
|
||||
|
||||
%description
|
||||
|
||||
Nix is a software deployment system.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
./configure --prefix=%{_prefix}
|
||||
make
|
||||
make check
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make DESTDIR=$RPM_BUILD_ROOT install
|
||||
strip $RPM_BUILD_ROOT/%{_prefix}/bin/* || true
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%{_prefix}/bin
|
||||
%{_prefix}/libexec
|
||||
%{_prefix}/var
|
||||
%{_prefix}/share
|
||||
%{_prefix}/man
|
||||
%{_prefix}/store
|
||||
%config
|
||||
%{_prefix}/etc
|
||||
#%doc
|
||||
#%{_prefix}/share/nix/manual
|
||||
+18
-11
@@ -1,18 +1,25 @@
|
||||
bin_SCRIPTS = nix-switch nix-collect-garbage \
|
||||
nix-pull nix-push
|
||||
bin_SCRIPTS = nix-collect-garbage \
|
||||
nix-pull nix-push nix-prefetch-url \
|
||||
nix-install-package nix-channel nix-build
|
||||
|
||||
noinst_SCRIPTS = nix-profile.sh
|
||||
|
||||
install-exec-local:
|
||||
$(INSTALL) -d $(sysconfdir)/profile.d
|
||||
$(INSTALL_PROGRAM) nix-profile.sh $(sysconfdir)/profile.d/nix.sh
|
||||
$(INSTALL) -d $(sysconfdir)/nix
|
||||
nix-pull nix-push: readmanifest.pm
|
||||
|
||||
install-exec-local: readmanifest.pm
|
||||
$(INSTALL) -d $(DESTDIR)$(sysconfdir)/profile.d
|
||||
$(INSTALL_PROGRAM) nix-profile.sh $(DESTDIR)$(sysconfdir)/profile.d/nix.sh
|
||||
$(INSTALL) -d $(DESTDIR)$(libexecdir)/nix
|
||||
$(INSTALL_DATA) readmanifest.pm $(DESTDIR)$(libexecdir)/nix
|
||||
$(INSTALL) -d $(DESTDIR)$(sysconfdir)/nix
|
||||
# !!! don't overwrite local modifications
|
||||
$(INSTALL_DATA) prebuilts.conf $(sysconfdir)/nix/prebuilts.conf
|
||||
$(INSTALL_DATA) prebuilts.conf $(DESTDIR)$(sysconfdir)/nix/prebuilts.conf
|
||||
|
||||
include ../substitute.mk
|
||||
|
||||
EXTRA_DIST = nix-switch.in nix-collect-garbage.in \
|
||||
nix-pull.in nix-push.in nix-profile.sh.in \
|
||||
prebuilts.conf
|
||||
|
||||
EXTRA_DIST = nix-collect-garbage.in \
|
||||
nix-pull.in nix-push.in nix-profile.sh.in \
|
||||
nix-prefetch-url.in nix-install-package.in \
|
||||
nix-channel.in \
|
||||
prebuilts.conf readmanifest.pm.in \
|
||||
nix-build.in
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#! @shell@ -e
|
||||
|
||||
nixExpr=$1
|
||||
|
||||
if test -z "$nixExpr"; then
|
||||
echo "syntax: $0 NIX-EXPR..." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extraArgs=
|
||||
|
||||
for i in "$@"; do
|
||||
case "$i" in
|
||||
-*)
|
||||
extraArgs="$extraArgs $i"
|
||||
;;
|
||||
*)
|
||||
storeExpr=$(nix-instantiate "$i")
|
||||
for j in $storeExpr; do
|
||||
echo "store expression is $j" >&2
|
||||
done
|
||||
nix-store -qnfv $extraArgs $storeExpr
|
||||
;;
|
||||
esac
|
||||
done
|
||||
Executable
+115
@@ -0,0 +1,115 @@
|
||||
#! @perl@ -w
|
||||
|
||||
use strict;
|
||||
|
||||
|
||||
# Figure out the name of the `.nix-channels' file to use.
|
||||
my $home = $ENV{"HOME"};
|
||||
die '$HOME not set' unless defined $home;
|
||||
my $channelsList = "$home/.nix-channels";
|
||||
|
||||
|
||||
my @channels;
|
||||
|
||||
|
||||
# Reads the list of channels from the file $channelsList;
|
||||
sub readChannels {
|
||||
return if (!-f $channelsList);
|
||||
open CHANNELS, "<$channelsList" or die "cannot open `$channelsList'";
|
||||
while (<CHANNELS>) {
|
||||
chomp;
|
||||
push @channels, $_;
|
||||
}
|
||||
close CHANNELS;
|
||||
}
|
||||
|
||||
|
||||
# Writes the list of channels to the file $channelsList;
|
||||
sub writeChannels {
|
||||
open CHANNELS, ">$channelsList" or die "cannot open `$channelsList'";
|
||||
foreach my $url (@channels) {
|
||||
print CHANNELS "$url\n";
|
||||
}
|
||||
close CHANNELS;
|
||||
}
|
||||
|
||||
|
||||
# Adds a channel to the file $channelsList;
|
||||
sub addChannel {
|
||||
my $url = shift;
|
||||
readChannels;
|
||||
foreach my $url2 (@channels) {
|
||||
return if $url eq $url2;
|
||||
}
|
||||
push @channels, $url;
|
||||
writeChannels;
|
||||
}
|
||||
|
||||
|
||||
# Fetch Nix expressions and pull cache manifests from the subscribed
|
||||
# channels.
|
||||
sub update {
|
||||
readChannels;
|
||||
|
||||
# Pull cache manifests.
|
||||
foreach my $url (@channels) {
|
||||
print "pulling cache manifest from `$url'\n";
|
||||
system "@bindir@/nix-pull '$url'/MANIFEST";
|
||||
die "cannot pull cache manifest from `$url'" if ($? != 0);
|
||||
}
|
||||
|
||||
# Create a Nix expression that fetches and unpacks the channel Nix
|
||||
# expressions.
|
||||
|
||||
my $nixExpr = "[";
|
||||
|
||||
foreach my $url (@channels) {
|
||||
my $fullURL = "$url/nixexprs.tar.bz2";
|
||||
my $hash = `@bindir@/nix-prefetch-url '$fullURL' 2> /dev/null`
|
||||
or die "cannot fetch `$fullURL'";
|
||||
chomp $hash;
|
||||
# !!! escaping
|
||||
$nixExpr .= "((import @datadir@/nix/corepkgs/fetchurl) " .
|
||||
"{url = $fullURL; md5 = \"$hash\"; system = \"@system@\";}) "
|
||||
}
|
||||
|
||||
$nixExpr .= "]";
|
||||
|
||||
$nixExpr =
|
||||
"(import @datadir@/nix/corepkgs/channels/unpack.nix) " .
|
||||
"{inputs = $nixExpr; system = \"@system@\";}";
|
||||
|
||||
# Instantiate and realise it.
|
||||
my $storeExpr = `echo '$nixExpr' | @bindir@/nix-instantiate -`
|
||||
or die "cannot instantiate Nix expression";
|
||||
chomp $storeExpr;
|
||||
|
||||
my $outPath = `nix-store -qnfB '$storeExpr'`
|
||||
or die "cannot realise store expression";
|
||||
chomp $outPath;
|
||||
|
||||
# Make it the default Nix expression for `nix-env'.
|
||||
system "@bindir@/nix-env --import '$outPath'";
|
||||
die "cannot pull set default Nix expression to `$outPath'" if ($? != 0);
|
||||
}
|
||||
|
||||
|
||||
while (scalar @ARGV) {
|
||||
my $arg = shift @ARGV;
|
||||
|
||||
if ($arg eq "--add") {
|
||||
die "syntax: nix-channel --add URL" if (scalar @ARGV != 1);
|
||||
addChannel (shift @ARGV);
|
||||
last;
|
||||
}
|
||||
|
||||
elsif ($arg eq "--update") {
|
||||
die "syntax: nix-channel --update" if (scalar @ARGV != 0);
|
||||
update;
|
||||
last;
|
||||
}
|
||||
|
||||
else {
|
||||
die "unknown argument `$arg'";
|
||||
}
|
||||
}
|
||||
@@ -1,39 +1,100 @@
|
||||
#! /usr/bin/perl -w
|
||||
#! @perl@ -w
|
||||
|
||||
my $linkdir = "@localstatedir@/nix/links";
|
||||
my $storedir = "@prefix@/store";
|
||||
use strict;
|
||||
use IPC::Open2;
|
||||
|
||||
my $rootsDir = "@localstatedir@/nix/gcroots";
|
||||
my $storeDir = "@storedir@";
|
||||
|
||||
my %alive;
|
||||
|
||||
my $keepsuccessors = 0;
|
||||
my $keepSuccessors = 1;
|
||||
my $invert = 0;
|
||||
|
||||
my @roots = ();
|
||||
|
||||
|
||||
# Parse the command line.
|
||||
foreach my $arg (@ARGV) {
|
||||
if ($arg eq "--keep-successors") { $keepsuccessors = 1; }
|
||||
if ($arg eq "--no-successors") { $keepSuccessors = 0; }
|
||||
elsif ($arg eq "--invert") { $invert = 1; }
|
||||
else { die "unknown argument `$arg'" };
|
||||
}
|
||||
|
||||
|
||||
# Read all GC roots from the given file.
|
||||
sub readRoots {
|
||||
my $fileName = shift;
|
||||
open ROOT, "<$fileName" or die "cannot open `$fileName': $!";
|
||||
while (<ROOT>) {
|
||||
chomp;
|
||||
foreach my $root (split ' ') {
|
||||
die "bad root `$root' in file `$fileName'"
|
||||
unless $root =~ /^\S+$/;
|
||||
push @roots, $root;
|
||||
}
|
||||
}
|
||||
close ROOT;
|
||||
}
|
||||
|
||||
|
||||
# Recursively finds all *.gcroot files in the given directory.
|
||||
sub findRoots;
|
||||
sub findRoots {
|
||||
my $followSymlinks = shift;
|
||||
my $dir = shift;
|
||||
|
||||
opendir(DIR, $dir) or die "cannot open directory `$dir': $!";
|
||||
my @names = readdir DIR or die "cannot read directory `$dir': $!";
|
||||
closedir DIR;
|
||||
|
||||
foreach my $name (@names) {
|
||||
next if $name eq "." || $name eq "..";
|
||||
$name = $dir . "/" . $name;
|
||||
if ($name =~ /.gcroot$/ && -f $name) {
|
||||
readRoots $name;
|
||||
}
|
||||
elsif (-d $name) {
|
||||
if ($followSymlinks || !-l $name) {
|
||||
findRoots 0, $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Find GC roots, starting at $rootsDir.
|
||||
findRoots 1, $rootsDir;
|
||||
|
||||
|
||||
# Determine all store paths reachable from the roots.
|
||||
my $extraarg = "";
|
||||
if ($keepsuccessors) { $extraarg = "--include-successors"; };
|
||||
open HASHES, "nix --query --requisites $extraarg \$(cat $linkdir/*.id) |" or die "in `nix -qrh'";
|
||||
while (<HASHES>) {
|
||||
if ($keepSuccessors) { $extraarg = "--include-successors"; };
|
||||
my $pid = open2(\*READ, \*WRITE, "@bindir@/nix-store --query --requisites $extraarg @roots")
|
||||
or die "determining live paths";
|
||||
close WRITE;
|
||||
while (<READ>) {
|
||||
chomp;
|
||||
$alive{$_} = 1;
|
||||
if ($invert) { print "$_\n"; };
|
||||
}
|
||||
close HASHES;
|
||||
close READ;
|
||||
|
||||
waitpid $pid, 0;
|
||||
$? == 0 or die "determining live paths";
|
||||
|
||||
exit 0 if ($invert);
|
||||
|
||||
opendir(DIR, $storedir) or die "cannot opendir $storedir: $!";
|
||||
my @names = readdir(DIR);
|
||||
closedir DIR;
|
||||
|
||||
foreach my $name (@names) {
|
||||
# Using that information, find all store paths *not* reachable from
|
||||
# the roots.
|
||||
opendir(DIR, $storeDir) or die "cannot open directory $storeDir: $!";
|
||||
foreach my $name (readdir DIR) {
|
||||
next if ($name eq "." || $name eq "..");
|
||||
$name = "$storedir/$name";
|
||||
$name = "$storeDir/$name";
|
||||
if (!$alive{$name}) {
|
||||
print "$name\n";
|
||||
}
|
||||
}
|
||||
closedir DIR;
|
||||
@@ -0,0 +1,37 @@
|
||||
#! @perl@ -w
|
||||
|
||||
use strict;
|
||||
use POSIX qw(tmpnam);
|
||||
|
||||
my $pkgfile = $ARGV[0];
|
||||
die unless defined $pkgfile;
|
||||
|
||||
my $tmpdir;
|
||||
do { $tmpdir = tmpnam(); }
|
||||
until mkdir $tmpdir, 0777;
|
||||
|
||||
# !!! remove tmpdir on exit
|
||||
|
||||
print "Unpacking $pkgfile in $tmpdir...\n";
|
||||
system "bunzip2 < $pkgfile | (cd $tmpdir && tar xf -)";
|
||||
die if $?;
|
||||
|
||||
print "This package contains the following derivations:\n";
|
||||
system "@bindir@/nix-env -qasf $tmpdir/default.nix";
|
||||
die if $?;
|
||||
|
||||
print "Do you wish to install these (Y/N)? ";
|
||||
my $reply = <STDIN>;
|
||||
chomp $reply;
|
||||
exit if (!($reply eq "y"));
|
||||
|
||||
print "Pulling caches...\n";
|
||||
system "@bindir@/nix-pull `cat $tmpdir/caches`";
|
||||
die if $?;
|
||||
|
||||
print "Installing package...\n";
|
||||
system "@bindir@/nix-env -if $tmpdir/default.nix '*'";
|
||||
die if $?;
|
||||
|
||||
print "Installation succeeded! Press Enter to continue.\n";
|
||||
<STDIN>;
|
||||
@@ -0,0 +1,41 @@
|
||||
#! @shell@ -e
|
||||
|
||||
url=$1
|
||||
|
||||
if test -z "$url"; then
|
||||
echo "syntax: nix-prefetch-url URL" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# !!! race? should be relatively safe, `svn export' barfs if $tmpPath exists.
|
||||
tmpPath1=@storedir@/nix-prefetch-url-$$
|
||||
|
||||
# Perform the checkout.
|
||||
@curl@ --fail --location --max-redirs 20 "$url" > $tmpPath1
|
||||
|
||||
# Compute the hash.
|
||||
hash=$(@bindir@/nix-hash --flat $tmpPath1)
|
||||
echo "hash is $hash" >&2
|
||||
|
||||
# Rename it so that the fetchsvn builder can find it.
|
||||
tmpPath2=@storedir@/nix-prefetch-url-$hash
|
||||
test -e $tmpPath2 || mv $tmpPath1 $tmpPath2 # !!! race
|
||||
|
||||
# Create a Nix expression that does a fetchsvn.
|
||||
storeExpr=$( \
|
||||
echo "(import @datadir@/nix/corepkgs/fetchurl) \
|
||||
{url = $url; md5 = \"$hash\"; system = \"@system@\";}" \
|
||||
| @bindir@/nix-instantiate -)
|
||||
|
||||
# Realise it.
|
||||
finalPath=$(@bindir@/nix-store -qnB --force-realise $storeExpr)
|
||||
|
||||
echo "path is $finalPath" >&2
|
||||
|
||||
rm -rf $tmpPath2 || true
|
||||
|
||||
echo $hash
|
||||
|
||||
if test -n "$PRINT_PATH"; then
|
||||
echo $finalPath
|
||||
fi
|
||||
@@ -1,20 +1,11 @@
|
||||
#if test -z "$NIX_SET"; then
|
||||
if test -n "$HOME"; then
|
||||
NIX_LINK="$HOME/.nix-profile"
|
||||
|
||||
# export NIX_SET=1
|
||||
if ! test -L "$NIX_LINK"; then
|
||||
echo "creating $NIX_LINK"
|
||||
_NIX_DEF_LINK=@localstatedir@/nix/profiles/default
|
||||
ln -s "$_NIX_DEF_LINK" "$NIX_LINK"
|
||||
fi
|
||||
|
||||
NIX_LINKS=@localstatedir@/nix/links/current
|
||||
|
||||
export PATH=$NIX_LINKS/bin:@prefix@/bin:$PATH
|
||||
|
||||
# export LD_LIBRARY_PATH=$NIX_LINKS/lib:$LD_LIBRARY_PATH
|
||||
|
||||
export LIBRARY_PATH=$NIX_LINKS/lib:$LIBRARY_PATH
|
||||
|
||||
export C_INCLUDE_PATH=$NIX_LINKS/include:$C_INCLUDE_PATH
|
||||
export CPLUS_INCLUDE_PATH=$NIX_LINKS/include:$CPLUS_INCLUDE_PATH
|
||||
|
||||
export PKG_CONFIG_PATH=$NIX_LINKS/lib/pkgconfig:$PKG_CONFIG_PATH
|
||||
|
||||
# export MANPATH=$NIX_LINKS/man:$MANPATH
|
||||
|
||||
#fi
|
||||
export PATH=$NIX_LINK/bin:@prefix@/bin:$PATH
|
||||
fi
|
||||
+83
-81
@@ -1,91 +1,93 @@
|
||||
#! /usr/bin/perl -w
|
||||
#! @perl@ -w -I@libexecdir@/nix
|
||||
|
||||
my $tmpfile = "@localstatedir@/nix/pull.tmp";
|
||||
my $conffile = "@sysconfdir@/nix/prebuilts.conf";
|
||||
use strict;
|
||||
use IPC::Open2;
|
||||
use POSIX qw(tmpnam);
|
||||
use readmanifest;
|
||||
|
||||
my @subs;
|
||||
my @sucs;
|
||||
my $tmpdir;
|
||||
do { $tmpdir = tmpnam(); }
|
||||
until mkdir $tmpdir, 0777;
|
||||
|
||||
open CONFFILE, "<$conffile";
|
||||
my $manifest = "$tmpdir/manifest";
|
||||
my $confFile = "@sysconfdir@/nix/prebuilts.conf";
|
||||
|
||||
while (<CONFFILE>) {
|
||||
#END { unlink $manifest; rmdir $tmpdir; }
|
||||
|
||||
chomp;
|
||||
if (/^\s*(\S+)\s*(\#.*)?$/) {
|
||||
my $url = $1;
|
||||
|
||||
print "obtaining list of Nix archives at $url...\n";
|
||||
|
||||
system "wget '$url' -O '$tmpfile' 2> /dev/null"; # !!! escape
|
||||
if ($?) { die "`wget' failed"; }
|
||||
|
||||
open INDEX, "<$tmpfile";
|
||||
|
||||
while (<INDEX>) {
|
||||
# Get all links to prebuilts, that is, file names of the
|
||||
# form foo-HASH-HASH.tar.bz2.
|
||||
next unless (/HREF=\"([^\"]*)\"/);
|
||||
my $fn = $1;
|
||||
next if $fn =~ /\.\./;
|
||||
next if $fn =~ /\//;
|
||||
next unless $fn =~ /^([0-9a-z]{32})-([0-9a-z]{32})(.*)\.nar\.bz2$/;
|
||||
my $hash = $1;
|
||||
my $id = $2;
|
||||
my $outname = $3;
|
||||
my $fsid;
|
||||
if ($outname =~ /^-/) {
|
||||
next unless $outname =~ /^-((s-([0-9a-z]{32}))?.*)$/;
|
||||
$outname = $1;
|
||||
$fsid = $3;
|
||||
} else {
|
||||
$outname = "unnamed";
|
||||
}
|
||||
|
||||
print "registering $id -> $url/$fn\n";
|
||||
|
||||
# Construct a Fix expression that fetches and unpacks a
|
||||
# Nix archive from the network.
|
||||
my $fetch =
|
||||
"App(IncludeFix(\"fetchurl/fetchurl.fix\"), " .
|
||||
"[(\"url\", \"$url/$fn\"), (\"md5\", \"$hash\")])";
|
||||
my $fixexpr =
|
||||
"App(IncludeFix(\"nar/unnar.fix\"), " .
|
||||
"[ (\"nar\", $fetch)" .
|
||||
", (\"name\", \"$outname\")" .
|
||||
", (\"id\", \"$id\")" .
|
||||
"])";
|
||||
|
||||
my $fixfile = "/tmp/nix-pull-tmp.fix";
|
||||
open FIX, ">$fixfile";
|
||||
print FIX $fixexpr;
|
||||
close FIX;
|
||||
|
||||
# Instantiate a Nix expression from the Fix expression.
|
||||
my $nid = `fix $fixfile`;
|
||||
$? and die "instantiating Nix archive expression";
|
||||
chomp $nid;
|
||||
die unless $nid =~ /^([0-9a-z]{32})$/;
|
||||
|
||||
push @subs, $id;
|
||||
push @subs, $nid;
|
||||
|
||||
# Does the name encode a successor relation?
|
||||
if (defined $fsid) {
|
||||
print "NORMAL $fsid -> $id\n";
|
||||
push @sucs, $fsid;
|
||||
push @sucs, $id;
|
||||
}
|
||||
}
|
||||
|
||||
close INDEX;
|
||||
|
||||
unlink $tmpfile;
|
||||
# Obtain URLs either from the command line or from a configuration file.
|
||||
my %storePaths2urls;
|
||||
my %urls2hashes;
|
||||
my %successors;
|
||||
sub doURL {
|
||||
my $url = shift;
|
||||
processURL $manifest, $url, \%storePaths2urls, \%urls2hashes, \%successors;
|
||||
}
|
||||
if (scalar @ARGV > 0) {
|
||||
while (@ARGV) {
|
||||
my $url = shift @ARGV;
|
||||
doURL $url;
|
||||
}
|
||||
|
||||
} else {
|
||||
open CONFFILE, "<$confFile";
|
||||
while (<CONFFILE>) {
|
||||
chomp;
|
||||
if (/^\s*(\S+)\s*(\#.*)?$/) {
|
||||
my $url = $1;
|
||||
doURL $url;
|
||||
}
|
||||
}
|
||||
close CONFFILE;
|
||||
}
|
||||
|
||||
system "nix --substitute @subs";
|
||||
if ($?) { die "`nix --substitute' failed"; }
|
||||
|
||||
system "nix --successor @sucs";
|
||||
if ($?) { die "`nix --successor' failed"; }
|
||||
my $size = scalar (keys %storePaths2urls);
|
||||
print "$size store paths in manifest\n";
|
||||
|
||||
|
||||
# Instantiate a store expression that builds the substitute program
|
||||
# (the program that fetches URLs and unpacks them into the store).
|
||||
my $nixExpr =
|
||||
"(import @datadir@/nix/corepkgs/nix-pull) " .
|
||||
"{system = \"@system@\";}";
|
||||
|
||||
print STDERR "instantiating store expression...\n";
|
||||
my $storeExpr = `echo '$nixExpr' | @bindir@/nix-instantiate -`
|
||||
or die "cannot instantiate Nix expression";
|
||||
chomp $storeExpr;
|
||||
|
||||
|
||||
# Register all substitutes.
|
||||
print STDERR "registering substitutes...\n";
|
||||
|
||||
my $pid = open2(\*READ, \*WRITE, "@bindir@/nix-store --substitute")
|
||||
or die "cannot run nix-store";
|
||||
|
||||
close READ;
|
||||
|
||||
foreach my $storePath (keys %storePaths2urls) {
|
||||
print WRITE "$storePath\n";
|
||||
print WRITE "$storeExpr\n";
|
||||
print WRITE "/fetch\n";
|
||||
print WRITE "2\n";
|
||||
print WRITE "$storePaths2urls{$storePath}\n";
|
||||
print WRITE "$urls2hashes{$storePaths2urls{$storePath}}\n";
|
||||
}
|
||||
|
||||
close WRITE;
|
||||
|
||||
waitpid $pid, 0;
|
||||
$? == 0 or die "nix-store failed";
|
||||
|
||||
|
||||
# Register all successors.
|
||||
print STDERR "registering successors...\n";
|
||||
my @sucs = %successors;
|
||||
while (scalar @sucs > 0) {
|
||||
my $n = scalar @sucs;
|
||||
if ($n > 256) { $n = 256 };
|
||||
my @sucs2 = @sucs[0..$n - 1];
|
||||
@sucs = @sucs[$n..scalar @sucs - 1];
|
||||
system "@bindir@/nix-store --successor @sucs2";
|
||||
if ($?) { die "`nix-store --successor' failed"; }
|
||||
}
|
||||
+156
-57
@@ -1,81 +1,180 @@
|
||||
#! /usr/bin/perl -w
|
||||
#! @perl@ -w
|
||||
|
||||
my @pushlist;
|
||||
use strict;
|
||||
use POSIX qw(tmpnam);
|
||||
|
||||
foreach my $id (@ARGV) {
|
||||
my $tmpdir;
|
||||
do { $tmpdir = tmpnam(); }
|
||||
until mkdir $tmpdir, 0777;
|
||||
|
||||
die unless $id =~ /^([0-9a-z]{32})$/;
|
||||
my $nixfile = "$tmpdir/create-nars.nix";
|
||||
my $manifest = "$tmpdir/MANIFEST";
|
||||
|
||||
END { unlink $manifest; unlink $nixfile; rmdir $tmpdir; }
|
||||
|
||||
my $curl = "@curl@ --fail --silent";
|
||||
my $extraCurlFlags = ${ENV{'CURL_FLAGS'}};
|
||||
$curl = "$curl $extraCurlFlags" if defined $extraCurlFlags;
|
||||
|
||||
|
||||
# Parse the command line.
|
||||
my $archives_put_url = shift @ARGV;
|
||||
my $archives_get_url = shift @ARGV;
|
||||
my $manifest_put_url = shift @ARGV;
|
||||
|
||||
|
||||
# From the given store expressions, determine the requisite store
|
||||
# paths.
|
||||
my %storepaths;
|
||||
|
||||
foreach my $storeexpr (@ARGV) {
|
||||
die unless $storeexpr =~ /^\//;
|
||||
|
||||
# Get all paths referenced by the normalisation of the given
|
||||
# fstate expression.
|
||||
system "nix --install $id";
|
||||
if ($?) { die "`nix --install' failed"; }
|
||||
# Nix expression.
|
||||
system "@bindir@/nix-store --realise $storeexpr > /dev/null";
|
||||
die if ($?);
|
||||
|
||||
my @paths;
|
||||
|
||||
open PATHS, "nix --query --requisites --include-successors $id 2> /dev/null |" or die "nix -qr";
|
||||
open PATHS, "@bindir@/nix-store --query --requisites --include-successors $storeexpr 2> /dev/null |" or die;
|
||||
while (<PATHS>) {
|
||||
chomp;
|
||||
die "bad: $_" unless /^\//;
|
||||
push @paths, $_;
|
||||
$storepaths{$_} = "";
|
||||
}
|
||||
close PATHS;
|
||||
}
|
||||
|
||||
# Also add all normal forms that are contained in these paths.
|
||||
# open PATHS, "nix --query --generators --path @paths |" or die "nix -qg";
|
||||
# while (<PATHS>) {
|
||||
# chomp;
|
||||
# die "bad: $_" unless /^\//;
|
||||
# push @paths, $_;
|
||||
# }
|
||||
# close PATHS;
|
||||
my @storepaths = keys %storepaths;
|
||||
|
||||
# For each path, create a Fix expression that turns the path into
|
||||
# a Nix archive.
|
||||
foreach my $path (@paths) {
|
||||
|
||||
next unless ($path =~ /\/([0-9a-z]{32})[^\/]*/);
|
||||
my $pathid = $1;
|
||||
# For each path, create a Nix expression that turns the path into
|
||||
# a Nix archive.
|
||||
open NIX, ">$nixfile";
|
||||
print NIX "[";
|
||||
|
||||
# Construct a name for the Nix archive. If the file is an
|
||||
# fstate successor, encode this into the name.
|
||||
my $name = $pathid;
|
||||
if ($path =~ /-s-([0-9a-z]{32}).nix$/) {
|
||||
$name = "$name-s-$1";
|
||||
foreach my $storepath (@storepaths) {
|
||||
die unless ($storepath =~ /\/[0-9a-z]{32}.*$/);
|
||||
|
||||
# Construct a Nix expression that creates a Nix archive.
|
||||
my $nixexpr =
|
||||
"((import @datadir@/nix/corepkgs/nar/nar.nix) " .
|
||||
# !!! $storepath should be represented as a closure
|
||||
"{path = \"$storepath\"; system = \"@system@\";}) ";
|
||||
|
||||
print NIX $nixexpr;
|
||||
}
|
||||
|
||||
print NIX "]";
|
||||
close NIX;
|
||||
|
||||
|
||||
# Instantiate store expressions from the Nix expression.
|
||||
my @storeexprs;
|
||||
print STDERR "instantiating store expressions...\n";
|
||||
open STOREEXPRS, "@bindir@/nix-instantiate $nixfile |" or die "cannot run nix-instantiate";
|
||||
while (<STOREEXPRS>) {
|
||||
chomp;
|
||||
die unless /^\//;
|
||||
push @storeexprs, $_;
|
||||
}
|
||||
close STOREEXPRS;
|
||||
|
||||
|
||||
# Realise the store expressions.
|
||||
print STDERR "creating archives...\n";
|
||||
|
||||
my @narpaths;
|
||||
|
||||
my @tmp = @storeexprs;
|
||||
while (scalar @tmp > 0) {
|
||||
my $n = scalar @tmp;
|
||||
if ($n > 256) { $n = 256 };
|
||||
my @tmp2 = @tmp[0..$n - 1];
|
||||
@tmp = @tmp[$n..scalar @tmp - 1];
|
||||
|
||||
system "@bindir@/nix-store --realise -B @tmp2 > /dev/null";
|
||||
if ($?) { die "`nix-store --realise' failed"; }
|
||||
|
||||
open NARPATHS, "@bindir@/nix-store --query --list @tmp2 |" or die "cannot run nix";
|
||||
while (<NARPATHS>) {
|
||||
chomp;
|
||||
die unless (/^\//);
|
||||
push @narpaths, "$_";
|
||||
}
|
||||
close NARPATHS;
|
||||
}
|
||||
|
||||
|
||||
# Create the manifest.
|
||||
print STDERR "creating manifest...\n";
|
||||
|
||||
open MANIFEST, ">$manifest";
|
||||
|
||||
my @nararchives;
|
||||
for (my $n = 0; $n < scalar @storepaths; $n++) {
|
||||
my $storepath = $storepaths[$n];
|
||||
my $nardir = $narpaths[$n];
|
||||
|
||||
$storepath =~ /\/([^\/]*)$/;
|
||||
my $basename = $1;
|
||||
defined $basename or die;
|
||||
|
||||
my $narname = "$basename.nar.bz2";
|
||||
|
||||
my $narfile = "$nardir/$narname";
|
||||
(-f $narfile) or die "narfile for $storepath not found";
|
||||
push @nararchives, $narfile;
|
||||
|
||||
open MD5, "$nardir/md5" or die "cannot open hash";
|
||||
my $hash = <MD5>;
|
||||
chomp $hash;
|
||||
$hash =~ /^[0-9a-z]{32}$/ or die "invalid hash";
|
||||
close MD5;
|
||||
|
||||
print MANIFEST "{\n";
|
||||
print MANIFEST " StorePath: $storepath\n";
|
||||
print MANIFEST " NarURL: $archives_get_url/$narname\n";
|
||||
print MANIFEST " MD5: $hash\n";
|
||||
|
||||
if ($storepath =~ /\.store$/) {
|
||||
open PREDS, "@bindir@/nix-store --query --predecessors $storepath |" or die "cannot run nix";
|
||||
while (<PREDS>) {
|
||||
chomp;
|
||||
die unless (/^\//);
|
||||
my $pred = $_;
|
||||
# Only include predecessors that are themselves being
|
||||
# pushed.
|
||||
if (defined $storepaths{$pred}) {
|
||||
print MANIFEST " SuccOf: $pred\n";
|
||||
}
|
||||
}
|
||||
$name = $name . ".nar.bz2";
|
||||
close PREDS;
|
||||
}
|
||||
|
||||
# Construct a Fix expression that creates a Nix archive.
|
||||
my $fixexpr =
|
||||
"App(IncludeFix(\"nar/nar.fix\"), " .
|
||||
"[ (\"path\", Slice([\"$pathid\"], [(\"$path\", \"$pathid\", [])]))" .
|
||||
"])";
|
||||
|
||||
my $fixfile = "/tmp/nix-push-tmp.fix";
|
||||
open FIX, ">$fixfile";
|
||||
print FIX $fixexpr;
|
||||
close FIX;
|
||||
print MANIFEST "}\n";
|
||||
}
|
||||
|
||||
# Instantiate a Nix expression from the Fix expression.
|
||||
my $nid = `fix $fixfile`;
|
||||
$? and die "instantiating Nix archive expression";
|
||||
chomp $nid;
|
||||
die unless $nid =~ /^([0-9a-z]{32})$/;
|
||||
close MANIFEST;
|
||||
|
||||
# Realise the Nix expression.
|
||||
system "nix --install $nid";
|
||||
if ($?) { die "`nix --install' failed"; }
|
||||
my $npath = `nix --query --list $nid 2> /dev/null`;
|
||||
$? and die "`nix --query --list' failed";
|
||||
chomp $npath;
|
||||
|
||||
push @pushlist, "$npath/*";
|
||||
# Upload the archives.
|
||||
print STDERR "uploading archives...\n";
|
||||
foreach my $nararchive (@nararchives) {
|
||||
|
||||
print "$path -> $npath\n";
|
||||
$nararchive =~ /\/([^\/]*)$/;
|
||||
my $basename = $1;
|
||||
|
||||
if (system("$curl --head $archives_get_url/$basename > /dev/null") != 0) {
|
||||
print STDERR " $nararchive\n";
|
||||
system("$curl --show-error --upload-file " .
|
||||
"'$nararchive' '$archives_put_url/$basename' > /dev/null") == 0 or
|
||||
die "curl failed on $nararchive: $?";
|
||||
}
|
||||
}
|
||||
|
||||
# Push the prebuilts to the server. !!! FIXME
|
||||
if (scalar @pushlist > 0) {
|
||||
system "rsync -av -e ssh @pushlist eelco\@losser.st-lab.cs.uu.nl:/home/eelco/public_html/nix-dist/";
|
||||
}
|
||||
|
||||
# Upload the manifest.
|
||||
print STDERR "uploading manifest...\n";
|
||||
system("$curl --show-error --upload-file " .
|
||||
"'$manifest' '$manifest_put_url' > /dev/null") == 0 or
|
||||
die "curl failed on $manifest: $?";
|
||||
@@ -1,82 +0,0 @@
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
|
||||
my $keep = 0;
|
||||
my $sourceroot = 0;
|
||||
my $srcid;
|
||||
|
||||
foreach my $arg (@ARGV) {
|
||||
if ($arg eq "--keep") { $keep = 1; }
|
||||
elsif ($arg eq "--source-root") { $sourceroot = 1; }
|
||||
elsif ($arg =~ /^([0-9a-z]{32})$/) { $srcid = $arg; }
|
||||
else { die "unknown argument `$arg'" };
|
||||
}
|
||||
|
||||
my $linkdir = "@localstatedir@/nix/links";
|
||||
|
||||
# Build the specified package, and all its dependencies.
|
||||
my $nfid = `nix --install $srcid`;
|
||||
if ($?) { die "`nix --install' failed"; }
|
||||
chomp $nfid;
|
||||
die unless $nfid =~ /^([0-9a-z]{32})$/;
|
||||
|
||||
my $pkgdir = `nix --query --list $nfid`;
|
||||
if ($?) { die "`nix --query --list' failed"; }
|
||||
chomp $pkgdir;
|
||||
|
||||
# Figure out a generation number.
|
||||
opendir(DIR, $linkdir);
|
||||
my $nr = 0;
|
||||
foreach my $n (sort(readdir(DIR))) {
|
||||
next if (!($n =~ /^\d+$/));
|
||||
$nr = $n + 1 if ($n >= $nr);
|
||||
}
|
||||
closedir(DIR);
|
||||
|
||||
my $link = "$linkdir/$nr";
|
||||
|
||||
# Create a symlink from $link to $pkgdir.
|
||||
symlink($pkgdir, $link) or die "cannot create $link: $!";
|
||||
|
||||
# Store the id of the normal form. This is useful for garbage
|
||||
# collection and the like.
|
||||
my $idfile = "$linkdir/$nr.id";
|
||||
open ID, "> $idfile" or die "cannot create $idfile";
|
||||
print ID "$nfid\n";
|
||||
close ID;
|
||||
|
||||
# Optionally store the source id.
|
||||
if ($sourceroot) {
|
||||
$idfile = "$linkdir/$nr-src.id";
|
||||
open ID, "> $idfile" or die "cannot create $idfile";
|
||||
print ID "$srcid\n";
|
||||
close ID;
|
||||
}
|
||||
|
||||
my $current = "$linkdir/current";
|
||||
|
||||
# Read the current generation so that we can delete it (if --keep
|
||||
# wasn't specified).
|
||||
my $oldlink = readlink($current);
|
||||
|
||||
# Make $link the current generation by pointing $linkdir/current to
|
||||
# it. The rename() system call is supposed to be essentially atomic
|
||||
# on Unix. That is, if we have links `current -> X' and `new_current
|
||||
# -> Y', and we rename new_current to current, a process accessing
|
||||
# current will see X or Y, but never a file-not-found or other error
|
||||
# condition. This is sufficient to atomically switch the current link
|
||||
# tree.
|
||||
|
||||
print "switching $current to $link\n";
|
||||
|
||||
my $tmplink = "$linkdir/new_current";
|
||||
symlink($link, $tmplink) or die "cannot create $tmplink";
|
||||
rename($tmplink, $current) or die "cannot rename $tmplink";
|
||||
|
||||
if (!$keep && defined $oldlink) {
|
||||
print "deleting old $oldlink\n";
|
||||
unlink($oldlink) == 1 or print "cannot delete $oldlink\n";
|
||||
unlink("$oldlink.id") == 1 or print "cannot delete $oldlink.id\n";
|
||||
unlink("$oldlink-src.id");
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
# A list of URLs from where we obtain Nix archives.
|
||||
http://losser.st-lab.cs.uu.nl/~eelco/nix-dist/
|
||||
# A list of URLs from where `nix-pull' obtain Nix archives if
|
||||
# no URL is specified on the command line.
|
||||
@@ -0,0 +1,72 @@
|
||||
use strict;
|
||||
|
||||
sub processURL {
|
||||
my $manifest = shift;
|
||||
my $url = shift;
|
||||
my $storePaths2urls = shift;
|
||||
my $urls2hashes = shift;
|
||||
my $successors = shift;
|
||||
|
||||
$url =~ s/\/$//;
|
||||
print "obtaining list of Nix archives at $url...\n";
|
||||
|
||||
system("@curl@ --fail --silent --show-error --location --max-redirs 20 " .
|
||||
"'$url' > '$manifest' 2> /dev/null") == 0
|
||||
or die "curl failed: $?";
|
||||
|
||||
open MANIFEST, "<$manifest";
|
||||
|
||||
my $inside = 0;
|
||||
|
||||
my $storePath;
|
||||
my $narurl;
|
||||
my $hash;
|
||||
my @preds;
|
||||
|
||||
while (<MANIFEST>) {
|
||||
chomp;
|
||||
s/\#.*$//g;
|
||||
next if (/^$/);
|
||||
|
||||
if (!$inside) {
|
||||
if (/^\{$/) {
|
||||
$inside = 1;
|
||||
undef $storePath;
|
||||
undef $narurl;
|
||||
undef $hash;
|
||||
@preds = ();
|
||||
}
|
||||
else { die "bad line: $_"; }
|
||||
} else {
|
||||
if (/^\}$/) {
|
||||
$inside = 0;
|
||||
|
||||
$$storePaths2urls{$storePath} = $narurl;
|
||||
$$urls2hashes{$narurl} = $hash;
|
||||
|
||||
foreach my $p (@preds) {
|
||||
$$successors{$p} = $storePath;
|
||||
}
|
||||
|
||||
}
|
||||
elsif (/^\s*StorePath:\s*(\/\S+)\s*$/) {
|
||||
$storePath = $1;
|
||||
}
|
||||
elsif (/^\s*NarURL:\s*(\S+)\s*$/) {
|
||||
$narurl = $1;
|
||||
}
|
||||
elsif (/^\s*MD5:\s*(\S+)\s*$/) {
|
||||
$hash = $1;
|
||||
}
|
||||
elsif (/^\s*SuccOf:\s*(\/\S+)\s*$/) {
|
||||
push @preds, $1;
|
||||
}
|
||||
else { die "bad line: $_"; }
|
||||
}
|
||||
}
|
||||
|
||||
close MANIFEST;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
+2
-51
@@ -1,51 +1,2 @@
|
||||
bin_PROGRAMS = nix nix-hash fix
|
||||
check_PROGRAMS = test
|
||||
|
||||
AM_CXXFLAGS = -DSYSTEM=\"@host@\" -Wall -I.. -I../externals/inst/include $(CXXFLAGS)
|
||||
AM_LDFLAGS = -L../externals/inst/lib -ldb_cxx -lATerm $(LDFLAGS)
|
||||
|
||||
nix_SOURCES = nix.cc
|
||||
nix_LDADD = libshared.a libnix.a -ldb_cxx -lATerm
|
||||
|
||||
nix_hash_SOURCES = nix-hash.cc
|
||||
nix_hash_LDADD = libshared.a libnix.a -ldb_cxx -lATerm
|
||||
|
||||
fix_SOURCES = fix.cc
|
||||
fix_LDADD = libshared.a libnix.a -ldb_cxx -lATerm
|
||||
|
||||
TESTS = test
|
||||
|
||||
test_SOURCES = test.cc
|
||||
test_LDADD = libshared.a libnix.a -ldb_cxx -lATerm
|
||||
|
||||
noinst_LIBRARIES = libnix.a libshared.a
|
||||
|
||||
libnix_a_SOURCES = util.cc hash.cc archive.cc md5.c \
|
||||
store.cc fstate.cc normalise.cc exec.cc \
|
||||
globals.cc db.cc references.cc
|
||||
|
||||
libshared_a_SOURCES = shared.cc
|
||||
|
||||
libshared_a_CXXFLAGS = \
|
||||
-DNIX_STORE_DIR=\"$(prefix)/store\" \
|
||||
-DNIX_DATA_DIR=\"$(datadir)\" \
|
||||
-DNIX_STATE_DIR=\"$(localstatedir)/nix\" \
|
||||
-DNIX_LOG_DIR=\"$(localstatedir)/log/nix\" \
|
||||
$(AM_CXXFLAGS)
|
||||
|
||||
nix.o: nix-help.txt.hh
|
||||
|
||||
%.hh: %
|
||||
echo -n '"' > $@
|
||||
sed 's|\(.*\)|\1\\n\\|' < $< >> $@
|
||||
echo '"' >> $@
|
||||
|
||||
install-data-local:
|
||||
$(INSTALL) -d $(localstatedir)/nix
|
||||
$(INSTALL) -d $(localstatedir)/nix/links
|
||||
ln -sf $(localstatedir)/nix/links/current $(prefix)/current
|
||||
$(INSTALL) -d $(localstatedir)/log/nix
|
||||
$(INSTALL) -d $(prefix)/store
|
||||
$(bindir)/nix --init
|
||||
|
||||
EXTRA_DIST = *.hh *.h
|
||||
SUBDIRS = bin2c boost libutil libstore libmain nix-store nix-hash \
|
||||
libexpr nix-instantiate nix-env log2xml
|
||||
@@ -0,0 +1,3 @@
|
||||
noinst_PROGRAMS = bin2c
|
||||
|
||||
bin2c_SOURCES = bin2c.c
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void print(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
if (vprintf(format, ap) < 0) abort();
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
int c;
|
||||
if (argc != 2) abort();
|
||||
print("static unsigned char %s[] = {", argv[1]);
|
||||
while ((c = getchar()) != EOF) {
|
||||
print("0x%02x, ", (unsigned char) c);
|
||||
}
|
||||
print("};\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
SUBDIRS = format
|
||||
|
||||
EXTRA_DIST = assert.hpp checked_delete.hpp format.hpp \
|
||||
shared_ptr.hpp weak_ptr.hpp throw_exception.hpp \
|
||||
enable_shared_from_this.hpp \
|
||||
detail/shared_count.hpp detail/workaround.hpp
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// boost/assert.hpp - BOOST_ASSERT(expr)
|
||||
//
|
||||
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
// Note: There are no include guards. This is intentional.
|
||||
//
|
||||
// See http://www.boost.org/libs/utility/assert.html for documentation.
|
||||
//
|
||||
|
||||
#undef BOOST_ASSERT
|
||||
|
||||
#if defined(BOOST_DISABLE_ASSERTS)
|
||||
|
||||
# define BOOST_ASSERT(expr) ((void)0)
|
||||
|
||||
#elif defined(BOOST_ENABLE_ASSERT_HANDLER)
|
||||
|
||||
#include <boost/current_function.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_ASSERT(expr) ((expr)? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
|
||||
#else
|
||||
# include <assert.h>
|
||||
# define BOOST_ASSERT(expr) assert(expr)
|
||||
#endif
|
||||
@@ -0,0 +1,71 @@
|
||||
#ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
|
||||
#define BOOST_CHECKED_DELETE_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// boost/checked_delete.hpp
|
||||
//
|
||||
// Copyright (c) 1999, 2000, 2001, 2002 boost.org
|
||||
// Copyright (c) 2002, 2003 Peter Dimov
|
||||
// Copyright (c) 2003 Daniel Frey
|
||||
// Copyright (c) 2003 Howard Hinnant
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org/libs/utility/checked_delete.html for documentation.
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
// verify that types are complete for increased safety
|
||||
|
||||
template<class T> inline void checked_delete(T * x)
|
||||
{
|
||||
// intentionally complex - simplification causes regressions
|
||||
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
|
||||
(void) sizeof(type_must_be_complete);
|
||||
delete x;
|
||||
}
|
||||
|
||||
template<class T> inline void checked_array_delete(T * x)
|
||||
{
|
||||
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
|
||||
(void) sizeof(type_must_be_complete);
|
||||
delete [] x;
|
||||
}
|
||||
|
||||
template<class T> struct checked_deleter
|
||||
{
|
||||
typedef void result_type;
|
||||
typedef T * argument_type;
|
||||
|
||||
void operator()(T * x) const
|
||||
{
|
||||
// boost:: disables ADL
|
||||
boost::checked_delete(x);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T> struct checked_array_deleter
|
||||
{
|
||||
typedef void result_type;
|
||||
typedef T * argument_type;
|
||||
|
||||
void operator()(T * x) const
|
||||
{
|
||||
boost::checked_array_delete(x);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
|
||||
@@ -0,0 +1,555 @@
|
||||
#ifndef BOOST_DETAIL_SHARED_COUNT_HPP_INCLUDED
|
||||
#define BOOST_DETAIL_SHARED_COUNT_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// detail/shared_count.hpp
|
||||
//
|
||||
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
||||
//#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_SP_USE_STD_ALLOCATOR) && defined(BOOST_SP_USE_QUICK_ALLOCATOR)
|
||||
# error BOOST_SP_USE_STD_ALLOCATOR and BOOST_SP_USE_QUICK_ALLOCATOR are incompatible.
|
||||
#endif
|
||||
|
||||
#include <boost/checked_delete.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
//#include <boost/detail/lightweight_mutex.hpp>
|
||||
|
||||
#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
|
||||
#include <boost/detail/quick_allocator.hpp>
|
||||
#endif
|
||||
|
||||
#include <memory> // std::auto_ptr, std::allocator
|
||||
#include <functional> // std::less
|
||||
#include <exception> // std::exception
|
||||
#include <new> // std::bad_alloc
|
||||
#include <typeinfo> // std::type_info in get_deleter
|
||||
#include <cstddef> // std::size_t
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# pragma warn -8026 // Functions with excep. spec. are not expanded inline
|
||||
# pragma warn -8027 // Functions containing try are not expanded inline
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
// Debug hooks
|
||||
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
|
||||
void sp_scalar_constructor_hook(void * px, std::size_t size, void * pn);
|
||||
void sp_array_constructor_hook(void * px);
|
||||
void sp_scalar_destructor_hook(void * px, std::size_t size, void * pn);
|
||||
void sp_array_destructor_hook(void * px);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// The standard library that comes with Borland C++ 5.5.1
|
||||
// defines std::exception and its members as having C calling
|
||||
// convention (-pc). When the definition of bad_weak_ptr
|
||||
// is compiled with -ps, the compiler issues an error.
|
||||
// Hence, the temporary #pragma option -pc below. The version
|
||||
// check is deliberately conservative.
|
||||
|
||||
#if defined(__BORLANDC__) && __BORLANDC__ == 0x551
|
||||
# pragma option push -pc
|
||||
#endif
|
||||
|
||||
class bad_weak_ptr: public std::exception
|
||||
{
|
||||
public:
|
||||
|
||||
virtual char const * what() const throw()
|
||||
{
|
||||
return "boost::bad_weak_ptr";
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(__BORLANDC__) && __BORLANDC__ == 0x551
|
||||
# pragma option pop
|
||||
#endif
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
// typedef detail::lightweight_mutex mutex_type;
|
||||
|
||||
public:
|
||||
|
||||
sp_counted_base(): use_count_(1), weak_count_(1)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~sp_counted_base() // nothrow
|
||||
{
|
||||
}
|
||||
|
||||
// dispose() is called when use_count_ drops to zero, to release
|
||||
// the resources managed by *this.
|
||||
|
||||
virtual void dispose() = 0; // nothrow
|
||||
|
||||
// destruct() is called when weak_count_ drops to zero.
|
||||
|
||||
virtual void destruct() // nothrow
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
virtual void * get_deleter(std::type_info const & ti) = 0;
|
||||
|
||||
void add_ref_copy()
|
||||
{
|
||||
#if defined(BOOST_HAS_THREADS)
|
||||
mutex_type::scoped_lock lock(mtx_);
|
||||
#endif
|
||||
++use_count_;
|
||||
}
|
||||
|
||||
void add_ref_lock()
|
||||
{
|
||||
#if defined(BOOST_HAS_THREADS)
|
||||
mutex_type::scoped_lock lock(mtx_);
|
||||
#endif
|
||||
if(use_count_ == 0) boost::throw_exception(boost::bad_weak_ptr());
|
||||
++use_count_;
|
||||
}
|
||||
|
||||
void release() // nothrow
|
||||
{
|
||||
{
|
||||
#if defined(BOOST_HAS_THREADS)
|
||||
mutex_type::scoped_lock lock(mtx_);
|
||||
#endif
|
||||
long new_use_count = --use_count_;
|
||||
|
||||
if(new_use_count != 0) return;
|
||||
}
|
||||
|
||||
dispose();
|
||||
weak_release();
|
||||
}
|
||||
|
||||
void weak_add_ref() // nothrow
|
||||
{
|
||||
#if defined(BOOST_HAS_THREADS)
|
||||
mutex_type::scoped_lock lock(mtx_);
|
||||
#endif
|
||||
++weak_count_;
|
||||
}
|
||||
|
||||
void weak_release() // nothrow
|
||||
{
|
||||
long new_weak_count;
|
||||
|
||||
{
|
||||
#if defined(BOOST_HAS_THREADS)
|
||||
mutex_type::scoped_lock lock(mtx_);
|
||||
#endif
|
||||
new_weak_count = --weak_count_;
|
||||
}
|
||||
|
||||
if(new_weak_count == 0)
|
||||
{
|
||||
destruct();
|
||||
}
|
||||
}
|
||||
|
||||
long use_count() const // nothrow
|
||||
{
|
||||
#if defined(BOOST_HAS_THREADS)
|
||||
mutex_type::scoped_lock lock(mtx_);
|
||||
#endif
|
||||
return use_count_;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
sp_counted_base(sp_counted_base const &);
|
||||
sp_counted_base & operator= (sp_counted_base const &);
|
||||
|
||||
long use_count_; // #shared
|
||||
long weak_count_; // #weak + (#shared != 0)
|
||||
|
||||
#if defined(BOOST_HAS_THREADS) || defined(BOOST_LWM_WIN32)
|
||||
mutable mutex_type mtx_;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
|
||||
template<class T> void cbi_call_constructor_hook(sp_counted_base * pn, T * px, checked_deleter<T> const &, int)
|
||||
{
|
||||
boost::sp_scalar_constructor_hook(px, sizeof(T), pn);
|
||||
}
|
||||
|
||||
template<class T> void cbi_call_constructor_hook(sp_counted_base *, T * px, checked_array_deleter<T> const &, int)
|
||||
{
|
||||
boost::sp_array_constructor_hook(px);
|
||||
}
|
||||
|
||||
template<class P, class D> void cbi_call_constructor_hook(sp_counted_base *, P const &, D const &, long)
|
||||
{
|
||||
}
|
||||
|
||||
template<class T> void cbi_call_destructor_hook(sp_counted_base * pn, T * px, checked_deleter<T> const &, int)
|
||||
{
|
||||
boost::sp_scalar_destructor_hook(px, sizeof(T), pn);
|
||||
}
|
||||
|
||||
template<class T> void cbi_call_destructor_hook(sp_counted_base *, T * px, checked_array_deleter<T> const &, int)
|
||||
{
|
||||
boost::sp_array_destructor_hook(px);
|
||||
}
|
||||
|
||||
template<class P, class D> void cbi_call_destructor_hook(sp_counted_base *, P const &, D const &, long)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Borland's Codeguard trips up over the -Vx- option here:
|
||||
//
|
||||
#ifdef __CODEGUARD__
|
||||
# pragma option push -Vx-
|
||||
#endif
|
||||
|
||||
template<class P, class D> class sp_counted_base_impl: public sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
P ptr; // copy constructor must not throw
|
||||
D del; // copy constructor must not throw
|
||||
|
||||
sp_counted_base_impl(sp_counted_base_impl const &);
|
||||
sp_counted_base_impl & operator= (sp_counted_base_impl const &);
|
||||
|
||||
typedef sp_counted_base_impl<P, D> this_type;
|
||||
|
||||
public:
|
||||
|
||||
// pre: initial_use_count <= initial_weak_count, d(p) must not throw
|
||||
|
||||
sp_counted_base_impl(P p, D d): ptr(p), del(d)
|
||||
{
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
detail::cbi_call_constructor_hook(this, p, d, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void dispose() // nothrow
|
||||
{
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
detail::cbi_call_destructor_hook(this, ptr, del, 0);
|
||||
#endif
|
||||
del(ptr);
|
||||
}
|
||||
|
||||
virtual void * get_deleter(std::type_info const & ti)
|
||||
{
|
||||
return ti == typeid(D)? &del: 0;
|
||||
}
|
||||
|
||||
#if defined(BOOST_SP_USE_STD_ALLOCATOR)
|
||||
|
||||
void * operator new(std::size_t)
|
||||
{
|
||||
return std::allocator<this_type>().allocate(1, static_cast<this_type *>(0));
|
||||
}
|
||||
|
||||
void operator delete(void * p)
|
||||
{
|
||||
std::allocator<this_type>().deallocate(static_cast<this_type *>(p), 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
|
||||
|
||||
void * operator new(std::size_t)
|
||||
{
|
||||
return quick_allocator<this_type>::alloc();
|
||||
}
|
||||
|
||||
void operator delete(void * p)
|
||||
{
|
||||
quick_allocator<this_type>::dealloc(p);
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
|
||||
int const shared_count_id = 0x2C35F101;
|
||||
int const weak_count_id = 0x298C38A4;
|
||||
|
||||
#endif
|
||||
|
||||
class weak_count;
|
||||
|
||||
class shared_count
|
||||
{
|
||||
private:
|
||||
|
||||
sp_counted_base * pi_;
|
||||
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
int id_;
|
||||
#endif
|
||||
|
||||
friend class weak_count;
|
||||
|
||||
public:
|
||||
|
||||
shared_count(): pi_(0) // nothrow
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
template<class P, class D> shared_count(P p, D d): pi_(0)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
|
||||
try
|
||||
{
|
||||
pi_ = new sp_counted_base_impl<P, D>(p, d);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
d(p); // delete p
|
||||
throw;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
pi_ = new sp_counted_base_impl<P, D>(p, d);
|
||||
|
||||
if(pi_ == 0)
|
||||
{
|
||||
d(p); // delete p
|
||||
boost::throw_exception(std::bad_alloc());
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
|
||||
// auto_ptr<Y> is special cased to provide the strong guarantee
|
||||
|
||||
template<class Y>
|
||||
explicit shared_count(std::auto_ptr<Y> & r): pi_(new sp_counted_base_impl< Y *, checked_deleter<Y> >(r.get(), checked_deleter<Y>()))
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
r.release();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
~shared_count() // nothrow
|
||||
{
|
||||
if(pi_ != 0) pi_->release();
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
id_ = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
shared_count(shared_count const & r): pi_(r.pi_) // nothrow
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
if(pi_ != 0) pi_->add_ref_copy();
|
||||
}
|
||||
|
||||
explicit shared_count(weak_count const & r); // throws bad_weak_ptr when r.use_count() == 0
|
||||
|
||||
shared_count & operator= (shared_count const & r) // nothrow
|
||||
{
|
||||
sp_counted_base * tmp = r.pi_;
|
||||
if(tmp != 0) tmp->add_ref_copy();
|
||||
if(pi_ != 0) pi_->release();
|
||||
pi_ = tmp;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(shared_count & r) // nothrow
|
||||
{
|
||||
sp_counted_base * tmp = r.pi_;
|
||||
r.pi_ = pi_;
|
||||
pi_ = tmp;
|
||||
}
|
||||
|
||||
long use_count() const // nothrow
|
||||
{
|
||||
return pi_ != 0? pi_->use_count(): 0;
|
||||
}
|
||||
|
||||
bool unique() const // nothrow
|
||||
{
|
||||
return use_count() == 1;
|
||||
}
|
||||
|
||||
friend inline bool operator==(shared_count const & a, shared_count const & b)
|
||||
{
|
||||
return a.pi_ == b.pi_;
|
||||
}
|
||||
|
||||
friend inline bool operator<(shared_count const & a, shared_count const & b)
|
||||
{
|
||||
return std::less<sp_counted_base *>()(a.pi_, b.pi_);
|
||||
}
|
||||
|
||||
void * get_deleter(std::type_info const & ti) const
|
||||
{
|
||||
return pi_? pi_->get_deleter(ti): 0;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __CODEGUARD__
|
||||
# pragma option pop
|
||||
#endif
|
||||
|
||||
|
||||
class weak_count
|
||||
{
|
||||
private:
|
||||
|
||||
sp_counted_base * pi_;
|
||||
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
int id_;
|
||||
#endif
|
||||
|
||||
friend class shared_count;
|
||||
|
||||
public:
|
||||
|
||||
weak_count(): pi_(0) // nothrow
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(weak_count_id)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
weak_count(shared_count const & r): pi_(r.pi_) // nothrow
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
if(pi_ != 0) pi_->weak_add_ref();
|
||||
}
|
||||
|
||||
weak_count(weak_count const & r): pi_(r.pi_) // nothrow
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
if(pi_ != 0) pi_->weak_add_ref();
|
||||
}
|
||||
|
||||
~weak_count() // nothrow
|
||||
{
|
||||
if(pi_ != 0) pi_->weak_release();
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
id_ = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
weak_count & operator= (shared_count const & r) // nothrow
|
||||
{
|
||||
sp_counted_base * tmp = r.pi_;
|
||||
if(tmp != 0) tmp->weak_add_ref();
|
||||
if(pi_ != 0) pi_->weak_release();
|
||||
pi_ = tmp;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
weak_count & operator= (weak_count const & r) // nothrow
|
||||
{
|
||||
sp_counted_base * tmp = r.pi_;
|
||||
if(tmp != 0) tmp->weak_add_ref();
|
||||
if(pi_ != 0) pi_->weak_release();
|
||||
pi_ = tmp;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(weak_count & r) // nothrow
|
||||
{
|
||||
sp_counted_base * tmp = r.pi_;
|
||||
r.pi_ = pi_;
|
||||
pi_ = tmp;
|
||||
}
|
||||
|
||||
long use_count() const // nothrow
|
||||
{
|
||||
return pi_ != 0? pi_->use_count(): 0;
|
||||
}
|
||||
|
||||
friend inline bool operator==(weak_count const & a, weak_count const & b)
|
||||
{
|
||||
return a.pi_ == b.pi_;
|
||||
}
|
||||
|
||||
friend inline bool operator<(weak_count const & a, weak_count const & b)
|
||||
{
|
||||
return std::less<sp_counted_base *>()(a.pi_, b.pi_);
|
||||
}
|
||||
};
|
||||
|
||||
inline shared_count::shared_count(weak_count const & r): pi_(r.pi_)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
if(pi_ != 0)
|
||||
{
|
||||
pi_->add_ref_lock();
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::throw_exception(boost::bad_weak_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# pragma warn .8027 // Functions containing try are not expanded inline
|
||||
# pragma warn .8026 // Functions with excep. spec. are not expanded inline
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_DETAIL_SHARED_COUNT_HPP_INCLUDED
|
||||
@@ -0,0 +1,74 @@
|
||||
// Copyright David Abrahams 2002. Permission to copy, use,
|
||||
// modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
#ifndef WORKAROUND_DWA2002126_HPP
|
||||
# define WORKAROUND_DWA2002126_HPP
|
||||
|
||||
// Compiler/library version workaround macro
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// #if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
|
||||
// ... // workaround code here
|
||||
// #endif
|
||||
//
|
||||
// When BOOST_STRICT_CONFIG is defined, expands to 0. Otherwise, the
|
||||
// first argument must be undefined or expand to a numeric
|
||||
// value. The above expands to:
|
||||
//
|
||||
// (BOOST_MSVC) != 0 && (BOOST_MSVC) <= 1200
|
||||
//
|
||||
// When used for workarounds that apply to the latest known version
|
||||
// and all earlier versions of a compiler, the following convention
|
||||
// should be observed:
|
||||
//
|
||||
// #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1301))
|
||||
//
|
||||
// The version number in this case corresponds to the last version in
|
||||
// which the workaround was known to have been required. When
|
||||
// BOOST_DETECT_OUTDATED_WORKAROUNDS is not the defined, the macro
|
||||
// BOOST_TESTED_AT(x) expands to "!= 0", which effectively activates
|
||||
// the workaround for any version of the compiler. When
|
||||
// BOOST_DETECT_OUTDATED_WORKAROUNDS is defined, a compiler warning or
|
||||
// error will be issued if the compiler version exceeds the argument
|
||||
// to BOOST_TESTED_AT(). This can be used to locate workarounds which
|
||||
// may be obsoleted by newer versions.
|
||||
|
||||
# ifndef BOOST_STRICT_CONFIG
|
||||
|
||||
# define BOOST_WORKAROUND(symbol, test) \
|
||||
((symbol != 0) && (1 % (( (symbol test) ) + 1)))
|
||||
// ^ ^ ^ ^
|
||||
// The extra level of parenthesis nesting above, along with the
|
||||
// BOOST_OPEN_PAREN indirection below, is required to satisfy the
|
||||
// broken preprocessor in MWCW 8.3 and earlier.
|
||||
//
|
||||
// The basic mechanism works as follows:
|
||||
// (symbol test) + 1 => if (symbol test) then 2 else 1
|
||||
// 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0
|
||||
//
|
||||
// The complication with % is for cooperation with BOOST_TESTED_AT().
|
||||
// When "test" is BOOST_TESTED_AT(x) and
|
||||
// BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined,
|
||||
//
|
||||
// symbol test => if (symbol <= x) then 1 else -1
|
||||
// (symbol test) + 1 => if (symbol <= x) then 2 else 0
|
||||
// 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero
|
||||
//
|
||||
|
||||
# ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
|
||||
# define BOOST_OPEN_PAREN (
|
||||
# define BOOST_TESTED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1
|
||||
# else
|
||||
# define BOOST_TESTED_AT(value) != ((value)-(value))
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
# define BOOST_WORKAROUND(symbol, test) 0
|
||||
|
||||
# endif
|
||||
|
||||
#endif // WORKAROUND_DWA2002126_HPP
|
||||
@@ -0,0 +1,68 @@
|
||||
#ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
|
||||
#define BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
|
||||
|
||||
//
|
||||
// enable_shared_from_this.hpp
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
// http://www.boost.org/libs/smart_ptr/enable_shared_from_this.html
|
||||
//
|
||||
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
//#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class T> class enable_shared_from_this
|
||||
{
|
||||
protected:
|
||||
|
||||
enable_shared_from_this()
|
||||
{
|
||||
}
|
||||
|
||||
enable_shared_from_this(enable_shared_from_this const &)
|
||||
{
|
||||
}
|
||||
|
||||
enable_shared_from_this & operator=(enable_shared_from_this const &)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
~enable_shared_from_this()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
shared_ptr<T> shared_from_this()
|
||||
{
|
||||
shared_ptr<T> p(_internal_weak_this);
|
||||
BOOST_ASSERT(p.get() == this);
|
||||
return p;
|
||||
}
|
||||
|
||||
shared_ptr<T const> shared_from_this() const
|
||||
{
|
||||
shared_ptr<T const> p(_internal_weak_this);
|
||||
BOOST_ASSERT(p.get() == this);
|
||||
return p;
|
||||
}
|
||||
|
||||
typedef T _internal_element_type; // for bcc 5.5.1
|
||||
weak_ptr<_internal_element_type> _internal_weak_this;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
|
||||
@@ -24,20 +24,16 @@
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
#if HAVE_LOCALE
|
||||
#include <locale>
|
||||
#else
|
||||
#define BOOST_NO_STD_LOCALE
|
||||
#define BOOST_NO_LOCALE_ISIDIGIT
|
||||
#include <cctype>
|
||||
#endif
|
||||
|
||||
#include <boost/format/macros_default.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template<class E> void throw_exception(E const & e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
#define BOOST_ASSERT(expr) assert(expr)
|
||||
|
||||
|
||||
// **** Forward declarations ----------------------------------
|
||||
#include <boost/format/format_fwd.hpp> // basic_format<Ch,Tr>, and other frontends
|
||||
@@ -54,15 +50,15 @@ namespace boost
|
||||
#include <boost/format/exceptions.hpp>
|
||||
|
||||
// **** Implementation -------------------------------------------
|
||||
#include <boost/format/format_implementation.hpp> // member functions
|
||||
//#include <boost/format/format_implementation.hpp> // member functions
|
||||
|
||||
#include <boost/format/group.hpp> // class for grouping arguments
|
||||
|
||||
#include <boost/format/feed_args.hpp> // argument-feeding functions
|
||||
#include <boost/format/parsing.hpp> // format-string parsing (member-)functions
|
||||
//#include <boost/format/parsing.hpp> // format-string parsing (member-)functions
|
||||
|
||||
// **** Implementation of the free functions ----------------------
|
||||
#include <boost/format/free_funcs.hpp>
|
||||
//#include <boost/format/free_funcs.hpp>
|
||||
|
||||
|
||||
#endif // BOOST_FORMAT_HPP
|
||||
@@ -0,0 +1,8 @@
|
||||
noinst_LIBRARIES = libformat.a
|
||||
|
||||
libformat_a_SOURCES = format_implementation.cc free_funcs.cc \
|
||||
parsing.cc exceptions.hpp feed_args.hpp format_class.hpp \
|
||||
format_fwd.hpp group.hpp internals.hpp internals_fwd.hpp \
|
||||
macros_default.hpp
|
||||
|
||||
AM_CXXFLAGS = -Wall -I../..
|
||||
File renamed without changes.
@@ -24,24 +24,23 @@
|
||||
#include "boost/format/format_class.hpp"
|
||||
#include "boost/format/group.hpp"
|
||||
|
||||
//#include "boost/throw_exception.hpp"
|
||||
#include "boost/throw_exception.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace io {
|
||||
namespace detail {
|
||||
namespace {
|
||||
|
||||
template<class Tr, class Ch> inline
|
||||
void empty_buf(BOOST_IO_STD basic_ostringstream<Ch,Tr> & os) {
|
||||
static const std::basic_string<Ch, Tr> emptyStr;
|
||||
inline
|
||||
void empty_buf(BOOST_IO_STD ostringstream & os) {
|
||||
static const std::string emptyStr;
|
||||
os.str(emptyStr);
|
||||
}
|
||||
|
||||
template<class Ch, class Tr>
|
||||
void do_pad( std::basic_string<Ch,Tr> & s,
|
||||
void do_pad( std::string & s,
|
||||
std::streamsize w,
|
||||
const Ch c,
|
||||
std::ios_base::fmtflags f,
|
||||
const char c,
|
||||
std::ios::fmtflags f,
|
||||
bool center)
|
||||
// applies centered / left / right padding to the string s.
|
||||
// Effects : string s is padded.
|
||||
@@ -59,7 +58,7 @@ namespace {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(f & std::ios_base::left) {
|
||||
if(f & std::ios::left) {
|
||||
s.append(n, c);
|
||||
}
|
||||
else {
|
||||
@@ -69,32 +68,32 @@ namespace {
|
||||
} // -do_pad(..)
|
||||
|
||||
|
||||
template< class Ch, class Tr, class T> inline
|
||||
void put_head(BOOST_IO_STD basic_ostream<Ch, Tr>& , const T& ) {
|
||||
template<class T> inline
|
||||
void put_head(BOOST_IO_STD ostream& , const T& ) {
|
||||
}
|
||||
|
||||
template< class Ch, class Tr, class T> inline
|
||||
void put_head( BOOST_IO_STD basic_ostream<Ch, Tr>& os, const group1<T>& x ) {
|
||||
template<class T> inline
|
||||
void put_head( BOOST_IO_STD ostream& os, const group1<T>& x ) {
|
||||
os << group_head(x.a1_); // send the first N-1 items, not the last
|
||||
}
|
||||
|
||||
template< class Ch, class Tr, class T> inline
|
||||
void put_last( BOOST_IO_STD basic_ostream<Ch, Tr>& os, const T& x ) {
|
||||
template<class T> inline
|
||||
void put_last( BOOST_IO_STD ostream& os, const T& x ) {
|
||||
os << x ;
|
||||
}
|
||||
|
||||
template< class Ch, class Tr, class T> inline
|
||||
void put_last( BOOST_IO_STD basic_ostream<Ch, Tr>& os, const group1<T>& x ) {
|
||||
template<class T> inline
|
||||
void put_last( BOOST_IO_STD ostream& os, const group1<T>& x ) {
|
||||
os << group_last(x.a1_); // this selects the last element
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST
|
||||
template< class Ch, class Tr, class T> inline
|
||||
void put_head( BOOST_IO_STD basic_ostream<Ch, Tr>& , T& ) {
|
||||
template<class T> inline
|
||||
void put_head( BOOST_IO_STD ostream& , T& ) {
|
||||
}
|
||||
|
||||
template< class Ch, class Tr, class T> inline
|
||||
void put_last( BOOST_IO_STD basic_ostream<Ch, Tr>& os, T& x ) {
|
||||
template<class T> inline
|
||||
void put_last( BOOST_IO_STD ostream& os, T& x ) {
|
||||
os << x ;
|
||||
}
|
||||
#endif
|
||||
@@ -102,19 +101,19 @@ namespace {
|
||||
|
||||
|
||||
|
||||
template< class Ch, class Tr, class T>
|
||||
template<class T>
|
||||
void put( T x,
|
||||
const format_item<Ch, Tr>& specs,
|
||||
std::basic_string<Ch, Tr> & res,
|
||||
BOOST_IO_STD basic_ostringstream<Ch, Tr>& oss_ )
|
||||
const format_item& specs,
|
||||
std::string & res,
|
||||
BOOST_IO_STD ostringstream& oss_ )
|
||||
{
|
||||
// does the actual conversion of x, with given params, into a string
|
||||
// using the *supplied* strinstream. (the stream state is important)
|
||||
|
||||
typedef std::basic_string<Ch, Tr> string_t;
|
||||
typedef format_item<Ch, Tr> format_item_t;
|
||||
typedef std::string string_t;
|
||||
typedef format_item format_item_t;
|
||||
|
||||
stream_format_state<Ch, Tr> prev_state(oss_);
|
||||
stream_format_state prev_state(oss_);
|
||||
|
||||
specs.state_.apply_on(oss_);
|
||||
|
||||
@@ -124,8 +123,8 @@ void put( T x,
|
||||
empty_buf( oss_);
|
||||
|
||||
const std::streamsize w=oss_.width();
|
||||
const std::ios_base::fmtflags fl=oss_.flags();
|
||||
const bool internal = (fl & std::ios_base::internal) != 0;
|
||||
const std::ios::fmtflags fl=oss_.flags();
|
||||
const bool internal = (fl & std::ios::internal) != 0;
|
||||
const bool two_stepped_padding = internal
|
||||
&& ! ( specs.pad_scheme_ & format_item_t::spacepad )
|
||||
&& specs.truncate_ < 0 ;
|
||||
@@ -203,8 +202,8 @@ void put( T x,
|
||||
|
||||
|
||||
|
||||
template< class Ch, class Tr, class T>
|
||||
void distribute(basic_format<Ch,Tr>& self, T x)
|
||||
template<class T>
|
||||
void distribute(basic_format& self, T x)
|
||||
// call put(x, ..) on every occurence of the current argument :
|
||||
{
|
||||
if(self.cur_arg_ >= self.num_args_)
|
||||
@@ -217,16 +216,16 @@ void distribute(basic_format<Ch,Tr>& self, T x)
|
||||
{
|
||||
if(self.items_[i].argN_ == self.cur_arg_)
|
||||
{
|
||||
put<Ch, Tr, T> (x, self.items_[i], self.items_[i].res_, self.oss_ );
|
||||
put<T> (x, self.items_[i], self.items_[i].res_, self.oss_ );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Ch, class Tr, class T>
|
||||
basic_format<Ch, Tr>& feed(basic_format<Ch,Tr>& self, T x)
|
||||
template<class T>
|
||||
basic_format& feed(basic_format& self, T x)
|
||||
{
|
||||
if(self.dumped_) self.clear();
|
||||
distribute<Ch, Tr, T> (self, x);
|
||||
distribute<T> (self, x);
|
||||
++self.cur_arg_;
|
||||
if(self.bound_.size() != 0)
|
||||
{
|
||||
Loaded 100 of 242 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user