Skip to content

Commit 836dfda

Browse files
committed
Added a section regarding --plugin
1 parent 6d10421 commit 836dfda

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

docs/archinstall/plugins.rst

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.. _archinstall.Plugins:
2+
3+
Python Plugins
4+
==============
5+
6+
``archinstall`` supports plugins via two methods.
7+
8+
First method is directly via the ``--plugin`` parameter when running as a CLI tool. This will load a specific plugin locally or remotely via a path.
9+
10+
The second method is via Python's built in `plugin discovery`_ using `entry points`_ categorized as ``archinstall.plugin``.
11+
12+
``--plugin`` parameter
13+
----------------------
14+
15+
The parameter has the benefit of being stored in the ``--conf`` state, meaning when re-running an installation — the plugin will automatically be loaded.
16+
It's limitation is that it requires an initial path to be known and written and be cumbersome.
17+
18+
Plugin Discovery
19+
----------------
20+
21+
This method allows for multiple plugins to be loaded with the drawback that they have to be installed beforehand on the system running ``archinstall``.
22+
This mainly targets those who build their own ISO's and package specific setups for their needs.
23+
24+
25+
What's supported?
26+
-----------------
27+
28+
Currently the documentation for this is scarse. Until that is resolved, the best way to find supported features is to search the source code for `plugin.on_ <https://github.com/search?q=repo%3Aarchlinux%2Farchinstall+%22plugin.on_%22&type=code>`_ as this will give a clear indication of which calls are made to plugins.
29+
30+
How does it work?
31+
-----------------
32+
33+
``archinstall`` plugins use a discovery-driven approach where plugins are queried for certain functions.
34+
As an example, if a plugin has the following function:
35+
36+
.. code-block:: python
37+
38+
def on_pacstrap(*packages):
39+
...
40+
41+
The function :code:`archinstall.Pacman().strap(["some packages"])` is hardcoded to iterate plugins and look for :code:`on_pacstrap` in the plugin.
42+
If the function exists, :code:`.strap()` will call the plugin's function and replace the initial package list with the result from the plugin.
43+
44+
The best way to document these calls is currently undecided, as it's hard to document this behavior dynamically.
45+
46+
47+
.. _plugin discovery: https://packaging.python.org/en/latest/specifications/entry-points/
48+
.. _entry points: https://docs.python.org/3/library/importlib.metadata.html#entry-points

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Some of the features of Archinstall are:
3434

3535
installing/python
3636
examples/python
37+
archinstall/plugins
3738

3839
.. toctree::
3940
:maxdepth: 3

0 commit comments

Comments
 (0)