nix-installer icon indicating copy to clipboard operation
nix-installer copied to clipboard

`nix-store --load-db` crashes on kasm docker images

Open mausch opened this issue 1 year ago • 3 comments

In a kasmweb/ubuntu-jammy-desktop:1.14.0 docker container running as root:

$ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix -o nix-installer
$ chmod a+x nix-installer
$ RUST_BACKTRACE=full ./nix-installer install linux --init none
info: downloading installer https://install.determinate.systems/nix/tag/v0.15.1/nix-installer-x86_64-linux
Nix install plan (v0.15.1)
Planner: linux

Configured settings:
* init: "None"
* start_daemon: true

Planned actions:
* Create directory `/nix`
* Fetch `https://releases.nixos.org/nix/nix-2.18.1/nix-2.18.1-x86_64-linux.tar.xz` to `/nix/temp-install-dir`
* Create a directory tree in `/nix`
* Move the downloaded Nix into `/nix`
* Create build users (UID 30000-30032) and group (GID 30000)
* Setup the default Nix profile
* Place the Nix configuration in `/etc/nix/nix.conf`
* Configure the shell profiles
* Create directory `/etc/tmpfiles.d`
* Remove directory `/nix/temp-install-dir`

Proceed? ([Y]es/[n]o/[e]xplain): y
 INFO Step: Create directory `/nix`
 INFO Step: Provision Nix
 INFO Step: Create build users (UID 30000-30032) and group (GID 30000)
 INFO Step: Configure Nix
ERROR 
   0: Install failure
   1: Error executing action
   2: Action `configure_nix` errored
   3: Action `setup_default_profile` errored
   4: Failed to execute command `HOME="/home/kasm-user" "/nix/store/azvn85cras6xv4z5j85fiy406f24r1q0-nix-2.18.1/bin/nix-store" "--load-db"`, stdout: 
      stderr: 
   4: 

Location:
   /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/convert/mod.rs:716

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  <empty backtrace>

Here's a dockerfile to repro:

FROM kasmweb/core-ubuntu-jammy:1.14.0
USER root
RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/tag/v0.15.1 | sh -s -- install linux --init none --no-confirm

mausch avatar Nov 30 '23 17:11 mausch

Got it to not crash by setting ENV LD_LIBRARY_PATH "". However when calling nix I get https://github.com/DeterminateSystems/nix-installer/issues/777

mausch avatar Dec 15 '23 17:12 mausch

This works:

FROM kasmweb/core-ubuntu-jammy:1.14.0
USER root
RUN echo 'ALL ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
USER 1000
ENV LD_LIBRARY_PATH ""
RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/tag/v0.15.1 | sh -s -- install linux --init none --no-confirm
ENV PATH="$PATH:/nix/var/nix/profiles/default/bin"
RUN sudo chown --recursive kasm-user /nix # https://github.com/NixOS/nix/issues/3435#issuecomment-1642654775

mausch avatar Dec 15 '23 17:12 mausch

It's unclear to my why nix-store --load-db would fail without printing to stderr. It's also unclear to me how setting LD_LIBRARY_PATH solves your issue...

If your workaround is to chown /nix you may want to consider the single user scripts: https://nixos.org/manual/nix/stable/installation/installing-binary#single-user-installation

Hoverbear avatar Dec 21 '23 18:12 Hoverbear