Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 68 additions & 17 deletions pkgs/applications/misc/plover/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{ lib, fetchurl, python27Packages, python36Packages, wmctrl,
qtbase, mkDerivationWith }:
{ lib
, fetchFromGitHub
, python3Packages, python27Packages
, wmctrl, qtbase, mkDerivationWith
}:

{
rec {
stable = with python27Packages; buildPythonPackage rec {
pname = "plover";
version = "3.1.1";
Expand All @@ -12,9 +15,11 @@
license = licenses.gpl2;
};

src = fetchurl {
url = "https://github.com/openstenoproject/plover/archive/v${version}.tar.gz";
sha256 = "1hdg5491phx6svrxxsxp8v6n4b25y7y4wxw7x3bxlbyhaskgj53r";
src = fetchFromGitHub {
owner = "openstenoproject";
repo = "plover";
rev = "v${version}";
sha256 = "114rlxvq471fyifwcdcgdad79ak7q3w2lk8z9nqhz1i9fg05721c";
};

nativeBuildInputs = [ setuptools_scm ];
Expand All @@ -24,32 +29,78 @@
];
};

dev = with python36Packages; mkDerivationWith buildPythonPackage rec {
dev = with python3Packages; mkDerivationWith buildPythonPackage rec {
pname = "plover";
version = "4.0.0.dev8";
version = "4.0.0.dev9";

meta = with lib; {
description = "OpenSteno Plover stenography software";
maintainers = with maintainers; [ twey kovirobi ];
license = licenses.gpl2;
license = licenses.gpl2Plus;
};

src = fetchurl {
url = "https://github.com/openstenoproject/plover/archive/v${version}.tar.gz";
sha256 = "1wxkmik1zyw5gqig5r0cas5v6f5408fbnximzw610rdisqy09rxp";
src = fetchFromGitHub {
owner = "openstenoproject";
repo = "plover";
rev = "54dbcf4ea73cc1ecc1d7c70dbe7bdb13f055d101";
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
rev = "54dbcf4ea73cc1ecc1d7c70dbe7bdb13f055d101";
rev = "v${version}";

Copy link
Member Author

Choose a reason for hiding this comment

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

nope, they're doing a moving tag of "continuous" but still have a versioning scheme that's no longer integrated with git

sha256 = "1jm6rajlh8nm1b1331pyvp20vxxfwi4nb8wgqlkznf0kkdvfa78a";
};

# I'm not sure why we don't find PyQt5 here but there's a similar
# sed on many of the platforms Plover builds for
postPatch = "sed -i /PyQt5/d setup.cfg";

checkInputs = [ pytest mock ];
propagatedBuildInputs = [ Babel pyqt5 xlib pyserial appdirs wcwidth setuptools ];
propagatedBuildInputs = [
Babel pyqt5 xlib pyserial
appdirs wcwidth setuptools
certifi
];

dontWrapQtApps = true;

preFixup = ''
makeWrapperArgs+=("''${qtWrapperArgs[@]}")
'';
};

plugins-manager = with python3Packages; buildPythonPackage rec {
pname = "plover-plugins-manager";
version = "0.6.1";

src = fetchFromGitHub {
owner = "benoit-pierre";
repo = "plover_plugins_manager";
rev = version;
sha256 = "sha256-7OyGmSwOvoqwbBgXdfUUmwvjszUNRPlD4XyBeJ29vBg=";
};

patches = [ ./plugins_manager.patch ];
Copy link
Member Author

Choose a reason for hiding this comment

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

without the patch plugins can't be managed


buildInputs = [
# plover.dev
dev
];

propagatedBuildInputs = [
pip pkginfo pygments
readme_renderer requests
requests-cache requests-futures
setuptools wheel
];

# tests try to instantiate a virtualenv and lack permission
doCheck = false;

meta = with lib; {
description = "OpenSteno Plover stenography software plugin manager";
homepage = "https://github.com/benoit-pierre/plover_plugins_manager";
license = licenses.gpl2Plus;
maintainers = with maintainers; [ evils ];
};
};

dev-with-plugins = dev.overrideAttrs (old: {
Copy link
Contributor

@lambdadog lambdadog Aug 11, 2021

Choose a reason for hiding this comment

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

I can only echo my thoughts on #110658 that including the plugin manager is expected functionality with the dev branch of plover. It's what you'll get if you're installing plover dev with any other package manager, or the appimage, or whatever else.

If anything, now that my experience with Nix has grown, I'd like to see an argument that can be overridden (to false) on plover dev that enables the package manager by default, rather than creating two separate derivations that are built, something like

plover.dev.override {
  withPluginManager = false;
}

Copy link
Contributor

@lambdadog lambdadog Aug 11, 2021

Choose a reason for hiding this comment

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

Actually, thinking further, I'm not exactly happy that the plugin-manager derivation is exposed as it is either.

While there is the potential usecase that one would want to override the plugin manager, the way it's currently exposed gives no particularly elegant ability to do so (other than simply repeating your plover-with-plugins derivation wholesale). It shouldn't be exposed in the plover tree's top level as it currently is. My best image for how it should be exposed while giving a way to override it probably looks like putting it under a subtree like plover.devPlugins.plugin-manager, then plover.dev could expose, perhaps, both a withPluginManager and plugins override argument. If you wanted to swap out the plugin manager with an overridden version, you would set withPluginManager to false, then add your overridden version to plugins.

I'm more than happy for more brainstorming on the subject, though, I admit this probably isn't the most elegant solution but I think we need to deal with a couple of concerns, including:

  1. the plugin-manager being included being an expected default
  2. allowing users to disable it if they wish
  3. making the plover subtree not bloated, and
  4. considering the possibility of extending plover with a withPlugins-like functionality in the future, which this is already great groundwork for

Copy link
Member Author

Choose a reason for hiding this comment

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

the right solution™ is probably to accept a list of plugins
then the (default) setting of an empty list would not provide the plugin manager

as far as i know this would require packaging all the plugins in nixpkgs
which i'm not willing to do because plover doesn't work on wayland...

for now, setting plover.dev to include the plugin manager does seem like the right way forward

unfortunately i seem to recall the issue with this PR being,
plover not reliably finding the site packages (plugins) installed by the plugin manager
(between a nix-env install, a nix-shell, and a NixOS systemPackages install)
which is something i don't know how to fix, but would like to see fixed before seeing this PR merged
alternatively, we could merge something that works in 1 use-case and let users get annoyed enough to fix it themselves

Copy link
Contributor

Choose a reason for hiding this comment

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

You could probably see if it's possible to pass the site packages in an environmental variable?

It would need to be the same place recognized by the plugin manager and writeable though, but the only two cases I see are:

  1. executed by a user with a $HOME directory, and
  2. executed by a user without a $HOME directory (which, frankly, given the use-case of plover may not be a problem in the first place)

Copy link
Contributor

Choose a reason for hiding this comment

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

This can be done with makeWrapper using the --run flag and a '-quoted argument to it using $HOME, you can see how my emacs config using Nix does similar here

I imagine something like (assuming the variable needed is SITE_PACKAGES and both the plugin manager and plover would read from it correctly)

makeWrapper "PATH/TO/PLOVER/EXECUTABLE" "$out/bin/plover"
  --run 'mkdir -p "$HOME/PATH/TO/YOUR/SITEPACKAGES"'
  --run 'export SITE_PACKAGES="$HOME/PATH/TO/YOUR/SITEPACKAGES"'

would work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Of course, you would also need the site packages that nixpkgs' buildPythonPackage creates, but I'm sure it's possible to do with a bit of work.

At worst you could probably do some patching of plover and the plugin manager here or there to enable it.

Copy link
Contributor

@lambdadog lambdadog Aug 17, 2021

Choose a reason for hiding this comment

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

Upon research you may be interested in the PYTHONUSERBASE environmental variable, which I don't believe that buildPythonPackage co-opts for its own usage.

pname = "plover-with-plugins";
propagatedBuildInputs = old.propagatedBuildInputs ++ [ plugins-manager ];

# the plugin manager installs plugins as local python packages
permitUserSite = true;
});
}
22 changes: 22 additions & 0 deletions pkgs/applications/misc/plover/plugins_manager.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/plover_plugins_manager/__main__.py b/plover_plugins_manager/__main__.py
index 9e03097..6204472 100644
--- a/plover_plugins_manager/__main__.py
+++ b/plover_plugins_manager/__main__.py
@@ -42,16 +42,7 @@ def pip(args, stdin=None, stdout=None, stderr=None, **kwargs):
'plover_plugins_manager.pip_wrapper',
'--disable-pip-version-check']
env = dict(os.environ)
- # Make sure user plugins are handled
- # even if user site is not enabled.
- if not running_under_virtualenv() and not site.ENABLE_USER_SITE:
- pypath = env.get('PYTHONPATH')
- if pypath is None:
- pypath = []
- else:
- pypath = pypath.split(os.pathsep)
- pypath.insert(0, site.USER_SITE)
- env['PYTHONPATH'] = os.pathsep.join(pypath)
+ env['PYTHONPATH'] = os.pathsep.join(sys.path + [site.USER_SITE])
command = args.pop(0)
if command == 'check':
cmd.append('check')
33 changes: 33 additions & 0 deletions pkgs/development/python-modules/requests-futures/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, requests
, pythonOlder
}:

buildPythonPackage rec {
pname = "requests-futures";
version = "0.9.9-27-gf126048";
Copy link
Member

Choose a reason for hiding this comment

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

From where did you get the version number?

Copy link
Member Author

@evils evils Jun 1, 2021

Choose a reason for hiding this comment

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

git describe --tags minus the leading v

disabled = pythonOlder "3.3";

src = fetchFromGitHub {
owner = "ross";
repo = "requests-futures";
rev = "f12604869b80c730192a84403f8a9b513c3f2520";
sha256 = "0a2n4gxpv7wlp7wxjppnigbwvc36zjam97xdzk1g8xg43jb6pjhd";
};

propagatedBuildInputs = [ requests ];

# tests try to access network
doCheck = false;

pythonImportsCheck = [ "requests_futures" ];

meta = with lib; {
description = "Asynchronous Python HTTP Requests for Humans using Futures";
homepage = "https://github.com/ross/requests-futures";
license = licenses.asl20;
maintainers = with maintainers; [ evils ];
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7354,6 +7354,8 @@ in {

requests-cache = callPackage ../development/python-modules/requests-cache { };

requests-futures = callPackage ../development/python-modules/requests-futures { };

requests-hawk = callPackage ../development/python-modules/requests-hawk { };

requests = callPackage ../development/python-modules/requests { };
Expand Down