Skip to content

man-db cache generation fails when building inside Nix Docker image #14143

@pkoenig10

Description

@pkoenig10

Describe the bug

I'm attempting to use the official Nix Docker image to build a NixOS LiveCD on a system without Nix installed.

I have the following iso.nix file:

{
  ...
}:

{
  imports = [
    <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix>
  ];

  programs.fish.enable = true;
}

And I'm attempting to build the LiveCD it with the following command:

docker run --rm \
    -v ./iso.nix:/iso.nix \
    nixos/nix:2.31.2 \
    nix-build '<nixpkgs/nixos>' -A config.system.build.isoImage -I nixos-config=/iso.nix

But this fails with the following error:

building '/nix/store/rrzpw22bv3q10map05gbp0s5mgffr9ic-man-cache.drv'...
error: Cannot build '/nix/store/rrzpw22bv3q10map05gbp0s5mgffr9ic-man-cache.drv'.
       Reason: builder failed with exit code 2.
       Output paths:
         /nix/store/iryvzki6r36ds2iq64pyrs32lsb5qiwz-man-cache

This happens because src/man_db.conf.in contains the following line:

MANDB_MAP /nix/var/nix/profiles/default/share/man /var/cache/man/nixpkgs

When building this ISO in NixOS, there is no such file:

$ ls -la /nix/var/nix/profiles/
/nix/var/nix/profiles/:
total 0
drwxr-xr-x 3 root root 100 Oct  3 02:11 .
drwxr-xr-x 7 root root 160 Oct  3 02:11 ..
drwxr-xr-x 3 root root  60 Oct  3 02:11 per-user
lrwxrwxrwx 1 root root  13 Oct  3 02:11 system -> system-1-link
lrwxrwxrwx 1 root root  88 Oct  3 02:11 system-1-link -> /nix/store/zskwzx88124z5f56zdidhp8y34wn23kd-nixos-system-nixos-24.11.713387.107d5ef05c0b

But when building this ISO in the Nix Docker image, that file exists:

/nix/var/nix/profiles:
total 8
drwxr-xr-x 1 root root 58 Jan  1  1980 .
drwxr-xr-x 1 root root 64 Oct  3 02:12 ..
lrwxrwxrwx 1 root root 36 Jan  1  1980 default -> /nix/var/nix/profiles/default-1-link
lrwxrwxrwx 1 root root 60 Jan  1  1980 default-1-link -> /nix/store/0djq5pgvmzhl7v132slkpqfm9nan0i13-root-profile-env
drwxr-xr-x 1 root root  8 Jan  1  1980 per-user

It seems that this is due to the configuration here:

nix/docker.nix

Lines 310 to 313 in fdea162

# see doc/manual/source/command-ref/files/profiles.md
ln -s ${profile} $out/nix/var/nix/profiles/default-1-link
ln -s /nix/var/nix/profiles/default-1-link $out/nix/var/nix/profiles/default
ln -s /nix/var/nix/profiles/default $out${userHome}/.nix-profile

I have relatively little experience with Nix, so it's certainly possible I'm doing something wrong.

Steps To Reproduce

  1. Create the following iso.nix file

    {
    ...
    }:
    
    {
      imports = [
        <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix>
      ];
    
    
      documentation.man.generateCaches = true;
    }
  2. Run the following command

    docker run --rm \
        -v ./iso.nix:/iso.nix \
        nixos/nix:2.31.2 \
        nix-build '<nixpkgs/nixos>' -A config.system.build.isoImage -I nixos-config=/iso.nix
    

Expected behavior

I expected the build to complete successfully and produce an ISO image.

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions