From f08449ccbd2009b858aae18341aedf3d0829b91a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 7 Oct 2015 14:55:33 +0200 Subject: nix-prefetch-url: Add --name option This allows overriding the name component of the resulting Nix store path, which is necessary if the base name of the URI contains "illegal" characters. --- src/nix-prefetch-url/nix-prefetch-url.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/nix-prefetch-url') diff --git a/src/nix-prefetch-url/nix-prefetch-url.cc b/src/nix-prefetch-url/nix-prefetch-url.cc index a3932d6bed55..0a8166da4aa1 100644 --- a/src/nix-prefetch-url/nix-prefetch-url.cc +++ b/src/nix-prefetch-url/nix-prefetch-url.cc @@ -75,6 +75,8 @@ int main(int argc, char * * argv) } else if (*arg == "--unpack") unpack = true; + else if (*arg == "--name") + name = getArg(*arg, arg, end); else if (parseAutoArgs(arg, end, autoArgs_)) ; else if (parseSearchPathArg(arg, end, searchPath)) @@ -125,9 +127,11 @@ int main(int argc, char * * argv) unpack = state.forceString(*attr->value) == "recursive"; /* Extract the name. */ - attr = v.attrs->find(state.symbols.create("name")); - if (attr != v.attrs->end()) - name = state.forceString(*attr->value); + if (name.empty()) { + attr = v.attrs->find(state.symbols.create("name")); + if (attr != v.attrs->end()) + name = state.forceString(*attr->value); + } } /* Figure out a name in the Nix store. */ -- cgit 1.4.1