Nix
nix.dev, Nix One Pager & Nix Book are great places to start learning/using Nix. How to learn Nix series is great too.
Looking into using Nix Quick Install Action in my projects. devshell, statix deploy-rs are neat.
I used Nix time article to install Nix on my mac.
Evolution of Nix is a nice historical talk on Nix.
Notes
- Nix never uses host dependencies, it always builds with exactly precise dependencies every time, and will always refer to them from then on.
- Nix lets you roll back changes atomically.
- nix-shell lets you make build environments that are totally reproducible across machines, and don’t interfere with each other. You can freely mix any number of libraries of versions or software on the same machine and they don’t conflict.
- With Ubuntu, every time you want to fix something with your car, you roll it into the garage, pop open the hood and get to work. It's intensive labour, results will vary, and undoing a change can be difficult.
- With NixOS, it's like 3D printing a new car every time. You'll design a model, press a button, and the car gets built from scratch. If you don't like it, tweak the design a bit, and print a new car. If the new car breaks, just go back to the previous known-good one, which is already in your garage. You can even take the design documents to your friend and generate an exactly identical model.
sudo
command sets the wrong$HOME
, have to usesudo -i
for nix commands that need sudo.- Nix is Turing complete language used for configuration and building packages.
- Can use nox, nix search, nix-repl, nixOS packages to search for packages.
- Think of Nix (the language) as an expression-based programming language where every program evaluates to a single (possibly complex) value; that resulting value is what is used as eg. the configuration of your system or a package, but it means that you can generate that value based on arbitrary logic and abstractions like you would with a regular programming language.
- As for domain-specific package managers, It Depends; it's possible with varying degrees of hackiness (and I definitely use eg. npm for development), but for a 'real' deployment - whether as a service on a server or as a local application - you'd want to convert your project's metadata to a Nix expression and let Nix handle the dependency management.
- Overlay adds/overrides something in the global package set.
- In general, you should only install things with nix, and not use any other package managers.
- The main idea of the Nix approach is to store software components in isolation from each other in a central component store, under path names that contain cryptographic hashes of all inputs involved in building the component, such as
/nix/store/rwmfbhb2znwp...-firefox1.0.4
. - Don't install libraries with Nix.
- Derivations are variables + build script.
- Docs are in
.xml
files in/docs
- To build derivation in nixpkgs, at root of
nixpkgs
, runnix build -f . <pkg-name>
(ienix build -f . wifi-password
) - To find out the SHA256, run
nix-prefetch-url -A <pkg-name>.src
(ienix-prefetch-url -A wifi-password.src
).nix-prefetch-url
works with GitHub. This gives you the SHA256 you can copy. - I think Nix's approach is the right way to build container images--build the image layers declaratively, reproducibly, incrementally (no, Dockerfile builds aren't incremental because dependency trees aren't linear), and without a container runtime dependency.
- Nix doesn't solve dependency resolution problems. Only pinning. There's ground to break there. Dependency management not being part of flakes is my biggest gripe with it. It would be our chance to be the once size fits all solution but we failed to deliver.
- There's a lot of unexplored potential of Nix in granular build systems and displacing systems like Bazel. If applied correctly, it lets smaller organisations get much of the benefit of Google-style monorepos but without as much maintenance overhead.
- Nix doesn't have an issue with metadata revisions: they're just another explicitly declared input to the build so they don't violate purity.
- Nix has an incredibly steep learning curve atm, but has completely eliminated entire classes of problems for me such as per-proj software deps and consistent environments, and has removed any fear of experimentation (since I can always rollback). Nothing else does this today.
- Nixpkgs overlays are monoids, where pkgs.lib.composeExtensions is the associative binary operation and (: : { }) is the identity element.
Code
# Build nix package locally.
# cd into cloned https://github.com/NixOS/nixpkgs
# Build package from default.nix inside nixpkgs. Will put result as ./result if succeeds
# i.e. nix-build -A watchexec -> will build watchexec package
nix-build -A <package>
# Install the build and put it `~/.nix-profile/bin`
nix-env -i ./result
# Garbage collect
sudo nix-collect-garbage --delete-older-than 30d
Links
- Nix Manual
- Nix Pills (Code)
- Benefits of using nix
- Nix, the purely functional build system - Great intro article.
- A Gentle Introduction to the Nix Family
- Nix: A Reproducible Setup for Linux and macOS
- hnix - Haskell re-implementation of the Nix expression language.
- Haskell & Nix
- Brian McKenna - Nix for Functional Systems
- Learning Nix by Example: Building FFmpeg 4.0
- nix-shell and Shebang Lines
- Domen Kožar, Lead DevOps, Nix workshop
- Cheap Docker images with Nix
- When to use declarative approach and when not
- example-nix - A way to develop software with Nix.
- Hercules CI - Hosted CI for building Nix projects on your infrastructure.
- Dysnomia - Tool and plug-in system that can be used to automatically deploy mutable components.
- Disnix - Nix-based distributed service deployment tool.
- NUR - Nix User Repository: User contributed nix packages.
- Eris - Binary cache for Nix.
- pypi2nix - Generate Nix expressions for Python packages.
- hnix-store - Haskell implementation of the nix store API.
- nix-cheatsheet
- Nix RFCs
- nix-linter - Linter for the Nix expression language.
- Install Nix docs by Mozilla - Pretty good.
- Nix scripts shared across IOHK projects
- niv - Painless dependencies for Nix projects.
- Cachix - Binary cache hosting for Nix. (Docs) (Docs Code) (Blog) (Public Beta)
- Alternative Haskell Infrastructure for Nixpkgs - Works by automatically translating your Cabal or Stack project and its dependencies into Nix code.
- nix-bundle - Bundle Nix derivations to run anywhere.
- crate2nix - Nix build file generator for rust crates. (Lobsters)
- lorri - nix-shell replacement for project development.
- Awesome Nix
- nixfmt - Formatter for Nix code.
- Nix for devs - Collection of recipes focused on nix-shell to make setting up project environments easy.
- nixpkgs-fmt - Nix code formatter for nixpkgs. (Web)
- Nix builder for Kubernetes
- Nixery - Provides the ability to pull ad-hoc container images from a Docker-compatible registry server. (Code) (Talk) (HN) (Nix-backed container registry)
- Nixery: Improved Layering Design (2019)
- hnix-lsp - Language Server Protocol for Nix.
- Make Nix precisely emulate gitignore
- Nixery - Container registry which transparently builds images using the Nix package manager.
- wharfix - Minimal stateless+readonly docker registry based on nix expressions. Heavily inspired by Nixery.
- Nix - A One Pager - A (more or less) one page introduction to Nix, the language.
- yants - Tiny type-checker for data in Nix, written in Nix. (HN)
- nix-shorts - Collection of short notes about Nix, down to what is immediately needed for users.
- rnix-parser - Nix parser written in Rust.
- Naersk - Nix support for building cargo crates.
- nix-diff - Explain why two Nix derivations differ.
- Optimising Docker Layers for Better Caching with Nix (2018)
- nix-du - Visualise which gc-roots to delete to free some space in your nix store.
- NixCon 2019 - Main Track
- Nix flakes (2019)
- Nix: How and Why it Works (2019)
- Nix recipes for Haskellers
- format-nix - Simple formatter for Nix using tree-sitter-nix.
- go-nix - Nix language parser and Nix-compatible file hasher in Go.
- nix-dns - Nix DSL for DNS zone files.
- Nix-based app VMs
- nix-index - Quickly locate nix packages with specific files.
- Nix-bisect - Bisect Nix Builds.
- Thoughts on Nix (2020) (Lobsters)
- I was Wrong about Nix (2020) (HN) (Lobsters)
- Grafanix - Visualize your Nix dependencies.
- What's your configuration.nix like?
- Built with Nix - Build software only once. (Code)
- How I Start: Nix (2020) (Lobsters)
- rnix-lsp - WIP Language Server for Nix.
- Language server for Nix language
- Eelco Dolstra's talks/papers (Code)
- Nix Haskell Monorepo Tutorial
- The journey of packaging a .NET app on Nix (2020)
- nixpkgs - Nix Packages collection.
- Nix IRC logs
- Nixology (2020) - Series of videos I've been releasing within Shopify to help promote and educate about Nix.
- Nix function to easily create derivations (packages) to install binaries from location
- What Is Nix (2020) (HN) (Lobsters)
- What Is Nix and Why You Should Use It (2020)
- comma - Runs software without installing it. Wraps together nix run and nix-index.
- nix-derivation - Parse and render *.drv files.
- nix-build-uncached - CI friendly wrapper around nix-build.
- nix-tests - Scratchpad for small experimental things I am doing with Nix.
- Nix Flakes, Part 1: An introduction and tutorial (2020)
- Nix Flakes, Part 1: An introduction and tutorial (Lobsters) (Lobsters 2)
- nix-overlays of Antonio Monteiro
- A Nix terminology primer by a newcomer (2020)
- Statistical Rethinking and Nix (2020)
- flake-utils - Pure Nix flake utility functions.
- nix.dev - Opinionated guide for developers wanting to get things done using the Nix ecosystem. (Code)
- Nix language antipatterns
- So, tell me about Nix (2020)
- nixdu - Interactively browse the dependency graph of your Nix derivations.
- Nix Package Versions - Search for old versions of Nix packages. (Code) (Reddit)
- Opinionated Nix repository template - Based on nix.dev tutorials, repository template to get you started with Nix.
- Tools to manage a Nix-based project
- Building static Haskell binary with Nix on Linux (2020)
- Template for NUR repositories
- Bramble - Functional build system inspired by nix. (Article) (Lobsters)
- The easiest way (I've found) to create your own Nix channel (2020)
- Nix Monorepo - How you might use Nix in a larger, multi-language project.
- A Tutorial Introduction to Nix (2020)
- nixbuild.net - Cloud service that runs your Nix builds. It takes away the effort of maintaining and scaling build clusters, and integrates easily with any setup that uses Nix. (Docs) (Tweet)
- Manix - Fast CLI documentation searcher for Nix.
- Review of home manager (2020) (Lobsters)
- Nix Quick Install Action - GitHub Action installs Nix in single-user mode, and adds almost no time at all to your workflow's running time. (Web)
- Setting up a Nix S3 binary cache (2020) (Lobsters)
- swift2nix: Run Swift inside Nix builds (2020)
- sorri - Simple, lightweight implementation of Tweag's lorri.
- Nix and the nix-shell for easily redistributable scripts (2020)
- nix-buildkite - Take a Nix job description and turn it into separate Buildkite steps with dependencies. (Tweet)
- pre-commit-hooks.nix - Seamless integration of pre-commit git hooks with Nix.
- Nix + Haskell setup
- caching your nix-shell (2020)
- nix-direnv - Fast, persistent use_nix implementation for direnv.
- NixCon 2020 (Stream) (Code) (HN)
- Nix UX improvements
- NixCon 2020 talk about Nix flakes
- Nickel - Lightweight configuration language. Its purpose is to automate the generation of static configuration files. (Nickel: better configuration for less) (First release of Nickel) (Lobsters)
- Nix-based process management framework
- Local Nix Cache - Poor and hacky attempt at re-serving local nix packages that came from trusted sources.
- Nix parallelism & Import From Derivation (2020) (Reddit)
- macOS Nix setup: an alternative to Homebrew (2020) (Lobsters) (HN)
- update-nix-fetchgit - Program to automatically update fetchgit values in Nix expressions.
- Cache install Nix packages - Use the GitHub Actions cache for Nix packages.
- nixbuild.net Action - GitHub Action for using the nixbuild.net service.
- fromElisp - Emacs Lisp reader in Nix.
- On-demand linked libraries for Nix (2020) (Lobsters)
- Towards a Content-Addressed Model for Nix (2020) (HN)
- deploy-rs - Simple, multi-profile Nix-flake deploy tool.
- TodoMVC-Nix - One-stop reference to build TodoMVC application inside the Nix world.
- Trustix: Distributed trust and reproducibility tracking for binary caches (2020) (Code)
- Trustix - Consensus and voting (2022)
- Binary Verification with Trustix starring Adam Höse (2021)
- Building with Nix Flakes for, eh .. reasons (2021)
- What is the right approach to handling binary, non-executable data dependencies of packages? (2021)
- Scrive Nix Workshop (Code)
- nix-npm-buildpackage - Build nix packages that use npm/yarn.
- dev-env - Nix with training wheels.
- Basinix - Pull request reviewing tool for nixpkgs.
- Nix-template - Make creating nix expressions easy. Provide a nice way to create largely boilerplate nix-expressions.
- nixpkgs-hammering - Set of nit-picky rules that aim to point out and explain common mistakes in nixpkgs package pull requests.
- nix-script - Write scripts in compiled languages that run in the nix ecosystem, with no separate build step. (Article)
- nix-update - Updates versions/source hashes of nix packages. It is designed to work with nixpkgs but also other package sets.
- Nix Portable - Static, Permissionless, Installation-free, Pre-configured.
- nix-optics - Using profunctor optics to focus modifications in Nix.
- Use Nix flakes without any fluff
- Nix-environments - Repository to maintain out-of-tree shell.nix files.
- Determinate Systems - Confidently build and deploy to the cloud, stadium, or stock exchange. Expert help with the Nix ecosystem from Graham. (Twitter) (GitHub)
- How to Learn Nix (HN)
- Nix is the ultimate DevOps toolkit (2021) (HN) (Lobsters)
- devshell - Per project developer environments.
- Nix Data - Set of packages for data-scientists with batteries-included.
- Nomia - System for precise, efficient resource management across every domain and resource type.
- Chimera - Nix-based package manager with the focus on developer experience.
- Data Science with Nix: Parameter Sweeps (2021)
- Nixpkgs rules for Bazel - Rules for importing Nixpkgs packages into Bazel.
- Practical Nix Flakes (2021)
- npmlock2nix - Utilizing npm lockfiles to create Nix expressions for NPM based projects.
- Laurn - Run a dev-environment in a pure-ish nix environment.
- nix-filter - Small self-container source filtering lib.
- nix-eval-lsp - Nix language server that evaluates code.
- Flakes are such an obviously good thing: ...but the design and development process should be better (2021) (Lobsters)
- scratchix - Linux From Scratch, but it's Nix.
- Understanding Nix's String Context (2018)
- Replit now supports every programming language in Nix (2021) (HN)
- nix-graph - Reify the Nix build graph into a Haskell graph data structure.
- Digga - Feature rich and configurable framework for harnessing Nix Flakes.
- Nix solves the package manager ejection problem (2021) (HN)
- Cross compilation using Nix (Tweet)
- nix-std - no-nixpkgs standard library for the nix expression language.
- Nix unstable installer - Place to host Nix unstable releases.
- Nix Learning - Links to blog posts, articles, videos, etc for learning Nix.
- nix-plugins - Collection of useful Nix native plugins.
- Nix.Ci - Provides the CI integration infrastructure for Nixpkgs and NixOS. More commonly known as OfBorg. (Code)
- nix-user-chroot - Install & Run nix without root permissions.
- Another Nix Success Story (2021) (Lobsters)
- nix bundle - Bundle an application so that it works outside of the Nix store.
- Building Container Images with Nix (2021) (HN)
- Debug symbols for binaries with Nix (2021)
- Ditch your version manager and use Nix (2021) (Lobsters) (HN)
- Advanced shell packaging: resholve YADM's nixpkg (2021)
- nix-parsec - Parser combinators in Nix.
- nix-prefetch-github - Prefetch sources from github for nix build tool.
- Building reproducible Development environment with nix-shell (2021)
- Building with Nix on Replit (HN)
- dream2nix - Generic framework for 2nix converters (converting from other build systems to nix).
- Novice Nix: Flake Templates (2021)
- Personal provisioning machines with Nix
- Issues you encountered learning Nix? (2021)
- Declarative Dev Environments using Nix (2021)
- Peerix - Peer-to-peer binary cache for nix derivations.
- update-flake-lock - GitHub Action that will update your flake.lock file whenever it is run.
- Replit - Faster Nix Repl Startup (2021)
- Statix - Lints and suggestions for the nix programming language. (Reddit)
- Cicero - Workflow execution engine. Workflow is a description of (dependent) steps using the Nix configuration language.
- Cross-compiling and Static-linking with Nix (2021)
- Nix 2.4 (2021) (Lobsters) (HN)
- nixcrpkgs - Tools for cross-compiling standalone applications using Nix.
- Flake structure
- nix-patchtools - Autopatching binary packages to make them work with Nix.
- A Critique of Nix Package Manager (Reddit)
- rusty-nix - Nix written in rust.
- Some Nix questions (2021)
- Nix - Flakes for out-of-tree code (2021)
- Is it worth learning and migrating to Flakes as of November 2021?
- dreampkgs - Collection of software packages managed with dream2nix, a framework for automated packaging.
- Flake templates
- libnix - Haskell library to interface with the nix package manager.
- nix-exec - Run programs defined in nix expressions.
- Closure vs. derivation in the Nix package manager (2018)
- mk-darwin-system - Small Nix utility to create an M1 aarch64-darwin (nixFlakes + nix-darwin + home-manager) system.
- Nix language for JavaScript developers
- Will Nix Overtake Docker (2021) (HN) (Lobsters)
- One too many shell (2021)
- Building a reproducible blog with Nix (2020)
- Tvix: We Are Rewriting Nix (2021) (HN) (Lobsters)
- Implementing a content-addressed Nix (2021)
- BuildKit-Nix - Allows using Nix derivations (default.nix) as Dockerfiles.
- How Nix and NixOS Get So Close to Perfect (2021)
- deadnix - Scan Nix files for dead code.
- nix-casync - More efficient way to store and substitute Nix store paths. (Article) (Tweet)
- Untrusted CI: Using Nix to get automatic trusted caching of untrusted builds (2019)
- nix-universal-prefetch - Uses nix and nixpkgs to actually run the prefetch operation, then read the error message to figure out the desired hash.
- Nix Starter Config - Simple config repo to get you started with NixOS + home-manager + flakes.
- Compatibility function to allow flakes to be used by non-flake-enabled Nix versions
- Tools You Should Know About: nix-shell (2021) (Lobsters)
- Basic implementation of a Nix-like store abstraction over a Merkle tree
- tower-lsp - Language Server Protocol implementation written in Rust.
- direnv-nix-lorelei - Alternative Nix extension of Direnv.
- nix-eval-jobs - Parallel nix evaluator with a streamable JSON output.
- go-nix - Nix experiments written in go.
- Nixpkgs Overlays Are Monoids (HN)
- Building fully declarative systems with Nix (2022)
- nix2container - Archive-less dockerTools.buildImage implementaion.
- Hydra - Nix-based continuous build system. (CLI)
- Exploring Nix Flakes: Usable Go Plugins (2022)
- gradle2nix - Generate Nix expressions which build Gradle-based projects.
- npins - Simple and convenient pinning of dependencies in Nix.
- nix-docker-base - Nix Docker base images for fast and minimal builds.
- Nix: An Idea Whose Time Has Come (2022) (Lobsters) (HN)
- Alejandra - Uncompromising Nix Code Formatter.
- Makes - DevSecOps framework powered by Nix.
- Standard - Opinionated, generic, Nix Flakes framework that will allow you to grow and cultivate Nix Cells with ease.
- nix-book - Nix Package Manager. (Docs)
- Nix Flakes: an Introduction (2022) (Lobsters) (Reddit) (HN)
- All New Repls are Powered By Nix (2022)
- Nix Flakes: Packages and How to Use Them (2022)
- libnar - Library for reading and writing from NAR (Nix Archive) files written in Rust.
- nix-output-monitor - Pipe your nix-build output through the nix-output-monitor (aka nom) to get additional information while building.
- nixpack - nix+spack.
- nix-html - HTML DSL for Nix.
- nickel-nix - Experimental Nix toolkit to use nickel as a language for writing nix packages, shells and more.
- What's new in Nix 2.7.0? (2022)
- Nix Bundlers - Way to transform derivations.
- How to Learn Nix (HN)
- The hard part of type-checking Nix (2022)
- Shrinkwrap: Taming dynamic shared objects (2022)
- any-nix-shell - Fish and Zsh support for the nix run and nix-shell environments of the Nix package manager.
- Nix time (2022)
- Flake For Non-Nix Projects (2022)
- Shrinkwrap - Tool that embosses the needed dependencies on the top level executable.
- nix-dram - Nix Flakes with a modified frontend.
- nixos-shell - Tool for reproducable development environments described as NixOS modules.
- nixpkgs-update - Updating nixpkgs packages since 2018.
- Awesome Nix high performance computing
- Nix tutorials
- Spongix - Proxy for Nix Caching.
- Nixpacks - App source + Nix packages + Docker = Image.
- Summer of Nix
- Cache evaluation of nix functions
- nix-bundle-exe - Simple Nix derivation to bundle Mach-O (macOS) and ELF (Linux) executables into a relocatable directory structure.
- deploy-flake - Tool for deploying nix flakes to remote systems.
- Nix Flakes: Exposing and using NixOS Modules (2022)
- NixEL - Lexer, Parser, Abstract Syntax Tree and Concrete Syntax Tree for the Nix Expressions Language.
- Why nix is great as a build tool (2022)
- Nix grammar for tree-sitter
- Generating nix store paths with arbitrary prefixes
- static-nix - Statically linked version of Nix with some patches intended to ease the installation and usage of Nix on typical HPC clusters.
- Nix Camp - 2 week long Nix event. (Twitter)
- Feedback loop - General purpose tool to set up good feedback loops and share them with your team.
- make-wrapper - makeWrapper and wrapProgram freed from Nix build system.
- Semantic linter for Nix using tree-sitter
- Nix flakes, and how to convert to them
- Toros - Implementation of Nix in Rust.
- nix-shell, but make it lovely (2022)
- Nix Security Packages
- harmonia - Nix binary cache implemented in rust using libnix-store.
- Hercules CI Effects - Implemented by the agent are a fairly low-level interface for executing programs that interact with the Nix store, centralized state and the real world.
- Fractal - Zero-compromise Kubernetes resource generation with Nix, Jsonnet and Kustomize.
- Union and intersection contracts are hard, actually (2022)
- Proof of concept of a literate Nix flake
- dev-container - devcontainer built on Debian and powered by Nix.
- nix-doc - Interactive Nix documentation tool providing a CLI for function search, a Nix plugin for docs in the REPL, and a ctags implementation for Nix script.
- Flake Modules Core - Core of a framework for writing flakes. Assemble your flakes with modules.
- How to Learn Nix, Part 47: New and unimproved shells (2021)
- Quickly building minimal Docker containers with Nix (2021)
- Nix Book - Centralized community online learning resource for Nix.
- Replit - Dynamic version for Nix derivations (2021)
- nix-serve - Standalone Nix binary cache server.
- Zicross - Nix Flake for cross-compiling and packaging for foreign systems.
- Tutorial: Getting started with Home Manager for Nix (2021)
- A Tour of Nix Flakes (2022)
- cached-nix-shell - Instant startup time for nix-shell.
- Evaluating the security implications of a company-wide Nix remote builder (2021)
- nixbench - Analyze Nix derivations.
- Using Nix as package manager experiences (2022)
- Nix as shell
- Nixago - Generate configuration files using Nix.
- nix-nomad - Generate HashiCorp Nomad JSON job files with Nix using NixOS modules.
- relocatable.nix - Nix bundler that produces relocatable deployment script for nix store paths.
- Nixpacks beat Buildpacks by almost two minutes
- Throwaway development environments with Nix (2022) (Lobsters)
- Nix post-build-hook queue
- Nix packaging, the heretic way (2022) (Lobsters)
- Nix-wrangle - Wrangle your nix dependencies.
- Nix – taming Unix with functional programming (2022) (HN)
- Demo of using Nix + Bazel for a tree-sitter project
- About using Nix in my development workflow (2018) (HN)
- Summer of Nix 2022 - YouTube
- nix-cue - Validate and generate configuration files using Nix and Cue.
- Using Nix on macOS (2022) (HN)
- Matthew Croughan - Use flake.nix, not Dockerfile (2022) (Lobsters)
- build-modules - Low level module system for nix builds.
- wabi in Nix
- nil - Language Server for Nix Expression Language.
- Making a PR to Nixpkgs (2022) (HN)
- Building websites using Nix Flakes and Zola (2022)
- How to look up a Nix package's Nix store path from flake inputs (2022)
- Our roadmap for Nix (2022) (Lobsters) (HN)
- nix-linux - Framework for configuring and building Linux and U-Boot using Nixpkgs.
- Domen Kožar - Nix Is Going Mainstream (2022)