Merge pull request #76189 from Ma27/nixos-install-verbosity-level

nixos/nixos-installer: add flags for verbosity and build logs
This commit is contained in:
Linus Heckemann 2019-12-28 11:50:25 +01:00 committed by GitHub
commit b9bf846080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 3 deletions

View File

@ -14,6 +14,26 @@
<refsynopsisdiv> <refsynopsisdiv>
<cmdsynopsis> <cmdsynopsis>
<command>nixos-install</command> <command>nixos-install</command>
<arg>
<group choice='req'>
<arg choice='plain'>
<option>--verbose</option>
</arg>
<arg choice='plain'>
<option>-v</option>
</arg>
</group>
</arg>
<arg>
<group choice='req'>
<arg choice='plain'>
<option>--print-build-logs</option>
</arg>
<arg choice='plain'>
<option>-L</option>
</arg>
</group>
</arg>
<arg> <arg>
<arg choice='plain'> <arg choice='plain'>
<option>-I</option> <option>-I</option>
@ -134,6 +154,23 @@
This command accepts the following options: This command accepts the following options:
</para> </para>
<variablelist> <variablelist>
<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>Please note that this option may be specified repeatedly.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--print-build-logs</option> / <option>-L</option></term>
<listitem>
<para>Print the full build logs of <command>nix build</command> to stderr.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<option>--root</option> <option>--root</option>

View File

@ -14,6 +14,8 @@ extraBuildFlags=()
mountPoint=/mnt mountPoint=/mnt
channelPath= channelPath=
system= system=
verbosity=()
buildLogs=
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
i="$1"; shift 1 i="$1"; shift 1
@ -55,6 +57,12 @@ while [ "$#" -gt 0 ]; do
--debug) --debug)
set -x set -x
;; ;;
-v*|--verbose)
verbosity+=("$i")
;;
-L|--print-build-logs)
buildLogs="$i"
;;
*) *)
echo "$0: unknown option \`$i'" echo "$0: unknown option \`$i'"
exit 1 exit 1
@ -94,7 +102,7 @@ if [[ -z $system ]]; then
outLink="$tmpdir/system" outLink="$tmpdir/system"
nix build --out-link "$outLink" --store "$mountPoint" "${extraBuildFlags[@]}" \ nix build --out-link "$outLink" --store "$mountPoint" "${extraBuildFlags[@]}" \
--extra-substituters "$sub" \ --extra-substituters "$sub" \
-f '<nixpkgs/nixos>' system -I "nixos-config=$NIXOS_CONFIG" -f '<nixpkgs/nixos>' system -I "nixos-config=$NIXOS_CONFIG" ${verbosity[@]} ${buildLogs}
system=$(readlink -f $outLink) system=$(readlink -f $outLink)
fi fi
@ -103,7 +111,7 @@ fi
# a progress bar. # a progress bar.
nix-env --store "$mountPoint" "${extraBuildFlags[@]}" \ nix-env --store "$mountPoint" "${extraBuildFlags[@]}" \
--extra-substituters "$sub" \ --extra-substituters "$sub" \
-p $mountPoint/nix/var/nix/profiles/system --set "$system" -p $mountPoint/nix/var/nix/profiles/system --set "$system" ${verbosity[@]}
# Copy the NixOS/Nixpkgs sources to the target as the initial contents # Copy the NixOS/Nixpkgs sources to the target as the initial contents
# of the NixOS channel. # of the NixOS channel.
@ -115,7 +123,8 @@ if [[ -z $noChannelCopy ]]; then
echo "copying channel..." echo "copying channel..."
mkdir -p $mountPoint/nix/var/nix/profiles/per-user/root mkdir -p $mountPoint/nix/var/nix/profiles/per-user/root
nix-env --store "$mountPoint" "${extraBuildFlags[@]}" --extra-substituters "$sub" \ nix-env --store "$mountPoint" "${extraBuildFlags[@]}" --extra-substituters "$sub" \
-p $mountPoint/nix/var/nix/profiles/per-user/root/channels --set "$channelPath" --quiet -p $mountPoint/nix/var/nix/profiles/per-user/root/channels --set "$channelPath" --quiet \
${verbosity[@]}
install -m 0700 -d $mountPoint/root/.nix-defexpr install -m 0700 -d $mountPoint/root/.nix-defexpr
ln -sfn /nix/var/nix/profiles/per-user/root/channels $mountPoint/root/.nix-defexpr/channels ln -sfn /nix/var/nix/profiles/per-user/root/channels $mountPoint/root/.nix-defexpr/channels
fi fi