Skip to content

plover: provide wrapPloverExes and withPlugins - #518828

Open
ShamrockLee wants to merge 2 commits into
NixOS:masterfrom
ShamrockLee:plover-with-plugins
Open

plover: provide wrapPloverExes and withPlugins#518828
ShamrockLee wants to merge 2 commits into
NixOS:masterfrom
ShamrockLee:plover-with-plugins

Conversation

@ShamrockLee

@ShamrockLee ShamrockLee commented May 10, 2026

Copy link
Copy Markdown
Contributor

This PR provides a build helper python3Packages.plover.wrapPloverExes which exposes only Plover executables from a Python environment package containing Plover and plugins.
This allows clean installation of Plover with plugins while preserving the flexibility of python3's packageOverrides package set extensibility.

{ python3 }:
let
  python3Overridden = python3.override {
    packageOverrides =
      final: previous:
      {
        plover = final.plover_5;
        plover-lapwing-aio = previous.plover-lapwing-aio.overrideAttrs { };
      };
  };
in
python3Overridden.pkgs.plover.wrapPloverExes (
  python3Overridden.withPackages (ps: with ps; [
    plover
    plover-lapwing-aio
  ])
)

This PR also provides plover.withPlugins for users who don't need custom overriding:

plover.withPlugins (ps: with ps; [ plover-lapwing-aio ])

Note

The plover.withPlugins is independent to the main plover package and depends only on python3 injected via a separate callPackage call.
Overriding applied to the main package won't get propagated to the withPlugins-constructed package.
In case downstream users need custom overriding, override the python3 argument of <plover-with-plugins>.override.

Closes #89341

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.

@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. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. labels May 10, 2026
toyboot4e added a commit to toyboot4e/plover-flake that referenced this pull request Jul 12, 2026
Follow the approach of NixOS/nixpkgs#518828:

- Define plover and ploverPlugins in a pythonPackagesExtensions overlay,
  so they are built against the same fixed point as the rest of the
  Python package set (including the Darwin qt6/pyside6 lld fixes).
- Implement withPlugins as a wrapper around python3.withPackages that
  exposes only Plover's executables (plus the desktop entry, icons and
  the macOS app bundle), so adding or removing plugins composes an
  environment instead of rebuilding Plover with extra dependencies.

Issue: opensteno#298

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
toyboot4e added a commit to toyboot4e/plover-flake that referenced this pull request Jul 26, 2026
Follow the approach of NixOS/nixpkgs#518828:

- Define plover and ploverPlugins in a pythonPackagesExtensions overlay,
  so they are built against the same fixed point as the rest of the
  Python package set (including the Darwin qt6/pyside6 lld fixes).
- Implement withPlugins as a wrapper around python3.withPackages that
  exposes only Plover's executables (plus the desktop entry, icons and
  the macOS app bundle), so adding or removing plugins composes an
  environment instead of rebuilding Plover with extra dependencies.

Issue: opensteno#298

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ShamrockLee
ShamrockLee force-pushed the plover-with-plugins branch from 2967076 to ef9ddb9 Compare August 3, 2026 09:53
@nixpkgs-ci nixpkgs-ci Bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Aug 3, 2026
@ShamrockLee
ShamrockLee force-pushed the plover-with-plugins branch from ef9ddb9 to afd0a48 Compare August 3, 2026 10:31
@ShamrockLee ShamrockLee changed the title plover: add plover.withPlugins plover: provide wrapPloverExes and withPlugins Aug 3, 2026
@ShamrockLee
ShamrockLee force-pushed the plover-with-plugins branch from afd0a48 to 66d63f1 Compare August 3, 2026 10:58
@nixpkgs-review-gha

This comment was marked as outdated.

@ShamrockLee
ShamrockLee force-pushed the plover-with-plugins branch from 66d63f1 to 9446572 Compare August 5, 2026 21:17
@nixpkgs-review-gha

Copy link
Copy Markdown

nixpkgs-review result

Generated using nixpkgs-review-gha (71d8654)

Command: nixpkgs-review pr 518828 -a plover.tests
Commit: 94465729f2617281285c439c93fea4aaddd4f155 (subsequent changes)
Merge: 91b98d10ad167e13934cf07e9a668738c2a7f121

Triggered by @ShamrockLee (44064051)
Logs: https://github.com/ShamrockLee/nixpkgs-review-gha/actions/runs/31034189465/attempts/2


x86_64-linux

✅ 1 package built:
  • plover.tests.plover-with-lapwing

aarch64-linux

✅ 1 package built:
  • plover.tests.plover-with-lapwing

aarch64-darwin (sandbox = relaxed)

✅ 1 package built:
  • plover.tests.plover-with-lapwing

@ShamrockLee
ShamrockLee marked this pull request as ready for review August 5, 2026 22:16
@ShamrockLee

ShamrockLee commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Cc: @Twey @lambdadog
Not sure why GitHub didn't let me request your review.

@ShamrockLee
ShamrockLee requested review from evils and tckmn August 5, 2026 22:28
Comment thread pkgs/development/python-modules/plover/wrap-plover-exes.nix
Comment thread pkgs/development/python-modules/plover/wrap-plover-exes.nix Outdated
Comment on lines +1 to +42
{
lib,
stdenvNoCC,
makeWrapper,
versionCheckHook,
plover,
}:
python-env:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "plover-wrapper-with-plugins";
inherit (plover) version;
nativeBuildInputs = [
makeWrapper
];
dontUnpack = true;
installPhase = ''
runHook preInstall
mkdir -p "''${!outputBin}/bin"
for _pathFromPlover in ${lib.getBin plover}/bin/*; do
_nameFromPlover=$(basename "$_pathFromPlover")
makeWrapper "${lib.getBin finalAttrs.passthru.python-env}/bin/$_nameFromPlover" "''${!outputBin}/bin/$_nameFromPlover"
done
runHook postInstall
'';
doInstallCheck = true;
nativeInstallCheckInputs = [
versionCheckHook
];
passthru = {
inherit python-env;
};
meta =
removeAttrs plover.meta [
"attrs"
"position"
"references"
"validity"
]
// {
mainProgram = "plover";
};
})

This comment was marked as outdated.

Comment on lines +1 to +4
{ python3 }:

selectPackages:
python3.pkgs.plover.wrapPloverExes (python3.withPackages (ps: [ ps.plover ] ++ selectPackages ps))

This comment was marked as outdated.

@Pandapip1

Copy link
Copy Markdown
Member

Never mind just checked and those do NOT work

@Pandapip1

Copy link
Copy Markdown
Member

Aha, I did figure out that we can avoid wrapping by doing

ps.plover.overridePythonAttrs (old: {
  dependencies = old.dependencies ++ (selectPackages ps);
  catchConflicts = false;
})

which gives a plover with the plugins just there.

@ShamrockLee
ShamrockLee force-pushed the plover-with-plugins branch from 33fb3aa to 4092ce9 Compare August 6, 2026 14:00
ShamrockLee and others added 2 commits August 6, 2026 22:04
Allow wrapping around the Python environment to avoid installation collisions.

Co-authored-by: Gavin John <gavinnjohn@gmail.com>
@ShamrockLee
ShamrockLee force-pushed the plover-with-plugins branch from 4092ce9 to 2534dc8 Compare August 6, 2026 14:04
@ShamrockLee

ShamrockLee commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@Pandapip1 That's interesting! Still, does it make sense to avoid wrapping by rebuilding?

@ShamrockLee
ShamrockLee requested a review from Pandapip1 August 6, 2026 14:07
@Pandapip1

Pandapip1 commented Aug 6, 2026

Copy link
Copy Markdown
Member

does it make sense to avoid wrapping by rebuilding?

It doesn't seem to take significant time to build on my machine. If it was even 20-30 seconds it might give me some pause, but it seems that the build is pretty darn fast. I think it makes sense to avoid the wrapper because it means we don't have to maintain a custom one-off wrapper which takes significantly more code than the alternative.

@toyboot4e toyboot4e left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome improvements! Looks like the right direction.

Let me note some early review.


This is an existing issue, but qtsvg would be necessary, because it's lacking icons on macOS:

Image

Here's some quick review by Claude Code (I'm sorry, but expect hallucinations):

Claude Code review

pkgs/development/python-modules/plover/wrap-plover-exes.nix

1. The desktop entry is lost. 5.nix installs share/applications/plover.desktop, and switching from plover to plover.withPlugins (…) silently drops the app launcher entry.

2. removeAttrs plover.meta [...] doesn't do what it looks like. plover.meta isn't just the block written in 5.nix — stdenv adds computed fields to it, so the wrapper inherits two it shouldn't:

  • name — the wrapper reports python3.14-plover-5.4.0 to nix search / nix-env -q / nix profile, instead of its own name.
  • isBuildPythonPackage — read by pkgs/top-level/release-python.nix to pick Hydra's Python jobset, and this isn't a Python package.

Listing what you want is both shorter and immune to meta gaining new computed fields later:

meta = {
  inherit (plover.meta)
    broken # plover_4 marks this on darwin
    description
    homepage
    license
    maintainers
    platforms
    ;
  mainProgram = "plover";
};

3. Nits. pname = "plover-with-plugins" reads better and matches withPlugins.

makeWrapper with zero arguments generates a script that only execs the target:

exec "/nix/store/…-python3-env/bin/plover" "$@"

Symlinking does the same thing — drop makeWrapper.

c.f. certbot/default.nix:

# certbot.withPlugins has a similar calling convention as python*.withPackages
# it gets invoked with a lambda, and invokes that lambda with the python package set matching certbot's:
# certbot.withPlugins (cp: [ cp.certbot-dns-foo ])
passthru.withPlugins =
f:
let
pythonEnv = python.withPackages f;
in
runCommand "certbot-with-plugins-${finalAttrs.version}"
{
inherit (finalAttrs) pname version;
}
''
mkdir -p $out/bin
cd $out/bin
ln -s ${pythonEnv}/bin/certbot
'';

pkgs/by-name/pl/plover/package.nix

4. withPlugins ignores python3Packages. callPackage ./with-plugins.nix { } fills python3 from the top level, not from the package set plover was built against. So:

(plover.override { python3Packages = python312Packages; }).withPlugins (ps: [ ps.plover-lapwing-aio ])

gives a 3.12 plover but a 3.14 withPlugins — two Plovers in the closure, with the plugins on the one you didn't ask for. Fix:

withPlugins = callPackage ./with-plugins.nix { python3 = python3Packages.python; };

5. The doc comment isn't valid Nix. python3.ploverpython3.pkgs.plover, withPluginswithPackages, and the missing parens make it a two-argument application:

python3.pkgs.plover.wrapPloverExes (python3.withPackages (ps: [ ps.plover ] ++ selectPackages ps))

5.nix also says python3.withPackage (singular).

6. tests merge order is inverted. { plover-with-lapwing = …; } // previousAttrs.passthru.tests or { } lets pre-existing tests shadow the new one — the usual order is previousAttrs.passthru.tests or { } // { … }.

@Pandapip1

Pandapip1 commented Aug 6, 2026

Copy link
Copy Markdown
Member

It's also lacking icons on Linux FWIW, but that's not caused by this PR and is a pre-existing issue.

@Pandapip1

Copy link
Copy Markdown
Member

Can confirm that adding qtsvg fixes the missing icons

image

@Pandapip1

Copy link
Copy Markdown
Member

#550030

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose 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. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Plover plugins

4 participants