WilliButz/preservation

persisting /etc/machine-id does not work

Opened this issue · 0 comments

In case someone runs into this issue:

With recent upstream NixOS changes the handling of /etc/machine-id changed.
Currently another change is necessary upstream, i.e. the file needs to be created with content uninitialized\n and on a setup with preservation something like the following needs to be done to properly preserve the machine-id across reboots. I'm not yet sure how to handle the necessary config change for the commit service.

{
  preservation.preserveAt."/state".files = [
    { file = "/etc/machine-id"; inInitrd = true; how = "symlink"; }
  ];

  systemd.services.systemd-machine-id-commit = {
    unitConfig.ConditionPathIsMountPoint = [
      "" "/state/etc/machine-id"
    ];
    serviceConfig.ExecStart = [
      "" "systemd-machine-id-setup --commit --root /state"
    ];
  };
}

Note that it is no longer possible to use the default behavior (i.e. how == "bindmount") to preserve machine-id, using a symlink instead works.
See NixOS/nixpkgs#351151 (comment)