mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-13 01:36:15 +02:00
nix-env/nix-instantiate/nix-build: Support URIs
For instance, you can install Firefox from a specific Nixpkgs revision
like this:
$ nix-env -f 63def04891
.tar.gz -iA firefox
Or build a package from the latest nixpkgs-unstable channel:
$ nix-build https://nixos.org/channels/nixpkgs-unstable/nixexprs.tar.xz -A hello
This commit is contained in:
parent
0705d04dfa
commit
6519f06f39
5 changed files with 19 additions and 14 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "common-opts.hh"
|
#include "common-opts.hh"
|
||||||
#include "../libmain/shared.hh"
|
#include "shared.hh"
|
||||||
|
#include "download.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +54,9 @@ bool parseSearchPathArg(Strings::iterator & i,
|
||||||
|
|
||||||
Path lookupFileArg(EvalState & state, string s)
|
Path lookupFileArg(EvalState & state, string s)
|
||||||
{
|
{
|
||||||
if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') {
|
if (isUri(s))
|
||||||
|
return downloadFileCached(s, true);
|
||||||
|
else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') {
|
||||||
Path p = s.substr(1, s.size() - 2);
|
Path p = s.substr(1, s.size() - 2);
|
||||||
return state.findFile(p);
|
return state.findFile(p);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -223,4 +223,13 @@ Path downloadFileCached(const string & url, bool unpack)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool isUri(const string & s)
|
||||||
|
{
|
||||||
|
size_t pos = s.find("://");
|
||||||
|
if (pos == string::npos) return false;
|
||||||
|
string scheme(s, 0, pos);
|
||||||
|
return scheme == "http" || scheme == "https";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,6 @@ Path downloadFileCached(const string & url, bool unpack);
|
||||||
|
|
||||||
MakeError(DownloadError, Error)
|
MakeError(DownloadError, Error)
|
||||||
|
|
||||||
|
bool isUri(const string & s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -601,15 +601,6 @@ Expr * EvalState::parseExprFromString(const string & s, const Path & basePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool isUri(const string & s)
|
|
||||||
{
|
|
||||||
size_t pos = s.find("://");
|
|
||||||
if (pos == string::npos) return false;
|
|
||||||
string scheme(s, 0, pos);
|
|
||||||
return scheme == "http" || scheme == "https";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void EvalState::addToSearchPath(const string & s, bool warn)
|
void EvalState::addToSearchPath(const string & s, bool warn)
|
||||||
{
|
{
|
||||||
size_t pos = s.find('=');
|
size_t pos = s.find('=');
|
||||||
|
|
|
@ -183,10 +183,10 @@ int main(int argc, char * * argv)
|
||||||
} else if (files.empty() && !fromArgs)
|
} else if (files.empty() && !fromArgs)
|
||||||
files.push_back("./default.nix");
|
files.push_back("./default.nix");
|
||||||
|
|
||||||
foreach (Strings::iterator, i, files) {
|
for (auto & i : files) {
|
||||||
Expr * e = fromArgs
|
Expr * e = fromArgs
|
||||||
? state.parseExprFromString(*i, absPath("."))
|
? state.parseExprFromString(i, absPath("."))
|
||||||
: state.parseExprFromFile(resolveExprPath(lookupFileArg(state, *i)));
|
: state.parseExprFromFile(resolveExprPath(lookupFileArg(state, i)));
|
||||||
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
||||||
evalOnly, outputKind, xmlOutputSourceLocation, e);
|
evalOnly, outputKind, xmlOutputSourceLocation, e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue