Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Nix: Difference between revisions

From Nest Guides
Add Nix stub
 
Overhauled with more instructions
Line 1: Line 1:
This article is a [[wikipedia:Wikipedia:Stub|stub]]. Please help expand it.
This article is a [[wikipedia:Wikipedia:Stub|stub]]. Please help expand it.
 
Nix is a package manager which is used on nest to allow users to install packages without the need of apt, which requires [[wikipedia:Sudo|sudo]] (Superuser Do) permissions. It's normally used to make reproducible developer and production environments with just one file!
Nix is a package manager which is used on nest to allow users to install packages without the need of apt, which requires [[wikipedia:Sudo|sudo]] (Superuser Do) permissions. It's normally used to make reproducible developer and production environments with just one file! What is great about nix, compared to pacman (Arch), or apt (Debian/Ubuntu), is that you can have multiple versions of a package installed on the nest server because it's on the user-level. This means one user could have Node.js 18, another 20, etc.
 
==== Installing a package ====
=== Nix Environment (persistent) ===
 
You can install things just like apt permanently using nix! This means even if you reboot or log off, the package will stay with your user account. You can run <code>nix-env -f '<nixpkgs>' -iA <package></code> to install packages.
Normally, people use <code>nix-env -i <package></code>, but that is slow and takes up a lot of memory. Please instead use: <syntaxhighlight lang="bash">
nix shell nixpkgs#package</syntaxhighlight>
=== Nix shells (temporary) ===
 
Let's talk about nix shells! You can spawn a new shell with the packages so you can try out packages, and when you close out the shell, all of those packages will be gone! For example, you can run <code>nix shell nixpkgs#package nixpkgs#package</code> (replacing "package" with the packages you want) to spin up a new shell with those packages.
==== Searching for a package ====
Once you're done, exit out using the <code>exit</code> command.
=== Removing a package ===
You can remove a package just by running <code>nix profile remove <package></code>
=== Searching for a package ===
You can also search for the package you want [https://search.nixos.org/packages online] or by running <code>nix search nixpkgs <package></code>. It appears to use a lot of memory running it from the command line so it's recommended that you use the online version instead.
You can also search for the package you want [https://search.nixos.org/packages online] or by running <code>nix search nixpkgs <package></code>. It appears to use a lot of memory running it from the command line so it's recommended that you use the online version instead.
==== Make an empty shell ====
Sometimes you just need a blank slate with packages just for testing that you don't want to install to your main shell. Just run <code>nix-shell -p <package> <package> <package></code> with the package(s) you want. When you close out the shell, all of those packages will be gone.

Revision as of 17:44, 27 March 2024

This article is a stub. Please help expand it.

Nix is a package manager which is used on nest to allow users to install packages without the need of apt, which requires sudo (Superuser Do) permissions. It's normally used to make reproducible developer and production environments with just one file! What is great about nix, compared to pacman (Arch), or apt (Debian/Ubuntu), is that you can have multiple versions of a package installed on the nest server because it's on the user-level. This means one user could have Node.js 18, another 20, etc.

Nix Environment (persistent)

You can install things just like apt permanently using nix! This means even if you reboot or log off, the package will stay with your user account. You can run nix-env -f '<nixpkgs>' -iA <package> to install packages.

Nix shells (temporary)

Let's talk about nix shells! You can spawn a new shell with the packages so you can try out packages, and when you close out the shell, all of those packages will be gone! For example, you can run nix shell nixpkgs#package nixpkgs#package (replacing "package" with the packages you want) to spin up a new shell with those packages.

Once you're done, exit out using the exit command.

Removing a package

You can remove a package just by running nix profile remove <package>

Searching for a package

You can also search for the package you want online or by running nix search nixpkgs <package>. It appears to use a lot of memory running it from the command line so it's recommended that you use the online version instead.