nixpkgs

Links to this page
  • macOS

    [!warning] Darwin support in nixpkgs macOS support in nixpkgs is not of same quality and priority as Linux. See https://github.com/NixOS/nixpkgs/issues/145230 & https://github.com/NixOS/nixpkgs/issues/116341

  • Why Choose Nix for develoment?

    [!note] macOS support While macOS doesn’t enjoy first-class support in nixpkgs yet, improvements are underway.

  • Rapid Introduction to Nix

    A flake can refer to other flakes in its inputs. Phrased differently, a flake’s outputs can be used as inputs in other flakes. The most common example is the nixpkgs flake which gets used as an input in most flakes. Intuitively, you may visualize a flake to be a node in a larger graph, with inputs being the incoming arrows and outputs being the outgoing arrows.

    Let’s do something more interesting with our flake.nix by adding the nixpkgs input:

    The nixpkgs flake has an output called legacyPackages, which is indexed by the platform (called “system” in Nix-speak), further containing all the packages for that system. We assign that package to our flake output key foo.

  • Nixifying a Haskell project using nixpkgs

    The official manual explains the Haskell’s infrastructure in nixpkgs detail. For our purposes, the main things to understand are:

    This flake defines a flake app that can be run using nix run. This app is simply a shell script that starts a Postgres server. nixpkgs provides the convenient writeShellApplication function to generate such a script. Note that "${script}" provides the path in the nix/store where the application is located.

    We used callCabal2nix function from nixpkgs to build the todo-app package above. This functio generates a Haskell package Derivation from its source, utilizing the “cabal2nix” program to convert a cabal file into a Nix derivation.

  • Nixify Haskell projects

    This is a tutorial series on nixifying Haskell projects. In part 1, we will begin with using nothing but nixpkgs. In the latter parts, we’ll use simplifiy our project Nix code through haskell-flake which builds on top of the Haskell infrastructure in nixpkgs.*

  • Module System

    The nixpkgs library provides a module system for Nix expressions. To learn it, see our tutorial: Introduction to module system.

  • Introduction to module system

    We shall begin by understanding the low-levels: how to use evalModules from nixpkgs to define and use our own modules from scratch, using the aforementioned lsd use-case. The next tutorial in this series will go one high-level up and talk about how to work with modules across flakes, using flake-parts.

  • Install NixOS with Flake configuration on Git

    You have successfully installed NixOS. The entire system configuration is also stored in a Git repo, and can be reproduced at will during either a reinstallation or a new machine purchase. You can make changes to your configuration, commit them to Git, and push it to GitHub. Additionally we enabled Flakes permanently, which means you can now use all the modern nix commands, such as running a package directly from nixpkgs (same version pinned in flake.lock file):

  • First steps with Nix

    As of this writing, nixpkgs has over 80,000 packages. You can search them here. Search for “cowsay” and you will find that it is available in Nixpkgs.

    In this tutorial we will learn how to use existing packages from the nixpkgs repository and elsewhere. We will not be writing any Nix language code yet (we reserve that for the next tutorial).

    It is the specific identifier for the nixpkgs repository (https://github.com/nixos/nixpkgs) defined in your local Flake registry:

    nixpkgs is the main repository, but Nix allows installing software from anywhere. You can run or install programs from any flake by specifying its URL.

  • Auto formatting using treefmt-nix

    The package shipped with the current nixpkgs might not be the desired one, follow the snippet below to override the package (assuming nixpkgs-21_11 is present in your flake’s inputs).