Currently the following guides exist:
- Nix reference guide
- NixOS reference guide
- Hydra reference guide
- Nixpkgs guide
as well as a (mostly outdated) read-only wiki.
Python is used throughout Nixpkgs. We use it for certain scripts, we provide Python libraries, and we provide applications. There are several methods on how to use Python on Nix, each with their pros and cons. An overview of all issues with the current Python infrastructure on Nix is available in the placeholder issue 1819.
# Produce a list of derivations that should likely have pythonPath set | |
with import <nixpkgs> {}; | |
with builtins; | |
let | |
# Package set to check | |
pythonPackages = pkgs.python2Packages; | |
# evaluate expr, returning default on error |
#! /usr/bin/env python | |
""" | |
Filter a .bib file with keys referred to in an .aux file. Print result to STDOUT. | |
""" | |
import argparse | |
import bibtexparser | |
import re | |
import itertools |
{pkgs ? (import <nixpkgs> {})}: | |
pkgs.stdenv.mkDerivation { | |
name = "fetchtarballtest"; | |
src = pkgs.fetchurl { | |
url = https://github.com/NixOS/nixpkgs/archive/9c90ff7e7df9ceadc7335bb43cc67ba92e171d53.tar.gz; | |
sha256 = "0f8ynrrj24i4g8flp978ccsb2hlwk1n321z8xwj0wakj0ak4c8i9"; | |
}; |
# Get nix 2.0 image from https://hub.docker.com/r/nixos/nix/ | |
FROM nixos/nix:2.0 | |
# Include the Nix expression we want to build | |
ADD default.nix default.nix | |
# We want the possibility for a custom store location | |
# Note that by using "/" there is effectively no mount namespace | |
# opening the doors for impurities. | |
ARG MOUNT_NIX_STORE |
let | |
pkgs = import (fetchTarball channel:nixos-18.03) {}; | |
custom-store = "/home/freddy/nix_custom_store"; | |
# Run nix in a mount namespace | |
nix-wrapped = pkgs.writeShellScriptBin "nix" '' | |
${pkgs.bubblewrap}/bin/bwrap \ | |
--unshare-all \ | |
--proc /proc \ | |
--dev /dev \ | |
--tmpfs /run \ |
import os | |
import subprocess | |
os.environ["FOO"] = "BAR" | |
subprocess.run("python3 -c 'import os; print(os.environ.get(\"FOO\", \"\"))'", shell=True) | |
del os.environ["FOO"] | |
subprocess.run("python3 -c 'import os; print(os.environ.get(\"FOO\", \"\"))'", shell=True) |
# # Python package set in Nixpkgs over time | |
# | |
# This gist is a Nix expression and generates a figure showing the size | |
# of the Python package set from September 2015 until now. | |
# | |
# To build the figure: | |
# | |
# nix-build | |
let |
let | |
overlay = self: super: { | |
python372 = let | |
py = super.python37.override { | |
self = py; | |
sourceVersion = { | |
major = "3"; | |
minor = "7"; | |
patch = "2"; | |
suffix = ""; |