diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2015-09-08 13:07:39 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2015-09-08 13:10:13 +0200 |
commit | 9757a93263496d71a9e37b4191743dddee2b18fb (patch) | |
tree | 6ddaf541972db05d3365d9be7b0203fe568f5011 /nix-script-download-sources.sh | |
parent | e9fd4bba0d8bf404a1f2d24e1d36bd68cbbfdbaa (diff) |
Add command to download sources of a package and its deps
Diffstat (limited to 'nix-script-download-sources.sh')
-rwxr-xr-x | nix-script-download-sources.sh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/nix-script-download-sources.sh b/nix-script-download-sources.sh new file mode 100755 index 0000000..061f312 --- /dev/null +++ b/nix-script-download-sources.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +source $(dirname ${BASH_SOURCE[0]})/nix-utils.sh + +usage() { + cat <<EOS + $(help_synopsis "${BASH_SOURCE[0]}" "[-h] -p <pkg>") + + -p <pkg> | Package to download source and deps for + -Q | No build output + -h | Show this help and exit + + Download sources for the package <pkg>, so we can disconnect + from the internet before building it. + +$(help_end) +EOS +} + +PACKAGE="" + +while getopts "p:Qh" OPTION +do + case $OPTION in + p) + PACKAGE=$OPTARG + dbg "PACKAGE = $PACKAGE" + ;; + + Q) + NO_BUILD_OUTPUT=1 + dbg "NO_BUILD_OUTPUT = $NO_BUILD_OUTPUT" + ;; + + h) + usage + exit 1 + ;; + esac +done + +[[ -z "$PACKAGE" ]] && stderr "No package passed" && usage && exit 1 + +continue_question "Install sources for package '$PACKAGE'" + +drvs=$(nix-store -qR $(nix-instantiate '<nixpkgs>' -A $PACKAGE) | grep '.drv$') + +ARGS="" +[[ $NO_BUILD_OUTPUT -eq 1 ]] && ARGS="-Q" + +nix-store $ARGS -r $(grep -l outputHash $drv) + |