[Nix-dev] getPkgConfig considered harmful

Lluís Batlle i Rossell viriketo at gmail.com
Mon May 17 12:14:57 CEST 2010


Michael Raskind and me just hit the problem described by kosmikus, related to
getPkgConfig "ikiwiki" "git" ...

because we have configuration set for git, for example.
git = { svnSupport = true; } 

I support the change kosmikus proposed, of using the
getConfig [ "global" "git" ] option instead of getConfig [ "git" ].

OTH, I don't like much the current usage of getPkgConfig. I can't propose
anything better though. I'd go with getConfig alone.

Regards,
Lluís.

On Fri, May 14, 2010 at 07:27:34PM +0200, Andres Loeh wrote:
> If I understand getPkgConfig correctly, then
> 
>   getPkgConfig A B default
> 
> will check the configuration file for a key A.B, and if that is not
> present, for a key B. As a final resort, if neither A.B nor B are set,
> default is returned. A common use case is to say
> 
>   if getPkgConfig "mypackage" "myfeature" false then ... else ...
> 
> in order to conditionally enable something depending on a user-defined
> flag. If myfeature is shared between multiple packages, then a user
> can globally specify whether (s)he wants the feature by saying
> "myfeature = ..." in the config file.
> 
> The problem arises once there is another line somewhere in Nixpkgs that says
> 
>   getPkgConfig "myfeature" "foo" false
> 
> in other words, if "myfeature" happens to be the name of another package.
> 
> This problem is real. One example where this problem currently arises
> is the following: In all-packages.nix, in the definition of distcc, we
> have
> 
>   python = if getPkgConfig "distcc" "python" true then python else null;
> 
> There are several other lines of the form
> 
>   getConfig ["python" ...]
> 
> That means, if someone sets for instance python.curses = true in the
> configuration file, then the getPkgConfig line above will result in a
> run-time type error.
> 
> I think this problem needs to be addressed. I know that Eelco dislikes
> getPkgConfig/getConfig in general, and I tend to agree. However, I do
> not want to propose any far-reaching changes. A relatively easy fix
> would be to make getPkgConfig A B not check A.B and B, but A.B and
> global.B (or some other name instead of global). That would
> significantly reduce the chances of name clashes.
> 
> Cheers,
>   Andres
> _______________________________________________
> nix-dev mailing list
> nix-dev at cs.uu.nl
> https://mail.cs.uu.nl/mailman/listinfo/nix-dev



More information about the nix-dev mailing list