-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/systemd: Enable systemd-machine-id-commit.service #351151
Conversation
71c7862
to
3024567
Compare
Prior to this contribution, every boot with a default configuration was considered `ConditionFirstBoot=true` by systemd, since /etc/machine-id was not commited to disk. This also extends the systemd with a check for subsequent boots not being considered first boots.
3024567
to
8f4b41c
Compare
Oh wow oops. Thanks for catching this |
This does not work well with https://github.com/nix-community/impermanence (or more precisely, the other way around), since when |
I've added these lines to my config for hosts where I have boot.initrd.systemd.suppressedUnits = [ "systemd-machine-id-commit.service" ];
systemd.suppressedSystemUnits = [ "systemd-machine-id-commit.service" ]; I'm not sure if both are necessary. |
I think maybe the original PR shouldn't have removed the
line but instead it should've done something like:
I think then all use-cases work? |
I looked into this for preservation and think that a good approach would be to create for preservation, I came up with this. I'll try to push that soon together with some other changes: boot.initrd.systemd.tmpfiles.settings.preservation."/sysroot/state/etc/machine-id".f = {
user = "root";
group = "root";
mode = ":0644";
argument = "uninitialized\\n";
};
systemd.services.systemd-machine-id-commit = {
unitConfig.ConditionPathIsMountPoint = [
""
"/state/etc/machine-id"
];
serviceConfig.ExecStart = [
""
"systemd-machine-id-setup --commit --root /state"
];
}; |
I forgot to add, this works with |
Is the |
As I understand it, yes. On first boot, |
But I don't think that needs to be handled in nixpkgs. It should be handled by whatever configuration causes the machine-id file to not be persisted under /etc/machine-id directly, in my case preservation. |
We should add the |
Nixpkgs recently merged NixOS/nixpkgs#351151 which enables systemd-machine-id-commit.service. This service fails if /etc/machine-id is a bind mount, as it is with the impermenance module, so I've changed the persistence for it to use a systemd tmpfiles symlink instead.
…ce trigger The bind mount creation for `/etc/machine-id` by `impermanence` is unintentionally triggering `systemd-machine-id-commit.service`, causing an error. This commit resolves this issue, see: nix-community/impermanence#229. And NixOS/nixpkgs#351151 for details.
…emd-machine-id-commit.service The bind mount creation for `/etc/machine-id` by `impermanence` is unintentionally triggering `systemd-machine-id-commit.service`, causing an error. This commit resolves this issue, see: nix-community/impermanence#229 and NixOS/nixpkgs#351151 for details.
…emd-machine-id-commit.service The bind mount creation for `/etc/machine-id` by `impermanence` is unintentionally triggering `systemd-machine-id-commit.service`, causing an error. This commit resolves this issue, see: nix-community/impermanence#229 and NixOS/nixpkgs#351151 for details.
Would you mind explaining the intention of that? I don't understand how this helps in any of the reported issues in the PR. As I understand, impermanence creates a bindmount for an already persisted |
I believe there was some confusion about this, definitely on my end. Right now in nixpkgs we should be fine without any changes, there are no problems and a missing machine-id file is semantically equivalent to one that contains the string For those interested in preserving the machine-id at another location than
|
Prior to this contribution, every boot with a default configuration was considered
ConditionFirstBoot=true
by systemd, since /etc/machine-id was not commited to disk.This also extends the systemd with a check for subsequent boots not being considered first boots.
This is a follow-up on #327552
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.