Skip to content

Update Cwd.pm to work on Guix & NixOS #18752

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 4 commits into from
Closed

Update Cwd.pm to work on Guix & NixOS #18752

wants to merge 4 commits into from

Conversation

Frosku
Copy link

@Frosku Frosku commented Apr 30, 2021

refs #18703

This change fixes Cwd on NixOS/Guix.

@grahamc
Copy link

grahamc commented Apr 30, 2021

The more correct way to handle this (as a NixOS contributor) is to patch Cwd at build time to use an absolute path to pwd. Please don't merge this.

@Frosku
Copy link
Author

Frosku commented Apr 30, 2021

The more correct way to handle this (as a NixOS contributor) is to patch Cwd at build time to use an absolute path to pwd. Please don't merge this.

As discussed in IRC, this doesn't work when using any of the common perl version managers (perlbrew/plenv) which do not use nix expressions or nix build tools.

@grahamc
Copy link

grahamc commented Apr 30, 2021

Those tools should also be patched.

@Frosku
Copy link
Author

Frosku commented Apr 30, 2021

Those tools should also be patched.

This would require actual rewriting of the tool so that it rewrites Cwd.pm in place every time it pulls perl.

@grahamc
Copy link

grahamc commented Apr 30, 2021

Unfortunately this will be true for lots of software installed by perlbrew etc, as lots of Perl packages expect programs at specific places in the FS. I wonder what other techniques might work?

@Frosku
Copy link
Author

Frosku commented Apr 30, 2021

Unfortunately this will be true for lots of software installed by perlbrew etc, as lots of Perl packages expect programs at specific places in the FS. I wonder what other techniques might work?

Typically this is for the same reason where you see it: to avoid breaking under taint mode, which is an ancient security feature. Short of deprecating taint mode or rewriting perl version managers (plenv/perlbrew) to rewrite the module in place before building, it's very difficult to solve.

Regardless, perl should be able to be built in nixos with or without using nix build tools, because current nix build tools do not have the sophistication to replace something like perlbrew (managing multiple versions, and multiple local::lib setups). Tim Toady and all that.

@jkeenan
Copy link
Contributor

jkeenan commented May 21, 2021

@tonycoz or @atoomic, could either of you review the discussion in this p.r.?

Thank you very much.
Jim Keenan

Comment on lines +158 to +159
'/run/current-system/profile/bin/pwd', # GUIX
'/run/current-system/sw/bin/pwd' # NixOS
Copy link

Choose a reason for hiding this comment

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

Importantly, Nix's concept of closures is very important and highly valued. It is very common to export a closure and run it elsewhere, where /run/ doesn't exist in any form. This works "sometimes" but intentionally sidesteps the design philosophy of Nix, creating software artifacts that appear to work in development and then fails on deployment due to cheating like this.

@tonycoz
Copy link
Contributor

tonycoz commented May 24, 2021

I suspect from the discussion and from using nixos to test #18791 that Configure should be detecting pwd (or PATH) to save in config.sh and Cwd should then using that to find pwd by default.

I think the standard way would be to use confstr() to get the system PATH and search that, but POSIX.pm doesn't expose that, and POSIX.pm isn't available at the point this is called anyway. I'm pretty sure that would have the same problems that this change does, since the result of getconf PATH doesn't change in a child environment.

So from the discussion I don't think this change is appropriate.

@jkeenan
Copy link
Contributor

jkeenan commented Oct 14, 2021

I suspect from the discussion and from using nixos to test #18791 that Configure should be detecting pwd (or PATH) to save in config.sh and Cwd should then using that to find pwd by default.

I think the standard way would be to use confstr() to get the system PATH and search that, but POSIX.pm doesn't expose that, and POSIX.pm isn't available at the point this is called anyway. I'm pretty sure that would have the same problems that this change does, since the result of getconf PATH doesn't change in a child environment.

So from the discussion I don't think this change is appropriate.

No one has disputed @tonycoz's judgment on this question in the past five months, so I'm closing this p.r.

@jkeenan jkeenan closed this Oct 14, 2021
@Leont
Copy link
Contributor

Leont commented Oct 14, 2021

I suspect from the discussion and from using nixos to test #18791 that Configure should be detecting pwd (or PATH) to save in config.sh and Cwd should then using that to find pwd by default.

This sounds sensible to me

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

Successfully merging this pull request may close these issues.

5 participants