66
77namespace nix {
88
9- void builtinFetchurl (
10- const BasicDerivation & drv,
11- const std::map<std::string, Path> & outputs,
12- const std::string & netrcData,
13- const std::string & caFileData)
9+ static void builtinFetchurl (const BuiltinBuilderContext & ctx)
1410{
1511 /* Make the host's netrc data available. Too bad curl requires
1612 this to be stored in a file. It would be nice if we could just
1713 pass a pointer to the data. */
18- if (netrcData != " " ) {
14+ if (ctx. netrcData != " " ) {
1915 settings.netrcFile = " netrc" ;
20- writeFile (settings.netrcFile , netrcData, 0600 );
16+ writeFile (settings.netrcFile , ctx. netrcData , 0600 );
2117 }
2218
2319 settings.caFile = " ca-certificates.crt" ;
24- writeFile (settings.caFile , caFileData, 0600 );
20+ writeFile (settings.caFile , ctx. caFileData , 0600 );
2521
26- auto out = get (drv.outputs , " out" );
22+ auto out = get (ctx. drv .outputs , " out" );
2723 if (!out)
2824 throw Error (" 'builtin:fetchurl' requires an 'out' output" );
2925
30- if (!(drv.type ().isFixed () || drv.type ().isImpure ()))
26+ if (!(ctx. drv .type ().isFixed () || ctx. drv .type ().isImpure ()))
3127 throw Error (" 'builtin:fetchurl' must be a fixed-output or impure derivation" );
3228
33- auto storePath = outputs.at (" out" );
34- auto mainUrl = drv.env .at (" url" );
35- bool unpack = getOr (drv.env , " unpack" , " " ) == " 1" ;
29+ auto storePath = ctx. outputs .at (" out" );
30+ auto mainUrl = ctx. drv .env .at (" url" );
31+ bool unpack = getOr (ctx. drv .env , " unpack" , " " ) == " 1" ;
3632
3733 /* Note: have to use a fresh fileTransfer here because we're in
3834 a forked process. */
@@ -56,8 +52,8 @@ void builtinFetchurl(
5652 else
5753 writeFile (storePath, *source);
5854
59- auto executable = drv.env .find (" executable" );
60- if (executable != drv.env .end () && executable->second == " 1" ) {
55+ auto executable = ctx. drv .env .find (" executable" );
56+ if (executable != ctx. drv .env .end () && executable->second == " 1" ) {
6157 if (chmod (storePath.c_str (), 0755 ) == -1 )
6258 throw SysError (" making '%1%' executable" , storePath);
6359 }
@@ -79,4 +75,6 @@ void builtinFetchurl(
7975 fetch (mainUrl);
8076}
8177
78+ static RegisterBuiltinBuilder registerFetchurl (" fetchurl" , builtinFetchurl);
79+
8280}
0 commit comments