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.
This commit is contained in:
parent
e4abf8610b
commit
f08449ccbd
2 changed files with 19 additions and 3 deletions
|
@ -91,6 +91,18 @@ downloaded file in the Nix store is also printed.</para>
|
|||
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry><term><option>--name</option></term>
|
||||
|
||||
<listitem><para>Override the name of the file in the Nix store. By
|
||||
default, this is
|
||||
<literal><replaceable>hash</replaceable>-<replaceable>basename</replaceable></literal>,
|
||||
where <replaceable>basename</replaceable> is the last component of
|
||||
<replaceable>url</replaceable>. Overriding the name is necessary
|
||||
when <replaceable>basename</replaceable> contains characters that
|
||||
are not allowed in Nix store paths.</para></listitem>
|
||||
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsection>
|
||||
|
|
|
@ -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,10 +127,12 @@ int main(int argc, char * * argv)
|
|||
unpack = state.forceString(*attr->value) == "recursive";
|
||||
|
||||
/* Extract the name. */
|
||||
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. */
|
||||
if (name.empty())
|
||||
|
|
Loading…
Reference in a new issue