π§ββοΈ Intro to Nix & NixOS β A Developer's Guide
π§ What is Nix?β
Nix is a powerful, declarative, and reproducible package manager that isolates dependencies and environments.
Itβs like:
brew
+docker
+asdf
+git
β all rolled into one.- A package manager that lets you declare your entire dev environment as code.
- A system that avoids "it works on my machine" bugs forever.
π§ What is NixOS?β
NixOS is a Linux distro built entirely with Nix. Every part of the system β packages, services, even the kernel β is declarative and reproducible.
While NixOS is amazing, you do NOT need to use NixOS to use Nix. It works on macOS, Debian, Ubuntu, etc.
π Quickstartβ
1. Install Nix (single-user mode)β
curl -L https://nixos.org/nix/install | sh
Then restart your terminal or source the profile:
. ~/.nix-profile/etc/profile.d/nix.sh
π On macOS with M1/M2: use
nix-darwin
or homebrew + Rosetta compat mode.
2. Clone the Project and Open a Dev Shellβ
git clone https://github.com/your/repo.git
cd repo
nix develop
This drops you into a shell with all the tools you need: Node, Python, Neovim, etc.
π§© Example: flake.nix
β
Hereβs a ready-to-use flake.nix
file you can add to any project:
{
description = "A reproducible dev environment with Nix";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in {
devShells.default = pkgs.mkShell {
name = "dev-env";
buildInputs = [
pkgs.git
pkgs.nodejs
pkgs.python3
pkgs.neovim
pkgs.jq
pkgs.curl
pkgs.htop
pkgs.fzf
pkgs.ripgrep
pkgs.fd
pkgs.bat
pkgs.zsh
pkgs.gcc
pkgs.clang
pkgs.make
];
shellHook = ''
echo "π§ Welcome to your Nixified dev shell"
export PATH=$PATH:~/.npm-global/bin
'';
};
});
}
π What Can You Use Nix For?β
Use Case | Nix Advantage |
---|---|
Dev environment setup | Reproducible, fast onboarding |
CI pipelines | Clean, cacheable, deterministic |
Multi-version language support | Isolated, conflict-free |
Dotfile & tooling bootstraps | Declarative, shareable |
Container image building | Nix β Docker or OCI image support |
System config (via NixOS) | Full-system version control |
π§ββοΈ Real-World Dev Flowβ
nix develop # Drops you into your dev shell
nix flake check # Validates flake setup
nix build # Build project artifacts with reproducibility
π¦ P6M Nix Channelsβ
The P6M platform provides pre-built Nix channels for easy access to our tools and packages:
Archetect Channelβ
# Add the Archetect channel
nix-channel --add https://developer.p6m.dev/channels/archetect/ archetect
nix-channel --update
# Install Archetect
nix-env -iA archetect.archetect
P6M Platform Toolsβ
# Add the P6M channel
nix-channel --add https://developer.p6m.dev/channels/p6m/ p6m
nix-channel --update
# Install P6M CLI tools
nix-env -iA p6m.p6m-cli
Using in Flakesβ
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
p6m.url = "https://developer.p6m.dev/channels/p6m/nixexprs.tar.xz";
archetect.url = "https://developer.p6m.dev/channels/archetect/nixexprs.tar.xz";
};
outputs = { nixpkgs, p6m, archetect, ... }: {
devShells.default = nixpkgs.legacyPackages.x86_64-linux.mkShell {
buildInputs = [
p6m.packages.x86_64-linux.p6m-cli
archetect.packages.x86_64-linux.archetect
];
};
};
}
π§ Pro Tipsβ
- Use
direnv
withuse flake
for auto-loading shells - Use
lorri
for auto dev-env reloads - Use
nix fmt
to formatflake.nix
π¬ Resourcesβ
- π Official Nix Manual
- π§΅ Zero to Nix
- π§ Awesome Nix
- π§ Learn X in Y: Nix
π§ͺ "Nix doesnβt install tools. It summons them."
β Everyone whoβs used it more than twice