Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite builtin:fetchurl output paths #1805

Closed
wants to merge 1 commit into from

Conversation

copumpkin
Copy link
Member

@copumpkin copumpkin commented Jan 18, 2018

This was failing when it needed redirected outputs, such as when calling a build with --check on a fixed-output derivation that used the builtin fetchurl.

Fixes #1803

cc @edolstra @shlevy @domenkozar

This was failing when it needed redirected outputs, such as when calling
a build with --check on a fixed-output derivation that used the builtin
fetchurl.

Fixes NixOS#1803
builtinFetchurl(*drv, netrcData);
if (drv->builder == "builtin:fetchurl") {
/* fetchurl might need to rewrite its outputs, so let's pass in a closure to rewrite anythings */
auto rewriter = [&](const std::string & in) { return rewriteStrings(in, inputRewrites); };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string rewriting support is all in build.cc so I didn't want to move the typedef for InputRewrites to somewhere common, when all I really needed was a string -> string function in builtinFetchurl.

@copumpkin
Copy link
Member Author

copumpkin commented Jan 18, 2018

Argh, I swear this was working and now it isn't.

Edit: I think it was; my computer is just b0rked I was using nix-daemon and it was doing the building for me, without my fix

@@ -4,6 +4,6 @@

namespace nix {

void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData);
void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData, std::function<std::string(const std::string &)> rewriteStrings);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be cleaner to rewrite strings in 'drv' prior to calling the builtin. That way all (future) builtin derivations benefit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edolstra agree, and I wanted to do that but I didn't feel comfortable changing the working of the main codepath, since all the state machine and branching stuff in this file makes it very hard to understand (or feel confident that you really grok it).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My inclination would be to remove env altogether (it's only used in a couple of places and is just another value that can get out of sync), and add the default environment values (as well as rewritten paths) to drv->env.

@copumpkin
Copy link
Member Author

@edolstra any chance we can just put this in and then clean up the rewriting logic in a subsequent commit? This is just broken right now and I don't really know how to fix it more cleanly.

@edolstra edolstra closed this in 3c4c30e Jan 19, 2018
@copumpkin
Copy link
Member Author

Thanks! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Permission denied" errors when using --check on certain fixed-output derivations
2 participants