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

ghostscript: wrap binaries to add correct PATH #216666

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

SharzyL
Copy link
Contributor

@SharzyL SharzyL commented Feb 16, 2023

Description of changes

For scripts in ${ghostscript}/bin, they are not properly wrapped to put the binaries in PATH. When running them without packages in PATH, the scripts complain command not found. For example,

env -i nix shell p#ghostscript_headless -c ps2pdf
/nix/store/qg3n3ncn0hsi94ljr20m7f5w4kpxhqxg-ghostscript-9.56.1/bin/ps2pdf: line 8: dirname: command not found
/nix/store/qg3n3ncn0hsi94ljr20m7f5w4kpxhqxg-ghostscript-9.56.1/bin/ps2pdf14: line 3: dirname: command not found
/nix/store/qg3n3ncn0hsi94ljr20m7f5w4kpxhqxg-ghostscript-9.56.1/bin/ps2pdfwr: line 7: dirname: command not found
/nix/store/qg3n3ncn0hsi94ljr20m7f5w4kpxhqxg-ghostscript-9.56.1/bin/ps2pdfwr: line 24: basename: command not found

We wrapped these binaries to prefix the necessary packages to PATH.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@SharzyL
Copy link
Contributor Author

SharzyL commented Feb 17, 2023

retarget staging now

Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

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

This seems to be a legit change, but I would like to have the confirmation of more experienced reviewers.

@drupol drupol added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jun 5, 2023
@drupol
Copy link
Contributor

drupol commented Jun 5, 2023

@xworld21 @apfelkuchen6 Can you help me reviewing this PR ?

@xworld21
Copy link
Contributor

xworld21 commented Jun 5, 2023

Uhm, doesn't texlive depend on ghostscript already?

I suppose this can work in a pinch, but it should definitely be revised to depend directly on dvips. Passing an empty combine is almost always wrong – either wasteful (the required package can be used directly) or broken (e.g. because of missing fonts).

pkgs/misc/ghostscript/default.nix Outdated Show resolved Hide resolved
SharzyL added 2 commits June 6, 2023 12:35
@apfelkuchen6 points out that “dvips looks up font files (and other
external files) using kpathsea and embeds them into the ps output.
But if you take dvips from such a minimal texlive installation, this
font lookup will always fail”. Since it is also ridiculous to use
texlive.combined.scheme-full, we do not wrap dvips and leaves the users
to provide their own dvips.
@SharzyL SharzyL force-pushed the ghostscript-wrap branch from 10ef19a to 9b2b680 Compare June 6, 2023 04:43
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jun 6, 2023
Copy link
Contributor

@apfelkuchen6 apfelkuchen6 left a comment

Choose a reason for hiding this comment

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

The changes look reasonable to me now.

There are failing tests on darwin, these also failed before, right?

done

for bin in $out/bin/ps2* ; do
wrapProgram $bin --prefix PATH : ${lib.makeBinPath [ coreutils ]}:$out/bin
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you checked that $0 is interpreted correctly? I believe wrapProgram breaks $0 for non-binary executables. I suspect in this case it would only break the help output, showing e.g. .ps2pdf-wrapped instead of ps2pdf. But $0 is also used to find the sibling executables.

(By the way, for many of these scripts, a single substituteInPlace of the entire block GS_EXECUTABLE= ... GS_EXECUTABLE="$gs" with GS_EXECUTABLE='${out}/bin/gs' is enough, and possibly more appropriate than a wrapper.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, help output is showing .ps2pdf-wrapped since it is using basename $0.

Substituting GS_EXECUTABLE='${out}/bin/gs' seems not enough because we also need to bind some PATH from coreutils, gawk.

Copy link
Contributor

Choose a reason for hiding this comment

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

Substituting GS_EXECUTABLE='${out}/bin/gs' seems not enough because we also need to bind some PATH from coreutils, gawk.

I meant, for quite a few scripts, the only coreutils usage is around GS_EXECUTABLE, so if you patch that away, there is no need for a wrapper. Other scripts do use gawk, basename, etc. so I agree with wrapping for those of course.

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Sep 7, 2023
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 19, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 27, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 27, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 10.rebuild-darwin: 501+ 10.rebuild-darwin: 2501-5000 10.rebuild-linux: 501+ 10.rebuild-linux: 5001+ 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants