Installing Nix on an Ubuntu Docker Container
·2 mins
open -a Docker # start Docker on MacOS
docker run -it ubuntu:latest /bin/bash
On the container:
apt update
apt install -y curl
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
sh -s -- install --no-confirm --extra-conf "trusted-users = $(whoami)"
It failed with this output:
info: downloading installer https://install.determinate.systems/nix/tag/v3.0.0/nix-installer-aarch64-linux
INFO nix-installer v3.0.0
Error:
0: Planner error
1: Error executing action
2: Action `create_upstream_init_service` errored
3: Action `configure_init_service` errored
4: Could not detect systemd; you may be able to get up and running without systemd with `nix-installer install linux --init none`.
See https://github.com/DeterminateSystems/nix-installer#without-systemd-linux-only for documentation on usage and drawbacks.
Location:
/build/nix-installer-source/src/cli/subcommand/install/mod.rs:180
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
Consider reporting this error using this URL: https://github.com/DeterminateSystems/nix-installer/issues/new?title=%3Cautogenerated-issue%3E&body=%23%23+Error%0A%60%60%60%0AError%3A+%0A+++0%3A+Planner+error%0A+++1%3A+Error+executing+action%0A+++2%3A+Action+%60create_upstream_init_service%60+errored%0A+++3%3A+Action+%60configure_init_service%60+errored%0A+++4%3A+Could+not+detect+systemd%3B+you+may+be+able+to+get+up+and+running+without+systemd+with+%60nix-installer+install+linux+--init+none%60.%0A++++++See+https%3A%2F%2Fgithub.com%2FDeterminateSystems%2Fnix-installer%23without-systemd-linux-only+for+documentation+on+usage+and+drawbacks.%0A%60%60%60%0A%0A%23%23+Metadata%0A%7Ckey%7Cvalue%7C%0A%7C--%7C--%7C%0A%7C**version**%7C3.0.0%7C%0A%7C**os**%7Clinux%7C%0A%7C**arch**%7Caarch64%7C%0A
The error is because we don’t have systemd in this Ubuntu container. To confirm that you have systemd run this command:
ps -p 1 -o comm=
bash
If you get systemd in the output, you are using systemd.
To be able to install without systemd we can use nix-installer install linux --init none
:
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
sh -s -- install linux --init none --no-confirm --extra-conf "trusted-users = $(whoami)"
To run Nix Health checks:
nix --accept-flake-config run github:juspay/omnix health
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
Reference: Install Nix.