* Canonicalise paths so that Fix produces identical Nix
expressions for identical inputs.
This commit is contained in:
parent
cab3f4977a
commit
9a99dc736d
|
@ -170,7 +170,8 @@ static Expr evalExpr(Expr e)
|
||||||
if (name == "")
|
if (name == "")
|
||||||
throw badTerm("no package name specified", nf);
|
throw badTerm("no package name specified", nf);
|
||||||
|
|
||||||
string out = nixStore + "/" + ((string) hash).c_str() + "-" + name;
|
string out =
|
||||||
|
canonPath(nixStore + "/" + ((string) hash).c_str() + "-" + name);
|
||||||
|
|
||||||
env = ATinsert(env, ATmake("(<str>, <str>)", "out", out.c_str()));
|
env = ATinsert(env, ATmake("(<str>, <str>)", "out", out.c_str()));
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ Hash writeTerm(ATerm t)
|
||||||
if (!ATwriteToNamedTextFile(t, path.c_str()))
|
if (!ATwriteToNamedTextFile(t, path.c_str()))
|
||||||
throw Error(format("cannot write aterm %1%") % path);
|
throw Error(format("cannot write aterm %1%") % path);
|
||||||
Hash hash = hashPath(path);
|
Hash hash = hashPath(path);
|
||||||
string path2 = nixStore + "/" + (string) hash + ".nix";
|
string path2 = canonPath(nixStore + "/" + (string) hash + ".nix");
|
||||||
if (rename(path.c_str(), path2.c_str()) == -1)
|
if (rename(path.c_str(), path2.c_str()) == -1)
|
||||||
throw SysError(format("renaming %1% to %2%") % path % path2);
|
throw SysError(format("renaming %1% to %2%") % path % path2);
|
||||||
registerPath(path2, hash);
|
registerPath(path2, hash);
|
||||||
|
|
|
@ -177,7 +177,7 @@ void addToStore(string srcPath, string & dstPath, Hash & hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
string baseName = baseNameOf(srcPath);
|
string baseName = baseNameOf(srcPath);
|
||||||
dstPath = nixStore + "/" + (string) hash + "-" + baseName;
|
dstPath = canonPath(nixStore + "/" + (string) hash + "-" + baseName);
|
||||||
|
|
||||||
copyPath(srcPath, dstPath);
|
copyPath(srcPath, dstPath);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue