[Nix-dev] nix unpack

Sergey Mironov ierton at gmail.com
Sun Feb 12 17:41:04 CET 2012


On Sun, Jan 29, 2012 at 11:56:20AM +0100, Marc Weber wrote:
> 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.

Thanks, I've created a wiki page describing that.
http://nixos.org/wiki/How_to_unpack_a_package%27s_sourcecode



More information about the nix-dev mailing list