nix-env (packages available to the user):
# search (query for --installed or --available)
nix-env -q --installed vim
nix-env -q --available 'emacs.*'
# install
nix-env -i htop
# remove
nix-env --uninstall htop
nix-shell:
nix-shell -p nodejs python3
shell.nix:
{ pkgs ? import <nixpkgs> {}
}:
pkgs.mkShell {
name="dev-environment";
buildInputs = [ pkgs.nodejs ];
shellHook = ''
echo "Start developing..."
'';
}
nix-shell as interpreter (Python):
#! /usr/bin/env nix-shell
#! nix-shell -i python -p python pythonPackages.prettytable
import prettytable
# Print a simple table.
t = prettytable.PrettyTable(["N", "N^2"])
for n in range(1, 10): t.add_row([n, n * n])
print t
nix-shell as bash interpreter + PHP:
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p "(php.withExtensions ({ all, enabled }: enabled ++ (with all; [ imagick redis ]))).packages.composer1"
composer --version
docker:
{ pkgs ? import <nixpkgs> { system = "x86_64-linux"; }
}:
pkgs.dockerTools.buildLayeredImage {
name = "nix-redis";
tag = "latest";
contents = [ pkgs.redis ];
}
It also requires:
nix-build docker-redis.nix -o ./result
docker load -i ./result