Skip to content

Comments

haskellPackages.cabal-install: fix build when cross compiling#490936

Open
alexfmpe wants to merge 1 commit intoNixOS:haskell-updatesfrom
alexfmpe:cabal-install-cross
Open

haskellPackages.cabal-install: fix build when cross compiling#490936
alexfmpe wants to merge 1 commit intoNixOS:haskell-updatesfrom
alexfmpe:cabal-install-cross

Conversation

@alexfmpe
Copy link
Member

Fixes nix-build -A pkgsCross.aarch64-multiplatform.haskellPackages.cabal-install

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@ofborg ofborg bot added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Feb 16, 2026
postInstall = old.postInstall + ''
mkdir -p "$out/share/man/man1"
"$out/bin/cabal" man --raw > "$out/share/man/man1/cabal.1"
${emulator} "$out/bin/cabal" man --raw > "$out/share/man/man1/cabal.1"
Copy link
Member Author

Choose a reason for hiding this comment

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

This causes rebuild even on the native case due to the extra exec.
One way to get around it is something like

let emulatorIfNeeded exe = if isCross then (emulator + " " + exe) else exe;

and then

${emulatorIfNeeded ''"$out/bin/cabal"''} man --raw > "$out/share/man/man1/cabal.1"

++ old.buildTools or [ ];
postInstall = old.postInstall + ''
mkdir -p "$out/share/man/man1"
"$out/bin/cabal" man --raw > "$out/share/man/man1/cabal.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we even call $out/bin/cabal here? Shouldn't we call the build tool cabal in this case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure, maybe @sternenseemann remembers?
They seem to have the same output, as
diff result-cabal-native/share/man/man1/cabal.1.gz result-cabal-cross/share/man/man1/cabal.1.gz came out empty.
I can't imagine a non-contrived scenario where they would differ. The only real concern I see is that build tool cabal might be a different version.
Tangent, but I think we might end up using this "run executable via emulator" logic quite a bit for those test suites which expect the executable in PATH

Copy link
Contributor

Choose a reason for hiding this comment

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

It was introduced in #115347. It doesn't look like it was on purpose that way.

Copy link
Member

Choose a reason for hiding this comment

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

Cabal doesn't act as a build tool that generates a man page from source files here. Rather, it dumps its own documentation that is compiled in. Hence it is correct to use $out/bin/cabal (it just is an ill-conceived mechanism). In particular, cabal-install doesn't even depend on cabal-install at build time and if we would introduce this dependency, there would not be a guarantee that the output would be the same, i.e. running cabal man and man cabal would give different results.

My vote would be to just disable the man page generation if cross compiling. There is no good way to support this.

Copy link
Member

Choose a reason for hiding this comment

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

Tangent, but I think we might end up using this "run executable via emulator" logic quite a bit for those test suites which expect the executable in PATH

Also here, probably disabling is better. The emulator is not a silver bullet (e.g. the user space qemu can't inject itself into exec calls) and also not necessarily available.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for clarifying.

My vote would be to just disable the man page generation if cross compiling. There is no good way to support this.

Agreed.

Copy link
Member Author

Choose a reason for hiding this comment

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

My vote would be to just disable the man page generation if cross compiling. There is no good way to support this.

Even for pkgsStatic ?
What about disabling when canExecute is false, which is what actually requires emulator shenanigans?

Copy link
Contributor

Choose a reason for hiding this comment

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

What about disabling when canExecute is false

Yes, that.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 6.topic: haskell General-purpose, statically typed, purely functional programming language labels Feb 18, 2026
@alexfmpe alexfmpe force-pushed the cabal-install-cross branch 2 times, most recently from 2db7daa to 6e825af Compare February 21, 2026 21:28
@alexfmpe alexfmpe force-pushed the cabal-install-cross branch from 6e825af to 2c7d514 Compare February 21, 2026 21:30
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. and removed 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. labels Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: haskell General-purpose, statically typed, purely functional programming language 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants