[Nix-dev] builtins.toPath returns ... a string?

Ben Doyle benjamin.peter.doyle at gmail.com
Thu May 22 18:51:53 CEST 2014


On Thu, May 22, 2014 at 11:49 AM, Marc Weber <marco-oweber at gmx.de> wrote:

>
> You may want to talk about your use case.



Happy to. We have several developers working on our (newly nix-ified)
codebase. For development, we'd like them each to have a nix expression
that points at their local copy of the source. It seemed reasonable, if
vaguely dodgy, to use an environmental variable to configure the base
directory
in which their local source lives. I ended up with this function:

helper.configSrc = buildLocal: srcdir: fetchArgs@{url, ... }: if buildLocal
     then builtins.toPath ((builtins.getEnv "CODE_PATH") + srcdir)
     else pkgs.fetchgit fetchArgs;

which also allows me to pass in `--arg buildLocal false` to use our git
repository, for deployment.

Of course, a workaround is to do something like this:

helper.configSrc = buildLocal: basedir: srcdir: fetchArgs@{url, ... }: if
buildLocal
     then basedir + srcdir
     else pkgs.fetchgit fetchArgs;

and have our developers set an alias for nix-shell --arg basedir
<their-code-directory>.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20140522/0528dee9/attachment.html 


More information about the nix-dev mailing list