Skip to content

nixos-init: fails to setup /etc on an empty root, resulting in a failure to systemctl switch-root #450765

@Frontear

Description

@Frontear

Nixpkgs version

  • Unstable (25.11)

Describe the bug

On a system that uses a tmpfs root, directories like /etc were previously created by the original activation scripts

# Set up the statically computed bits of /etc.
echo "setting up /etc..."
${pkgs.perl.withPackages (p: [ p.FileSlurp ])}/bin/perl ${./setup-etc.pl} ${etc}/etc
'';

It seems that nixos-init does not do this in the initrd (or at all?) which results in a missing /etc/os-release that systemd apparently needs to perform the switch-root. Otherwise, the service fails and systemd falls back to emergency.target

Steps to reproduce

  1. Use tmpfs for the root mount
  2. Enable system.nixos-init

Expected behaviour

The /etc directory is correctly populated

Screenshots

No response

Relevant log output

Additional context

No response

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.16.11-xanmod1, NixOS, 25.11 (Xantusia), 25.11.20251009.0b4defa
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Lix, like Nix) 2.93.3 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux, x86_64-v4-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/frontear/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/frontear/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/frontear/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/frontear/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/zxl9ivn2v7xcrzlf4j036fl6av34zwv9-lix-2.93.3/share
  • nixpkgs: /nix/store/0w224qci6vkj0m8m68rl9d44zmni0qjp-input-farm/nixpkgs

Notify maintainers

@nikstur


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

  • system: "x86_64-linux"
  • host os: Linux 6.16.11-xanmod1, NixOS, 25.11 (Xantusia), 25.11.20251009.0b4defa
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Lix, like Nix) 2.93.3 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux, x86_64-v4-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/frontear/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/frontear/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/frontear/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/frontear/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/zxl9ivn2v7xcrzlf4j036fl6av34zwv9-lix-2.93.3/share
  • nixpkgs: /nix/store/0w224qci6vkj0m8m68rl9d44zmni0qjp-input-farm/nixpkgsAdd a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions