2024-06-22 16:42:04 +00:00
---
title: Nixpkgs Tools
description: An overview of the various functions unrelated to building source code available in Nixpkgs.
published: true
2024-06-29 14:50:43 +00:00
date: 2024-06-29T14:50:41.540Z
2024-06-22 16:42:04 +00:00
tags: nix, nixpkgs
editor: markdown
dateCreated: 2024-06-22T16:41:59.925Z
---
# Introduction to Nixpkgs' tools
This page is an overview of various functionality included in Nixpkgs, that is not directly related to building packages from source code.
## Fetchers (`pkgs.fetch*`)
Fetchers such as `pkgs.fetchurl` allow to download content such as package sources, by specifying an expected hash of the content.
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#chap-pkgs-fetchers )
## Wrappers (`pkgs.runCommand*`, `pkgs.write*`)
Functions such as `pkgs.runCommand` or `pkgs.writeShellScript` are use-case specific wrappers around `pkgs.stdenv` with simple arguments.
Not to be confused with `pkgs.writers` .
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#chap-trivial-builders )
## Data Formats (`pkgs.writers`)
Data format or application focussed writers that transform Nix expressions into the respective format.
Not to be confused with `pkgs.write*` .
Resource:
- [Nixpkgs source ](https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/writers )
## Config File Formats (`pkgs.formats`)
Produce various config file formats from nix expressions.
Resources:
- [Nixpkgs source ](https://github.com/NixOS/nixpkgs/blob/master/pkgs/pkgs-lib/formats.nix )
## Custom Build Environments (`pkgs.mkShell`)
Convenience wrapper around `mkDerivation` for usage with `nix-shell` / `nix develop` .
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-mkShell )
## Creating Hooks (`pkgs.makeSetupHook`)
Helper to produce hooks for the `stdenv` build phases.
(For more info on hooks in general, see [Language/Framework Specific Builders in Nixpkgs#Hooks ](./pkgs-languages-frameworks#hooks )).
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#sec-pkgs.makeSetupHook )
## Test Utilities (`pkgs.testers`)
Derivation builders for testing various properties of other derivations.
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#chap-testers )
2024-06-29 14:50:43 +00:00
- [nix.dev Tutorial: Integration testing with NixOS virtual machines ](https://nix.dev/tutorials/nixos/integration-testing-using-virtual-machines )
2024-06-22 16:42:04 +00:00
## `fakeNss`
Including this *derivation* in, e.g. docker images or other environments without them, provides a simplistic set of user/group entries, to allow binaries expecting them to exist to work.
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#sec-fakeNss )
## Standard Filesystem Layout Wrapper (`buildFHSEnv`)
Wraps binaries that expect a [FHS ](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard )-compatible filesystem layout to run unpatched on NixOs.
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#sec-fhs-environments )
## Run AppImages (`pkgs.appimageTools`)
A set of functions to run or extract [AppImages ](https://appimage.org/ ).
Resources:
- [Nixpkgs manual ](https://appimage.org/ )
## Docker Images (`pkgs.dockerTools`)
A set of functions to create, modify, import or export docker images.
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-dockerTools )
2024-06-29 14:50:43 +00:00
- [Xe Iaso's Talk: Nix is a better Docker image builder than Docker's image builder (Transcript & Recording) ](https://xeiaso.net/talks/2024/nix-docker-build/ )
- [nix.dev Tutorial: Building and running Docker images) ](https://nix.dev/tutorials/nixos/building-and-running-docker-images.html )
- [Xe Iaso's Blog Post: Nix Flakes: Packages and How to Use Them ](https://xeiaso.net/blog/nix-flakes-2-2022-02-27/ )
2024-06-22 16:42:04 +00:00
## Build OCI Containers (`pkgs.ociTools`)
A set of function to create [OCI containers ](https://github.com/opencontainers/runtime-spec/blob/v1.0.0/spec.md ).
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-ociTools )
## Build Portable Services (`pkgs.portableService`)
A function to create [systemd's Portable Services ](https://systemd.io/PORTABLE_SERVICES/ ).
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-portableService )
2024-06-29 14:50:43 +00:00
- [Xe Iaso's Blog Post: Nix Flakes: Packages and How to Use Them ](https://xeiaso.net/blog/nix-flakes-2-2022-02-27/ )
2024-06-22 16:42:04 +00:00
## Build Disk Images (`make-disk-image.nix`)
This function creates disk images in various formats (e.g. raw, QCOW2 (QEMU), VDI (VirtualBox), etc.).
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#sec-make-disk-image )
## Run Derivations inside a VM (`pkgs.vmTools`)
Various tools to run derivations inside a Qemu/KVM backed virtual machine.
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#sec-vm-tools )
## Incremental Builds (`pkgs.checkpointBuildTools`)
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#sec-checkpoint-build )
## Flat-file Binary Cache (`pkgs.mkBinaryCache`)
Create Nix flat-file binary caches.
Resources:
- [Nixpkgs manual ](https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-binary-cache )