salt.modules.nixpkg#
Work with Nix packages#
New in version 3008.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 is compatible with the pkg state, so you can use it with
pkg.installed, pkg.removed, pkg.latest, etc.
For more information on nix, see the nix documentation.
- salt.modules.nixpkg.available_version(*names, **kwargs)#
This function is an alias of
latest_version.Return the latest version of the named package available for upgrade or installation.
Since Nix doesn't have a simple way to query the latest available version without performing a search, this queries
nix searchfor each package.If the latest version of a given package is already installed, an empty string will be returned for that package.
CLI Example:
salt '*' pkg.latest_version <package name> salt '*' pkg.latest_version <package1> <package2> ...
- salt.modules.nixpkg.collect_garbage()#
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.
- Returns:
How much space was freed and how many derivations were removed
- Return type:
Warning
This is a destructive action on the nix store.
CLI Example:
salt '*' pkg.collect_garbage
- salt.modules.nixpkg.install(name=None, pkgs=None, **kwargs)#
Installs a single or multiple packages via nix profile
- Parameters:
- Returns:
Installed packages. Example element:
gcc-3.3.2- Return type:
CLI Example:
salt '*' pkg.install vim salt '*' pkg.install pkgs='[vim, git]'
- salt.modules.nixpkg.latest_version(*names, **kwargs)#
Return the latest version of the named package available for upgrade or installation.
Since Nix doesn't have a simple way to query the latest available version without performing a search, this queries
nix searchfor each package.If the latest version of a given package is already installed, an empty string will be returned for that package.
CLI Example:
salt '*' pkg.latest_version <package name> salt '*' pkg.latest_version <package1> <package2> ...
- salt.modules.nixpkg.list_pkgs(versions_as_list=False, **kwargs)#
Lists installed packages.
- Parameters:
versions_as_list (bool) -- returns versions as lists, not strings. Default: False
- Returns:
Packages installed or available, along with their attributes.
- Return type:
CLI Example:
salt '*' pkg.list_pkgs salt '*' pkg.list_pkgs versions_as_list=True
- salt.modules.nixpkg.list_upgrades(refresh=True, **kwargs)#
List all available package upgrades.
CLI Example:
salt '*' pkg.list_upgrades
- salt.modules.nixpkg.refresh_db(**kwargs)#
Nix doesn't have a traditional package database to refresh, but this updates the flake registry / channel.
CLI Example:
salt '*' pkg.refresh_db
- salt.modules.nixpkg.remove(name=None, pkgs=None, **kwargs)#
Removes packages with
nix profile remove.- Parameters:
- Returns:
A dict containing the changes
CLI Example:
salt '*' pkg.remove vim salt '*' pkg.remove pkgs='[vim, git]'
- salt.modules.nixpkg.uninstall(*pkgs)#
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
pkg.purgefunction, to clear the package cache of unused packages.- Parameters:
- Returns:
Packages that have been uninstalled
- Return type:
CLI Example:
salt '*' pkg.uninstall vim salt '*' pkg.uninstall vim git
- salt.modules.nixpkg.upgrade(*pkgs, **kwargs)#
Runs an update operation on the specified packages, or all packages if none is specified.
- Parameters:
- Returns:
The upgraded packages. Example element:
['libxslt-1.1.0', 'libxslt-1.1.10']- Return type:
CLI Example:
salt '*' pkg.upgrade salt '*' pkg.upgrade pkgs=one,two
- salt.modules.nixpkg.version(*names, **kwargs)#
Returns a string representing the package version or an empty string if not installed. If more than one package name is specified, a dict of name/version pairs is returned.
CLI Example:
salt '*' pkg.version <package name> salt '*' pkg.version <package1> <package2> <package3> ...