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

ncurses: Build standard terminfo dirs into static ncurses #311411

Merged
merged 1 commit into from
May 29, 2024

Conversation

NorfairKing
Copy link
Contributor

Description of changes

This builds terminfo directories into ncurses when building statically, even on non-static variants of nixpkgs.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.05 Release Notes (or backporting 23.05 and 23.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.

Add a 👍 reaction to pull requests you find important.

@@ -39,7 +39,7 @@ stdenv.mkDerivation (finalAttrs: {
++ lib.optionals stdenv.hostPlatform.isWindows [
"--enable-sp-funcs"
"--enable-term-driver"
] ++ lib.optionals (stdenv.hostPlatform.isUnix && stdenv.hostPlatform.isStatic) [
] ++ lib.optionals (stdenv.hostPlatform.isUnix && (enableStatic || stdenv.hostPlatform.isStatic)) [
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 it can be simplified to this:

Suggested change
] ++ lib.optionals (stdenv.hostPlatform.isUnix && (enableStatic || stdenv.hostPlatform.isStatic)) [
] ++ lib.optionals (stdenv.hostPlatform.isUnix && enableStatic) [

I don't think the package would build if stdenv.hostPlatform.isStatic == true && enableStatic == false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@midchildan Does enableStatic get activated automatically on stdenv.hostPlatform.isStatic?
Or do I need to change the default value for enableStatic to stdenv.hostPlatform.isStatic?

Copy link
Member

Choose a reason for hiding this comment

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

The default value for enableStatic already is stdenv.hostPlatform.isStatic, so no further changes should be necessary.

, enableStatic ? stdenv.hostPlatform.isStatic

@NorfairKing
Copy link
Contributor Author

Done

@NorfairKing
Copy link
Contributor Author

NorfairKing commented May 15, 2024

@midchildan Anything else I need to do before we can merge this? I'd like to get it into 24.05.

@midchildan
Copy link
Member

passthru.tests is failing, but this would probably be fixed with #311069

@midchildan
Copy link
Member

@NorfairKing You'll need to get a committer to merge it. Since I reviewed this PR, you can post a link to the "PRs already reviewed" Discourse thread to give it some attention.

https://discourse.nixos.org/t/prs-already-reviewed/2617

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/1637

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label May 16, 2024
@JohnRTitor
Copy link
Contributor

I'd like to get it into 24.05.

Probably won't happen unless backported. The last staging-next iteration was merged a few days ago.

I wonder if this should be targeting master branch though, it doesn't cause that many rebuilds.

@NorfairKing
Copy link
Contributor Author

I could backport it once this is merged.

@doronbehar
Copy link
Contributor

I don't understand, how did you find out you need to apply this change?

@NorfairKing
Copy link
Contributor Author

@doronbehar I was statically linking against musl with pkgsMusl.

@doronbehar
Copy link
Contributor

@doronbehar I was statically linking against musl with pkgsMusl.

Exactly what expression did you try to evaluate? Could you share it please?

@NorfairKing
Copy link
Contributor Author

@NorfairKing
Copy link
Contributor Author

This PR has already been approved. I just need someone to press merge, and I don't know what anyone is waiting for .. ?
This process could use some transparency :(

@doronbehar
Copy link
Contributor

@doronbehar you can check here: NorfairKing/smos@8c7f97b/nix/overlay.nix#L54 and also the terminfo section here: cs-syd.eu/posts/2024-04-20-static-linking-haskell-nix

It's a bit hard for me to dive into the context there, but I'm taking from here that basically the issue with the terminfo dirs is reproducible with (if you are inside a Nixpkgs branch):

nix build -L --impure --expr 'with (builtins.getFlake "'$PWD'").legacyPackages.${builtins.currentSystem}; ncurses.override {enableStatic = true;}'

I asked that because I wanted to claim that if you'd run instead:

nix build -L --impure --expr 'with (builtins.getFlake "'$PWD'").legacyPackages.${builtins.currentSystem}; pkgsStatic.pkgsMusl.ncurses'

You'd get the package you are interested in, without the terminfo dirs issue.

This case makes me think that in general we shouldn't add enableStatic arguments to packages, but instruct people to use pkgsStatic.${pkg}, because they really mean the same.

This PR has already been approved. I just need someone to press merge, and I don't know what anyone is waiting for .. ? This process could use some transparency :(

I might merge it, I just want to make sure that my observations are correct. I'm sorry for you were waiting so long. Your PR is not trivial although it seems simple, which makes people afraid to break packages due to it. I'm opening a discourse thread about this issue in general.

I'm sorry I wasn't transparent in my intentions when I commented here for the first time, I hope now that my concerns are clear.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/remove-all-enablestatic-arguments-in-nixpkgs-and-instruct-people-to-use-pkgsstatic/46092/1

@doronbehar
Copy link
Contributor

BTW this doesn't have to target staging branch, as the number of rebuilds is small because it touches only the static ncurses.

@NorfairKing
Copy link
Contributor Author

NorfairKing commented May 28, 2024

CC @nh2 who's done all a lot of the work you're suggesting removing.
IIRC he knows about why we use pkgsMusl instead of pkgsStatic for static linking.

@doronbehar
Copy link
Contributor

CC @nh2 who's done all the work you're suggesting removing.

The work that I suggest removing? Are you talking about removing the enableStatic arguments?

@NorfairKing
Copy link
Contributor Author

The work that I suggest removing? Are you talking about removing the enableStatic arguments?

Yes, the discourse page https://discourse.nixos.org/t/remove-all-enablestatic-arguments-in-nixpkgs-and-instruct-people-to-use-pkgsstatic/46092 seems to suggest removing enableStatic, right?
Did I read that wrong?

This would make impossible to link statically in a nixpkgs "version" like pkgsMusl, which is what @nh2 has made possible in many cases, see #43795

This PR is just following up on the years of effort that went into that, so I'm pinging him to weigh in.

@doronbehar
Copy link
Contributor

seems to suggest removing enableStatic, right?
Did I read that wrong?

Partly wrong yes. I'm suggesting to remove enableStatic, but rely instead upon stdenv.hostPlatform.isStatic - so that pkgsStatic.ncurses and/or pkgsStatic.pkgsMusl.ncurses will make the expression add the configureFlags you are missing.

This would make impossible to link statically in a nixpkgs "version" like pkgsMusl, which is what @nh2 has made possible in many cases, see #43795

OK I wasn't aware of this effort. I had in the past good experience with pkgsStatic.pkgsMusl and pkgsMusl.pkgsStatic, so that's why I suggested you to try out pkgsStatic.pkgsMusl.ncurses, and perhaps also try (it could be equivalent) pkgsMusl.pkgsStatic.ncurses, as I'm curious to know how will it work for you - that's what I asked you to try to use in my long comment. Please try out these attribute as an alternative 🙏.

@NorfairKing
Copy link
Contributor Author

@doronbehar I'm all for improvements but can we please make them after merging this fix ?

@doronbehar
Copy link
Contributor

OK I understand now the subtle difference between enableStatic and using pkgsStatic :) Sorry for holding this up, and thank you for insisting you are correct 🚀 .

@doronbehar doronbehar merged commit ce7eb01 into NixOS:staging May 29, 2024
25 checks passed
@doronbehar
Copy link
Contributor

Aish you could have target branch master, and could have get this update faster to your channels / flakes.

@NorfairKing
Copy link
Contributor Author

@doronbehar thank you for the kind communication 💛

@NorfairKing
Copy link
Contributor Author

@doronbehar Some more background info:
#61575

@NorfairKing NorfairKing added the backport staging-24.05 Backport PR automatically label Jun 24, 2024
Copy link
Contributor

Successfully created backport PR for staging-24.05:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 11-100 10.rebuild-linux: 11-100 12.approvals: 1 This PR was reviewed and approved by one reputable person backport staging-24.05 Backport PR automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants