NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.11k stars 14.15k forks source link

`nixos-install` attempts to execute activation script #353476

Closed Frontear closed 1 week ago

Frontear commented 1 week ago

Describe the bug

I've got a configuration that adds some things to the activation script, namely bind mounts for an ephemeral root setup. Recently I completed a reinstallation of my system, and this was my main hiccup as it seemed to execute the activation script. This caused /etc/machine-id to attempt linkage within the newly installed system before systemd had activated, which made it a blank file. This then continued to fail the installation, explaining that machine_file.readlines()[0] from the systemd-boot python script failed as there were no lines to read.

This does not occur when performing a nixos-rebuild boot from an installed minimal system, since it doesn't attempt to fire the activation script. I feel like this qualifies as a bug, and if its not, I don't understand the design choice, since activation occurs at boot later anyways, why does it need to fire within the chroot environment?

Steps To Reproduce

Steps to reproduce the behavior:

  1. ...
  2. ...
  3. ...

Expected behavior

I did not expect the activation script to fire, since I expected that to happen post-install when booting into the system for the first time.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Notify maintainers

Metadata


Add a :+1: reaction to issues you find important.

Frontear commented 1 week ago

@jackwilsdon informed me that I was looking in the wrong place. It turns out the culprit here is nixos-enter, which fires the activation script in order to subsequently execute /run/current-system/bin/switch-to-configuration boot.

This causes an issue for me in particular because my activation scripts attempts to link files from my persistent drive to my ephemeral root. Basic idea is if the file doesn't exist, it creates an empty placeholder and links that. This causes /etc/machine-id to be empty since it obviously doesn't exist on a first install, which then subsequently breaks systemd-boots install bootloader, since the file is fully empty.

It doesn't seem like this is something that could reasonably be resolved on nixpkgs end, so instead I'll opt for a solution on my end, especially since its my own changes that caused this.