Skip to content

[RFC] Proposal: Engineering a Common "Plugin" Infrastructure #59344

Open

Description

@deliciouslytyped

Edit: It may be easier to start by looking at https://discourse.nixos.org/t/wip-rfc-a-new-nixpkgs-frontend-for-language-infrastructures/3447
Edit: I made a WIP PoC library https://github.com/deliciouslytyped/nix-rootedoverlay/ , it still needs a lot of work but seems to be functional.
Edit: Help wanted: someone to hand-hold me through the fixpoint stuff needed for overrides in this infrastructure I think I figured it out.

There are various separate, probably incompatible implementations of plugin infrastructure across nixpkgs, examples being at least:

(NOT REVIEWED indicates the author is tentatively aware of a plugin system but has not inspected the implementation)

  • TODO, list here
  • a not-yet-upstreamed implementation for Ghidra cannibalized from Idris
  • NOT REVIEWED: Idris (see above)
  • NOT REVIEWED: firefox / other mozilla software
  • NOT REVIEWED: Eclipse
  • package managers of interpreted languages (TODO: any 'sub'-package manager?)
    • NOT REVIEWED: python packages
    • NOT REVIEWED: ruby
  • NOT REVIEWED: Jekyll
  • NOT REVIEWED: redmine
  • NOT REVIEWED: perl perl: add .withPackages #59215
  • HYPOTHETICAL wine package management
  • NOT REVIEWED retroarch
  • NOT REVIEWED gnome-shell
  • NOT REVIEWED terraform (was suggested for it's simplicity)
  • NOT REVIEWED r/rstudio/rwrapper/rpackages
  • NOT REVIEWED llvmPackages
    No implementation:
  • jenkins (?)

CONSIDER: asking maintainers of the various systems for input

The more advanced implementations usually (TODO: substantiate this) use some kind of fix-point mechanism which can be quite hard to understand.

Would it be possible and reasonable to factor out a plugin handling API that can be specialized to various desired implementations, such that the internal mechanisms do not need to be understood by the user? This could also result in the overall simplification of these components of nixpkgs.

A generic plugin system should:

  • provide one or more (possibly extensible) methods of applying plugins to a package:
    • feeding plugins back into the original derivation, e.g.
      {..., plugins ? ... }: mkDerivation ...
    • merging base and plugin derivations via something like symlinkJoin.
      This has the advantage of being faster and less wasteful than rebuilding the base package, but may fail with improper symlink handling? This also may have other failure modes such as runner makeWrapper scripts referring to the original derivation, resulting in the plugins being ignored because they are in a new derivation. (TODO: elaborate on this, this is an issue I ran into.)
    • ...other...?
  • provide the ability to have in-tree (nixpkgs) plugins
  • provide the ability to have out-of-tree plugins via overrides, overlays, or some similar mechanism
  • ...other...?

Pending questions:

Activity

  1. deliciouslytyped commented on Apr 12, 2019

    @deliciouslytyped
    ContributorAuthor

    If a desirable solution already exists, then other plugin systems listed in the (TODO) aggregation should be migrated to it.

  2. changed the title [-]Proposal: Engineering a Common Plugin Infrastructure[/-] [+]Proposal: Engineering a Common "Plugin" Infrastructure[/+] on Apr 12, 2019
  3. deliciouslytyped commented on Apr 12, 2019

    @deliciouslytyped
    ContributorAuthor

    This post: syntax/semantics/ergonomics

    I quite like the rootPackage.withPackages (p: with p; [ a b c ]) pattern.

    Under what circumstances should it be considered meaningful to include non-child packages of the rootPackage in the list? Are there conditions where it's useful to pass in external packages? Say, something like python37.withPackages (p: [ pkgs.hello ]), or should the intended result of such a thing be achieved some other way?
    Edit: a use case may be hybrid environments like interfacing between Python and R?

    This should not be the same as accepting out-of-tree plugins; I think it would be reasonable to accept something like functions in the plugin list, where during evaluation the root package is applied to the plugins if necessary, and passed on to another builder (or some similar approach).
    This is done in my current implementation of ghidra plugins because they need access to a build script located in the root package. (TODO substantiating example)

    Alternatively, external overrides should be applied strictly through some pattern like the following:
    (rootPackage.overridePackages { d = parent: ...; }).withPackages (p: with p; [ a b c d ])
    The parent: parameter may lead to infinite recursion with improper use? (This is the kind of thing that might be useful to mention in API docs, if it's not possible to reasonably prevent altogether)
    Though I find the parenthesization a bit awkward.

  4. deliciouslytyped commented on Apr 12, 2019

    @deliciouslytyped
    ContributorAuthor

    Per suggestions I have attempted to explore makeScope/newScope/... , but I haven't been able to understand them yet enough to get them to work right. My current understanding is that would at least cover my minimum desired functionality for providing overrides.

  5. joepie91 commented on Apr 16, 2019

    @joepie91

    Some quick additional notes before I forget, though I don't have much time to elaborate right now:

    • Mods for games are also plugins, not sure whether those require special handling.
    • There's currently a disconnect in cases where plugins can be managed from within the application as well as from Nix configuration; there should probably be some sort of way to reconcile that, though it may involve extra tooling.
    • PlatformIO orchestrates a bunch of different tools for interacting with different embedded devices and architectures; it currently downloads those on runtime. Not sure if that would fall under the conceptual meaning of 'plugins' here.
  6. joepie91 commented on Apr 16, 2019

    @joepie91

    More: Jekyll has plugins, if I recall correctly.

  7. deliciouslytyped commented on Apr 18, 2019

    @deliciouslytyped
    ContributorAuthor

    @joepie91
    To address your points in some order:

    2 )
    The application managed plugins problem is something that has bothered me for a while and I'm not sure what to do about it.

    My knee-jerk reaction is that applications need to support application-external plugin/setting management if we don't want strange things to happen? The reason I mention settings management, is because that's usually how plugins get added to the "current set of running plugins", right? My mental model is currently based off of firefox - for which I'm not sure of the details (but there's this mess of notes nix-community/home-manager#606 ) - which is to say, I think (?) I'm agreeing with you.

    1 )
    I don't see yet why game mods are special? I'm imagining that specific installation functionality would be handled by domain specific handlers anyway. Application specific hooks.

    3 )
    I will talk to you about this on IRC and update this post.

    @eighal yeah I'm inclined to think so. My current heuristic for "plugins" is whether there is some central thing that needs to have plugins fed back into it, that being the interpreter/'s package environment.
    But maybe I'm going about this from the wrong direction. Instead of thinking about plugins, maybe we should be thinking about "things that have a domain specific set of 'sub'packages, that must be fed-back the packages"? I wouldn't be surprised if this basically reduces to the thing going on with the fixpoint stuff.

    Misc:
    added ruby and jekyll to tentative list.

    Edit:
    Just a subpackageset is easy to make, it gets hairy with this fixpoint stuff which is needed for overrides.

  8. deliciouslytyped commented on Apr 18, 2019

    @deliciouslytyped
    ContributorAuthor

    TL;DR: if it has something that looks like a .withPackages (p: ...), or looks like it would want a .withPackages (p: ...) then at least that is relevant.

  9. aanderse commented on Apr 18, 2019

    @aanderse
    Member

    The redmine service has plugins and themes. This is currently not implemented well.

  10. coreyoconnor commented on Apr 20, 2019

    @coreyoconnor
    Contributor

    Projects with internal package managers for handling plugins I've worked with: jenkins, retroarch, gnome-shell. These all can download their own plugins/extensions which, sometimes, works. Other times there are requirements to the .so/.jar/.js that are not part of the provided environment. Hence: those need to be built via nix and, preferably, block the installation of built artifacts dynamically.

    As @deliciouslytyped mentions: applications themselves need some consideration to prevent bad things happening.

    EG: in retroarch an update for bundled core can be requested but will fail with an odd error as that .so is RO.

  11. coreyoconnor commented on Apr 21, 2019

    @coreyoconnor
    Contributor

    I noticed the question mark next to jenkins and decided to dig in a bit mroe.

    • The relevant code is at nixos/modules/services/continuous-integration/jenkins/default.nix
    • the tool referenced jenkinsPlugins2nix does not (afaict) build the plugin. Only packages a pre-built plugin.
    • only runtime dependencies would impact actually using the plugin
    • jenkins itself is not built by nix but only packaged

    I agree this puts jenkins in a different group than the above.

  12. joepie91 commented on Apr 21, 2019

    @joepie91

    Addition: KDE has a plugin manager as well, for "plasma widgets" and such, I believe.

    Edit: and Thunar has file manager plugins too, though no interactive manager I think - the Thunar package in nixpkgs also already has a plugins option.

  13. deliciouslytyped commented on Apr 21, 2019

    @deliciouslytyped
    ContributorAuthor

    @coreyoconnor The reason I "separated" it was because on a cursory look I didn't see an implementation of handling plugins - hence: "No implementation". If it had an implementation I would have listed it under the rest. (This is just a comment on that and not really addressing anything else.)

    Edit: which is to say, it has plugins, there is just no implementation of handling them in nixpkgs. Though now that I think about it, the list might get really long if we start considering everything everywhere that takes plugins. :P - which doesn't mean that I think we shouldn't consider everything. However, I guess after the first 20 or 30 examples it will be time to start trying to figure out archetypes.

  14. deliciouslytyped commented on Apr 22, 2019

    @deliciouslytyped
    ContributorAuthor

    I'm currently poking around overlays and...that stuff. Still trying to figure out how it works.
    I spent the day prototyping stuff with a type system but I'm not quite at the goal of the previously mentioned syntax I want yet...

    https://www.youtube.com/watch?v=W85mF1zWA2o (@nbp NixCon talk on overlays) is helpful.

  15. 18 remaining items

  16. deliciouslytyped commented on Aug 7, 2019

    @deliciouslytyped
    ContributorAuthor
  17. deliciouslytyped commented on Aug 11, 2019

    @deliciouslytyped
    ContributorAuthor

    It seems like a good idea to read through and steal some ideas from https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md , there appear to have been developments since I last read it. (edit: it's more likely that I just didn't notice a bunch of things...)

  18. deliciouslytyped commented on Aug 26, 2019

    @deliciouslytyped
    ContributorAuthor
  19. deliciouslytyped commented on Jun 9, 2020

    @deliciouslytyped
    ContributorAuthor

    TODO: look at whats going on in #53834 (comment)

  20. stale commented on Dec 6, 2020

    @stale

    I marked this as stale due to inactivity. → More info

  21. added
    2.status: stale
    on Dec 6, 2020
  22. toraritte commented on Nov 6, 2021

    @toraritte
    Contributor

    This discussion seems very relevant: Status of lang2nix approaches

  23. removed
    2.status: stale
    on Nov 6, 2021
  24. deliciouslytyped commented on Nov 7, 2021

    @deliciouslytyped
    ContributorAuthor

    If that's relevant, the dream2nix project may be as well.

  25. added
    2.status: stale
    on Jul 3, 2025
  26. added
    0.kind: enhancement
    6.topic: user experience
    9.needs: community feedback
    6.topic: developer experience
    on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: enhancement2.status: stale6.topic: developer experience6.topic: user experience9.needs: community feedback

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions