[Nix-dev] stripHash

Colin Putney colin at wiresong.com
Tue Apr 8 03:39:04 CEST 2014


Hi all,

The Nixpkgs Manual mentions that stdenv provides a shell function,
stripHash, that will strip off the directory and hash part of a store path,
and print out just the name. (See
http://nixos.org/nixpkgs/manual/#fun-stripHash).

However, it doesn't actually print anything out. (At least not in my
environment--nixpkgs from the unstable channel, recently updated). Digging
further:

[nix-shell:/tmp/build]$ type stripHash
stripHash is a function
stripHash ()
{
    strippedName=$(basename $1);
    if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then
        strippedName=$(echo "$strippedName" | cut -c34-);
    fi
}

It seems that it's correctly stripping off the name, but not echoing it as
the manual suggests. And sure enough, poking around in builder scripts in
nixpkgs, there are lots of uses of stripHash that follow this pattern:

$(stripHash $foo; echo $strippedName)

Is this a bug that everybody just works around, or is it the desired
behaviour?

Colin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20140407/ea297446/attachment.html 


More information about the nix-dev mailing list