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

haskell: move generateOptparseApplicativeCompletions into pkg sets for cross support #190536

Conversation

sternenseemann
Copy link
Member

@sternenseemann sternenseemann commented Sep 9, 2022

Deprecate haskell.lib{,.compose}.generateOptparseApplicativeCompletion* in favor of the newly added
haskell.packages.*.generateOptparseApplicativeCompletions (plural!) which takes into account whether we are cross-compiling or not. If we are, generating completions is disabled, since we can't execute software built for a different platform.

The move is necessary, so we can receive the /same/ stdenv as the package we are overriding in order to accurately check whether we can execute produced binaries.

Resolves #174040.
Resolves #49748.

Description of changes
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/)
  • 22.11 Release Notes (or backporting 22.05 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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

Comment on lines 420 to 422
addOptparseApplicativeCompletionScripts = exeName: pkg:
builtins.trace "addOptparseApplicativeCompletionScripts is deprecated in favor of generateOptparseApplicativeCompletion. Please change ${pkg.name} to use the latter or its plural form."
(generateOptparseApplicativeCompletion exeName pkg);
lib.warn "addOptparseApplicativeCompletionScripts is deprecated in favor of haskellPackages.generateOptparseApplicativeCompletions. Please change ${pkg.name} to use the latter and make sure it uses its matching haskell.packages set!"
(__generateOptparseApplicativeCompletion exeName pkg);
Copy link
Member

Choose a reason for hiding this comment

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

I don't feel strongly about this, but maybe we could just remove this function? It has been here and been deprecated for quite a long time, right?

I can't ever recall seeing this in the wild.

Copy link
Member Author

Choose a reason for hiding this comment

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

Deleting it form haskell.lib.compose should be fine in any case, we can still keep it in haskell.lib for backwards compatibility.

Copy link
Member

@cdepillabout cdepillabout left a comment

Choose a reason for hiding this comment

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

This looks really good to me, thanks for putting it together!

*/
generateOptparseApplicativeCompletions = commands: pkg:
pkgs.lib.foldr generateOptparseApplicativeCompletion pkg commands;
lib.warn "haskellLib.generateOptparseApplicativeCompletions is deprecated in favor of haskellPackages.generateOptparseApplicativeCompletions. Please change ${pkg.name} to use the latter and make sure it uses its matching haskell.packages set!"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
lib.warn "haskellLib.generateOptparseApplicativeCompletions is deprecated in favor of haskellPackages.generateOptparseApplicativeCompletions. Please change ${pkg.name} to use the latter and make sure it uses its matching haskell.packages set!"
lib.warnIf (lib.isInOldestRelease 2211) "haskellLib.generateOptparseApplicativeCompletions is deprecated in favor of haskellPackages.generateOptparseApplicativeCompletions. Please change ${pkg.name} to use the latter and make sure it uses its matching haskell.packages set!"

We should give third-party projects a bit of time before warning, so that they aren't asked to apply the change before all supported Nixpkgs releases support the new method.

Copy link
Member Author

Choose a reason for hiding this comment

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

Side note: The naming of this function is so confusing, it took me like 5 minutes to figure out what it means.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure which one you mean, but I wrote both and I agree. I'm open to suggestions.

pkgs/development/haskell-modules/lib/compose.nix Outdated Show resolved Hide resolved
Deprecate haskell.lib{,.compose}.generateOptparseApplicativeCompletion*
in favor of the newly added
haskell.packages.*.generateOptparseApplicativeCompletions (plural!)
which takes into account whether we are cross-compiling or not. If we
are, generating completions is disabled, since we can't execute software
built for a different platform.

The move is necessary, so we can receive the /same/ stdenv as the
package we are overriding in order to accurately check whether we can
execute produced binaries.

Resolves NixOS#174040.
Resolves NixOS#49648.
This function was deprecated when it was first added to
haskell.lib.compose, so we can probably safely drop it.
@sternenseemann sternenseemann force-pushed the generate-opt-parse-completion-cross branch from 5a8fa99 to 68df602 Compare October 6, 2022 22:19
@sternenseemann sternenseemann merged commit 9e9b7f4 into NixOS:haskell-updates Oct 6, 2022
@sternenseemann sternenseemann deleted the generate-opt-parse-completion-cross branch October 6, 2022 22:37
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.

4 participants