%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/nix.pyc

�
���^c@@sdZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlmZej
e�Zd�Zd�Zd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zeed�Zd�Zd�ZdS(u�
Work with Nix packages
======================

.. versionadded:: 2017.7.0

Does not require the machine to be Nixos, just have Nix installed and available
to use for the user running this command. Their profile must be located in
their home, under ``$HOME/.nix-profile/``, and the nix store, unless specially
set up, should be in ``/nix``. To easily use this with multiple users or a root
user, set up the `nix-daemon`_.

This module exposes most of the common nix operations. Currently not meant to be run as a ``pkg`` module, but explicitly as ``nix.*``.

For more information on nix, see the `nix documentation`_.

.. _`nix documentation`: https://nixos.org/nix/manual/
.. _`nix-daemon`: https://nixos.org/nix/manual/#ssec-multi-user
i(tabsolute_importtprint_functiontunicode_literalsN(tzipcC@s�tjjtjjdjtd��d�}tjjjtjj|d��rztjjjtjj|d��rzt	St
dfSdS(u6
    This only works if we have access to nix-env
    u~{0}uuseru.nix-profile/bin/unix-envunix-collect-garbageu]The `nix` binaries required cannot be found or are not installed. (`nix-store` and `nix-env`)N(tostpathtjoint
expandusertformatt__opts__tsalttutilstwhichtTruetFalse(tnixhome((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt__virtual__$s.HcC@s4td|ditjjdjtd��d6�S(uJ
    Just a convenience function for ``__salt__['cmd.run_all'](cmd)``
    ucmd.run_alltenvu~{0}uuseruHOME(t__salt__RRRRR	(tcmd((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt_run/scC@sDtjjtjjdjtd��d�}tjj|d�gS(u�
    nix-env with quiet option. By default, nix is extremely verbose and prints the build log of every package to stderr. This tells nix to
    only show changes.
    u~{0}uuseru.nix-profile/bin/unix-env(RRRRRR	(R((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt_nix_env6s.cC@sDtjjtjjdjtd��d�}tjj|d�gS(u4
    Make sure we get the right nix-store, too.
    u~{0}uuseru.nix-profile/bin/unix-collect-garbage(RRRRRR	(R((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt_nix_collect_garbage?s.cC@st�}|jd�|S(u�
    nix-env with quiet option. By default, nix is extremely verbose and prints the build log of every package to stderr. This tells nix to
    only show changes.
    u--no-build-output(Rtappend(tp((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt	_quietnixGs	
cC@s"tjjttj|�|��S(uH
    intersperse x into ys, with an extra element at the beginning.
    (t	itertoolstchaint
from_iterableRtrepeat(txtys((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt_zip_flattenQs	cC@s0g|D]%}|j|�r|j�d^qS(u�
    gets a list of all the packages that were affected by ``operation``, splits it up (there can be multiple packages on a line), and then
    flattens that list. We make it to a list for easier parsing.
    i(t
startswithtsplit(toutt	operationts((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt_output_formatYs
cC@s
|jd�S(u7
    split the ``upgrade`` responses on ``' to '``
    u to (R"(R%((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt_format_upgradecscC@s
|jd�S(u]
    nix likes to quote itself in a backtick and a single quote. This just strips those.
    u'`(tstrip(R%((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt
_strip_quotesjscG@s�t�}|jd�|j|�t|�}g|dj�D]1}|jd�r@t|jdd�d�^q@}g|D]%}g|D]}t|�^q�^q~S(u�
    Runs an update operation on the specified packages, or all packages if none is specified.

    :type pkgs: list(str)
    :param pkgs:
        List of packages to update

    :return: The upgraded packages. Example element: ``['libxslt-1.1.0', 'libxslt-1.1.10']``
    :rtype: list(tuple(str, str))

    .. code-block:: bash

        salt '*' nix.update
        salt '*' nix.update pkgs=one,two
    u	--upgradeustderru	upgradingtmaxspliti(	RRtextendRt
splitlinesR!R'R"R)(tpkgsRR#R%tupgradests_((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pytupgradeqs	

1cO@s�|jdt�}|sdSt�}|jd�|jdt�r]|jtd|��n
|j|�t|�}ttj	j
g|dj�D]%}|jd�r�|j
�d^q���}g|D]}t|�^q�S(u�
    Installs a single or multiple packages via nix

    :type pkgs: list(str)
    :param pkgs:
        packages to update
    :param bool attributes:
        Pass the list of packages or single package as attribues, not package names.
        default: False

    :return: Installed packages. Example element: ``gcc-3.3.2``
    :rtype: list(str)

    .. code-block:: bash

        salt '*' nix.install package [package2 ...]
        salt '*' nix.install attributes=True attr.name [attr.name2 ...]
    u
attributesu.Plese specify a package or packages to upgradeu	--installu--attrustderru
installingi(tgetRRRR+R RtlistRRRR,R!R"R)(R-tkwargst
attributesRR#R%tinstalls((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pytinstall�s	

+cC@s�t�}|jd�|r,|jd�n|sX|jd�|rX|jd�qXnt|�}gtjjj|dd�D]}|j�^q�S(uP
    Lists installed packages. Due to how nix works, it defaults to just doing a ``nix-env -q``.

    :param bool installed:
        list only installed packages. This can be a very long list (12,000+ elements), so caution is advised.
        Default: True

    :param bool attributes:
        show the attributes of the packages when listing all packages.
        Default: True

    :return: Packages installed or available, along with their attributes.
    :rtype: list(list(str))

    .. code-block:: bash

        salt '*' nix.list_pkgs
        salt '*' nix.list_pkgs installed=False
    u--queryu--installedu--availableu--attr-pathustdoutu
(RRRR
RRR"(t	installedR4RR#R%((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt	list_pkgs�s	

cG@s�t�}|jd�|j|�t|�}|dj�df}g|dj�D]+}|jd�rVt|j�d�^qVS(u
    Erases a package from the current nix profile. Nix uninstalls work differently than other package managers, and the symlinks in the
    profile are removed, while the actual package remains. There is also a ``nix.purge`` function, to clear the package cache of unused
    packages.

    :type pkgs: list(str)
    :param pkgs:
        List, single package to uninstall

    :return: Packages that have been uninstalled
    :rtype: list(str)

    .. code-block:: bash

        salt '*' nix.uninstall pkg1 [pkg2 ...]
    u--uninstallustderruuninstallingi(RRR+RR,R!R)R"(R-RR#tfmtoutR%((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt	uninstall�s	

cC@s0t�}|jd�t|�}|dj�S(u�
    Completely removed all currently 'uninstalled' packages in the nix store.

    Tells the user how many store paths were removed and how much space was freed.

    :return: How much space was freed and how many derivations were removed
    :rtype: str

    .. warning::
       This is a destructive action on the nix store.

    .. code-block:: bash

        salt '*' nix.collect_garbage
    u--delete-oldustdout(RRRR,(RR#((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pytcollect_garbages	
(t__doc__t
__future__RRRtloggingRRtsalt.utils.itertoolsR
tsalt.utils.pathtsalt.ext.six.movesRt	getLoggert__name__tloggerRRRRRR R&R'R)R0R6R
R8R:R;(((s4/usr/lib/python2.7/site-packages/salt/modules/nix.pyt<module>s.						
		
				+,	

Zerion Mini Shell 1.0