Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treewide: Remove uses of builtins.toPath. #40937

Merged
merged 1 commit into from Sep 6, 2018
Merged

Conversation

shlevy
Copy link
Member

@shlevy shlevy commented May 22, 2018

toPath has confusing semantics and is never necessary; it can always
either just be omitted or replaced by pre-concatenating /.. It has
been marked as "!!! obsolete?" for more than 10 years in a C++
comment, hopefully removing it will let us properly deprecate and,
eventually, remove it.

toPath has confusing semantics and is never necessary; it can always
either just be omitted or replaced by pre-concatenating `/.`. It has
been marked as "!!! obsolete?" for more than 10 years in a C++
comment, hopefully removing it will let us properly deprecate and,
eventually, remove it.
@shlevy shlevy requested a review from edolstra May 22, 2018 20:47
@shlevy shlevy requested a review from nbp as a code owner May 22, 2018 20:47
@jwiegley
Copy link
Contributor

I entirely agree. The semantics of builtins.toPath are strange at best.

@@ -35,7 +35,7 @@ let

mkUniquePkgs = pkgs: fastUnique (a: b: a < b) # highlighting hack: >
# here we deal with those dummy packages needed for hyphenation filtering
(map (p: if lib.isDerivation p then builtins.toPath p else "") pkgs);
(map (p: if lib.isDerivation p then p.outPath else "") pkgs);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vcunat Can you validate that this is the right thing here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs something that "gets converted" to the store path and is reasonably ordered by < operator. I think .outPath should work.

@domenkozar
Copy link
Member

+1 - same for Nix itself (and the docs).

# Abuse `builtins.toPath` to collapse possible double slashes
repoTag0 = builtins.toString (builtins.toPath "/${stripScheme registry}/${repository}/${imageName}");
# Abuse paths to collapse possible double slashes
repoTag0 = builtins.toString (/. + "/${stripScheme registry}/${repository}/${imageName}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can just be done with replaceStrings:

repoTag0 = replaceStrings ["//"] ["/"] "/${stripScheme registry}/${repository}/${imageName}";

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't replaceStrings quite inefficient? Anyway trying to keep the changes minimal for this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem.

@shlevy
Copy link
Member Author

shlevy commented May 25, 2018

@edolstra Would like your feedback here, that we actually do want to deprecate toPath?

@edolstra
Copy link
Member

Removing toPath is undesirable because users would lose the ability to build old Nixpkgs versions.

@shlevy
Copy link
Member Author

shlevy commented May 28, 2018

Sure, but we could stop using it, deprecate it with a warning, and possibly eventually replace it with an error saying "use --backwards-compat flag if you're trying to evaluate old code" or similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants