* nix-build: default to `./default.nix' if no paths are specified.
So when using Nix as a build tool, you can just say `nix-build' and it will build the top-level derivation defined in `default.nix'.
This commit is contained in:
parent
d4879b4dfe
commit
a5ceb5bc0b
|
@ -25,6 +25,10 @@ to multiple derivations, multiple sequentially numbered symlinks are
|
|||
created (<filename>result</filename>, <filename>result-2</filename>,
|
||||
and so on).</para>
|
||||
|
||||
<para>If no <replaceable>paths</replaceable> are specified, then
|
||||
<command>nix-build</command> will use <filename>default.nix</filename>
|
||||
in the current directory, if it exists.</para>
|
||||
|
||||
<note><para><command>nix-build</command> is essentially a wrapper
|
||||
around <link
|
||||
linkend="sec-nix-instantiate"><command>nix-instantiate</command></link>
|
||||
|
|
|
@ -176,7 +176,7 @@ set.</para></footnote></para>
|
|||
<sect1 id="sec-profiles"><title>Profiles</title>
|
||||
|
||||
<para>Profiles and user environments are Nix’s mechanism for
|
||||
implementing the ability to allow differens users to have different
|
||||
implementing the ability to allow different users to have different
|
||||
configurations, and to do atomic upgrades and rollbacks. To
|
||||
understand how they work, it’s useful to know a bit about how Nix
|
||||
works. In Nix, components are stored in unique locations in the
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
|
||||
nixExpr=$1
|
||||
|
||||
if test -z "$nixExpr"; then
|
||||
echo "syntax: $0 NIX-EXPR..." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extraArgs=
|
||||
addDrvLink=0
|
||||
addOutLink=1
|
||||
|
@ -16,9 +11,15 @@ trap 'rm -f ./.nix-build-tmp-*' EXIT
|
|||
|
||||
|
||||
# Process the arguments.
|
||||
exprs=
|
||||
for i in "$@"; do
|
||||
case "$i" in
|
||||
|
||||
--help)
|
||||
echo "syntax: $0 [NIX-EXPR...]" >&2
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--add-drv-link)
|
||||
addDrvLink=1
|
||||
;;
|
||||
|
@ -32,28 +33,37 @@ for i in "$@"; do
|
|||
;;
|
||||
|
||||
*)
|
||||
# Instantiate the Nix expression.
|
||||
prefix=
|
||||
if test "$addDrvLink" = 0; then prefix=.nix-build-tmp-; fi
|
||||
storeExprs=$(@bindir@/nix-instantiate \
|
||||
--add-root ./${prefix}derivation --indirect \
|
||||
"$i")
|
||||
|
||||
for j in $storeExprs; do
|
||||
echo "store expression is $(readlink "$j")" >&2
|
||||
done
|
||||
|
||||
# Build the resulting store derivation.
|
||||
prefix=
|
||||
if test "$addOutLink" = 0; then prefix=.nix-build-tmp-; fi
|
||||
outPaths=$(@bindir@/nix-store \
|
||||
--add-root ./${prefix}result --indirect \
|
||||
-rv $extraArgs $storeExprs)
|
||||
|
||||
for j in $outPaths; do
|
||||
echo "$(readlink "$j")"
|
||||
done
|
||||
|
||||
exprs="$exprs $i"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test -z "$exprs"; then
|
||||
exprs="./default.nix"
|
||||
fi
|
||||
|
||||
# Process the specified Nix expressions.
|
||||
for i in $exprs; do
|
||||
|
||||
# Instantiate the Nix expression.
|
||||
prefix=
|
||||
if test "$addDrvLink" = 0; then prefix=.nix-build-tmp-; fi
|
||||
storeExprs=$(@bindir@/nix-instantiate \
|
||||
--add-root ./${prefix}derivation --indirect \
|
||||
"$i")
|
||||
|
||||
for j in $storeExprs; do
|
||||
echo "store expression is $(readlink "$j")" >&2
|
||||
done
|
||||
|
||||
# Build the resulting store derivation.
|
||||
prefix=
|
||||
if test "$addOutLink" = 0; then prefix=.nix-build-tmp-; fi
|
||||
outPaths=$(@bindir@/nix-store \
|
||||
--add-root ./${prefix}result --indirect \
|
||||
-rv $extraArgs $storeExprs)
|
||||
|
||||
for j in $outPaths; do
|
||||
echo "$(readlink "$j")"
|
||||
done
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue