FROM ubuntu:latest
RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends curl xz-utils ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN set -x \
&& curl -L https://nixos.org/nix/install | sh -s -- --daemon \
&& mkdir -p /etc/nix \
&& echo 'experimental-features = nix-command flakes' >> /etc/nix/nix.conf
Build docker image
$ docker build -t ubuntu-nix - < Dockerfile
$ docker run --rm -it ubuntu-nix -v ~/.ssh:/home/$USER/.ssh:ro
In new shell verify installation
$ nix-shell -p nix-info --run 'nix-info -m'
$ nix run nixpkgs#hello --show-trace
# https://nixos.org/download.html#nix-install-macos
$ sh <(curl -L https://nixos.org/nix/install)
# Enable nix command (flakes already enabled for nix >= 2.4.0)
$ mkdir -p ~/.config/nix
$ echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
# Restart your machine
$ reboot
After restart
# Check if nix is installed correctly
$ nix-shell -p nix-info --run "nix-info -m"
# Check if the next commands is working
$ NP_DEBUG=1 nix run nixpkgs#hello --show-trace