Home >System Tutorial >LINUX >How To Install Nix Package Manager In Linux

How To Install Nix Package Manager In Linux

Joseph Gordon-Levitt
Joseph Gordon-LevittOriginal
2025-03-19 09:18:10654browse

This tutorial guides you through installing the powerful Nix package manager on your Linux system. Nix offers reliable installations, easy rollbacks, and simplifies software management, making it ideal for developers and system administrators. This guide uses Ubuntu as an example, but the steps are largely the same for other Linux distributions.

Installing Nix Package Manager

Nix installation is straightforward. The developers recommend a multi-user installation where possible.

  1. Download and Run the Installer: Begin by downloading and executing the Nix installation script:
curl -L https://nixos.org/nix/install | sh

This will automatically detect your system and initiate the appropriate installation (multi-user by default on systems like Ubuntu with systemd and without SELinux, otherwise single-user).

  1. Specify Installation Type (Optional): You can explicitly choose between single-user and multi-user installations:
  • Single-user: curl -L https://nixos.org/nix/install | sh -s -- --no-daemon
  • Multi-user: curl -L https://nixos.org/nix/install | sh -s -- --daemon
  1. Multi-user Installation Details (If prompted): The multi-user installer will display a summary of actions. Type y to see a detailed list or n to proceed directly. You'll be asked to confirm various steps, including user and group creation and service configuration.

  2. Sudo Authorization: The installer will request sudo access. Type y and enter your password when prompted.

  3. Existing Installation Check: The installer will check for pre-existing Nix installations. Confirm with y to continue.

  4. Password Entry: Provide your sudo password when requested to complete the installation process.

  5. Installation Completion: A success message will appear, indicating that Nix is installed. You may need to restart your terminal or log out and back in for the changes to take effect. For single-user installations, you might need to source a specific script (e.g., source $HOME/.nix-profile/etc/profile.d/nix.sh).

How To Install Nix Package Manager In Linux How To Install Nix Package Manager In Linux How To Install Nix Package Manager In Linux How To Install Nix Package Manager In Linux How To Install Nix Package Manager In Linux How To Install Nix Package Manager In Linux

Verifying the Installation

To confirm a successful installation, open a new terminal and run:

nix-shell -p nix-info --run "nix-info -m"

This will display system information, including the Nix version. Alternatively, use nix --version to check only the version number.

How To Install Nix Package Manager In Linux

Getting Started and Uninstallation

Further instructions on using Nix are available in the original article's "Getting Started with Nix" section. The "Uninstall Nix" section provides detailed uninstallation instructions for both single-user and multi-user setups. Remember to carefully follow the steps for a clean removal.

The above is the detailed content of How To Install Nix Package Manager In Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn