[Nix-dev] stripHash

Alex Berg chexxor at gmail.com
Tue Apr 8 06:03:53 CEST 2014


I thought the documentation for the standard environment in the Nix manual
needed, some updating, so I wrote a wiki page a few months ago. There's a
section there which describes all of those library functions [1]. I didn't
see anything which suggests it is printed to stdout. Here's the current
implementation [2].

It's possible the manual became incorrect. Does anyone else know how
stripHash should behave?

[1] https://nixos.org/wiki/NixPkgs_Standard_Environment#Library_Functions
[2]
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L418
 On Apr 7, 2014 8:39 PM, "Colin Putney" <colin at wiresong.com> wrote:

> 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
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20140407/9a4b043a/attachment.html 


More information about the nix-dev mailing list