Merge remote-tracking branch 'origin/main'

This commit is contained in:
a 2024-06-15 22:14:32 +02:00
commit de50a09a6c
7 changed files with 60 additions and 39 deletions

View file

@ -201,7 +201,7 @@ The problem might be:
- Your locale is not set to utf-8, to check this you can set the content of the
environment variable ``LC_TYPE``
- Your locale is correctly set but **after** xonsh started. This is typically
the case if you set your ``LC_TYPE`` inside your ``.xonshrc`` and xonsh is
the case if you set your ``LC_TYPE`` inside your `xonshrc <xonshrc.rst>`_ and xonsh is
your default/login shell. To fix this you should see the documentation of your
operating system to know how to correctly setup environment variables before
the shell start (``~/.pam_environment`` for example)

View file

@ -84,7 +84,7 @@ or highlight syntax or set process title, respectively.
If it does not find ``prompt-toolkit`` package, it will
use the Python ``readline`` module (which reads configuration file ``.inputrc`` in a manner compatible with ``GNU readline``).
To ensure xonsh uses ``readline`` even if ``prompt-toolkit`` is installed, configure this in your
``.xonshrc`` file:
`xonshrc <xonshrc.rst>`_ (e.g. ``~/.xonshrc``) file:
.. code-block:: xonshcon

View file

@ -30,6 +30,36 @@ lines to your ``~/.bashrc file``:
unset module
unset scl
Use the Nix Package manager with Xonsh
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To users of the `Nix Package Manager <https://www.nixos.org/>`_ these few lines might be life-savers:
.. code-block:: xonshcon
import os.path
if os.path.exists(f"{$HOME}/.nix-profile") and not __xonsh__.env.get("NIX_PATH"):
$NIX_REMOTE="daemon"
$NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/" + $USER
$NIX_PROFILES="/nix/var/nix/profiles/default " + $HOME + "/.nix-profile"
$NIX_SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt"
$NIX_PATH="nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs:/nix/var/nix/profiles/per-user/root/channels"
$PATH += [f"{$HOME}/.nix-profile/bin", "/nix/var/nix/profiles/default/bin"]
Btw. a hacky solution to install xontribs that do not yet ship with ``nixpkgs`` is:
.. code-block:: xonshcon
for p in map(lambda s: str(s.resolve()), p"~/.local/lib/".glob("python*/site-packages")):
if p not in sys.path:
sys.path.append(p)
$PYTHONPATH = "$USER/.local/lib/python3.7/site-packages"
python -m ensurepip --user
xonsh
python -m pip install --user -U pip xontrib-z xonsh-direnv
Just run the last three lines, do not put them in your `xonshrc`!
MacOS, OSX
----------
@ -237,7 +267,7 @@ typing and avoid the ambiguity altogether:
>>> aliases['d'] = ['cmd', '/c', 'dir']
You can add aliases to your ``~/.xonshrc`` to have it always
You can add aliases to your `xonshrc <xonshrc.rst>`_ to have it always
available when xonsh starts.

View file

@ -39,7 +39,7 @@ content above into it.
Now we need to tell xonsh to use it as the history backend. To do this
we need xonsh to be able to find our file and this ``CouchDBHistory`` class.
Putting the following code into ``~/.xonshrc`` file can achieve this.
Putting the following code into `xonshrc <xonshrc.rst>`_ file can achieve this.
.. code-block:: none

View file

@ -104,12 +104,11 @@ create the layout for your xontrib package.
Loading Xontribs
================
Xontribs may be loaded in a few different ways: from the config file
(e.g. ``~/.config/xonsh/rc.xsh``), dynamically at runtime with
the ``xontrib`` command, or its Python API.
Xontribs may be loaded in a few different ways: from the `xonshrc <xonshrc.rst>`_ file
(e.g. ``~/.xonshrc``), dynamically at runtime with the ``xontrib`` command, or its Python API.
Extensions are loaded via the ``xontrib load`` command.
This command may be run from anywhere in a xonshrc file or at any point
This command may be run from anywhere in a `xonshrc <xonshrc.rst>`_ file or at any point
after xonsh has started up.
.. code-block:: xonsh

View file

@ -249,34 +249,3 @@ For a compact shell prompts, some people prefer a very condensed time format. Bu
get_shelldate.fulldate = 0
$PROMPT_FIELDS['shelldate'] = get_shelldate
Use the Nix Package manager with Xonsh
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To users of the `Nix Package Manager <https://www.nixos.org/>`_ these few lines might be life-savers:
.. code-block:: xonshcon
import os.path
if os.path.exists(f"{$HOME}/.nix-profile") and not __xonsh__.env.get("NIX_PATH"):
$NIX_REMOTE="daemon"
$NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/" + $USER
$NIX_PROFILES="/nix/var/nix/profiles/default " + $HOME + "/.nix-profile"
$NIX_SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt"
$NIX_PATH="nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs:/nix/var/nix/profiles/per-user/root/channels"
$PATH += [f"{$HOME}/.nix-profile/bin", "/nix/var/nix/profiles/default/bin"]
Btw. a hacky solution to install xontribs that do not yet ship with ``nixpkgs`` is:
.. code-block:: xonshcon
for p in map(lambda s: str(s.resolve()), p"~/.local/lib/".glob("python*/site-packages")):
if p not in sys.path:
sys.path.append(p)
$PYTHONPATH = "$USER/.local/lib/python3.7/site-packages"
python -m ensurepip --user
xonsh
python -m pip install --user -U pip xontrib-z xonsh-direnv
Just run the last three lines, do not put them in your `xonshrc`!

23
news/docs_nix.rst Normal file
View file

@ -0,0 +1,23 @@
**Added:**
* Added section "Use the Nix Package manager with Xonsh" to "Platform-specific tips and tricks".
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* <news item>
**Security:**
* <news item>