Nix (Package) 📦
A package manager that installs software in /nix/store that you can use alongside your linux distribution - Home / ChatGPT
Pick your pills –daemon/–no-daemon
Whatever the choice
- The installer require to create
/nixat root by a privileged user- it makes tools host dependant (vs One $HOME to rule them all )
The difference is that multi-user mode, there is a daemon running that take
care of managing the /nix folder, whereas there is no daemon in single user.
In both case, there is no requirement for calling nix with sudo afterward.
At this point, there is not much difference between Hombrew requirement and Nix, except that:
- homebrew is thought mono-user first - and you have to share your one user repos with others
- Nix + daemon fills like a lot less messy approach
- Nix philosphy/power is now reachable: you can start using profile like Homebrew packages and climb to Flakes latter on.
$ sh <(curl -L https://nixos.org/nix/install) --no-daemonRoot Access
--no-daemon - is quite straighforward in operation (see below).
--daemon - is more involved, since it has to setup the daemon.
Root Access Details
$ sh <(curl -L https://nixos.org/nix/install) --no-daemon
Note: a multi-user installation is possible. See https://nix.dev/manual/nix/stable/installation/installing-binary.html#multi-user-installation
performing a single-user installation of Nix...
directory /nix does not exist; creating it by running 'mkdir -m 0755 /nix && chown yves /nix' using sudo
[sudo] password for yves:
copying Nix to /nix/store................................................................
installing 'nix-2.33.1'
building '/nix/store/v3qb5sdzsj351fsia196zrsfjpz8ksd3-user-environment.drv'...
unpacking 1 channels...
modifying /home/yves/.profile...
placing /home/yves/.config/fish/conf.d/nix.fish...
Installation finished! To ensure that the necessary environment
variables are set, either log in again, or type
. /home/yves/.nix-profile/etc/profile.d/nix.fish
in your shell.Package Install
Taking zig as an example
The modern, recommended way:
✔ Enable Flakes
✔ Use nix profile for packages
✔ Use nix develop for projects (Flakes)
✔ Use Home Manager (optionally with NixOS)
✔ Avoid channels and nix-env
Using profile
This is similar to other package manager and can be thought as a replacement for brew/apt/etc… but for user only
# install package permanently to user profil
$ nix profile add nixpkgs#zig
# list installed package
$ nix profile list
# remove
$ nix profile remove zig
# upgrade
$ nix profile upgrade '.*'
# search
$ nix search nixpkgs firefoxUsing Flakes (Recommended)
Flakes are now the standard way to use Nix.
see Nix Flakes
Using nix-shell
temporary environment
This is useful if you just want to try Zig without permanently installing it
- This will drop you into a shell where zig is available.
- When you exit the shell, Zig is no longer available.
# create a temporary shell with tools
$ nix-shell -p zig
# or just run the tools
$ nix run nixpkgs#zigUsing nix-env
permanent installation for your use
This installs Zig in your user profile
This will stick with your user account.
$ nix-env -iA nixpkgs.zigUsing home-manager (optional)
Nix Home Manager is a tool in the Nix ecosystem that lets you manage your user-specific environment declaratively using Nix—similar to how NixOS manages system configuration, but applied to a user’s home directory and personal setup. - ChatGPT