[Nix-dev] nix unpack

Marc Weber marco-oweber at gmx.de
Sun Jan 29 11:56:20 CET 2012


I use the followiing two functions, the first is a copy paste from
unpack phase

alias nb="nix-build $(NIXPKGS_ALL) -A"

cdunpack () {
	local curSrc="$1"
	local b=$(basename "$1")
	local dir="/tmp/${b}-unpacked"
	[ -e "$dir" ] || {
		mdc "$dir"
		case "$curSrc" in
			(*.tar) tar xvf $curSrc ;;
			(*.tar.gz|*.tgz|*.tar.Z) gzip -d < $curSrc | tar xvf - ;;
			(*.tar.bz2|*.tbz2) bzip2 -d < $curSrc | tar xvf - ;;
			(*.zip) unzip $curSrc ;;
			(*) if test -d "$curSrc"
				then
					stripHash $curSrc
					cp -prvd $curSrc $strippedName
				else
					if test -z "$unpackCmd"
					then
						echo "source archive $curSrc has unknown type"
						return 1
					fi
					runHook unpackCmd
				fi ;;
		esac
	}
	cd $dir
}

cdsrc () {
	cdunpack "$(nb ${1}.src --show-trace )"
}

Adjust to your liking.

Marc Weber


More information about the nix-dev mailing list