Skip to content

update firstboot examples in docs and tests - #23

Open
rebmit wants to merge 5 commits into
nix-community:mainfrom
rebmit:firstboot-systemd-v258
Open

update firstboot examples in docs and tests#23
rebmit wants to merge 5 commits into
nix-community:mainfrom
rebmit:firstboot-systemd-v258

Conversation

@rebmit

@rebmit rebmit commented Nov 16, 2025

Copy link
Copy Markdown

Update the firstboot examples in the documentation and tests to be compatible with systemd v258.

Closes #22

@rebmit

rebmit commented Nov 16, 2025

Copy link
Copy Markdown
Author

Seems like we should also update the workflows.

@rebmit

rebmit commented Nov 16, 2025

Copy link
Copy Markdown
Author

Can confirm the tests build locally, likely hitting NixOS/nixpkgs#399245

@nazarewk

Copy link
Copy Markdown

Today I had more success with plain config, than with symlink variants mentioned in the docs.

This works perfectly fine without any additional configuration:

            {
              file = "/etc/machine-id";
              inInitrd = true;
              configureParent = true;
            }

@rebmit

rebmit commented Jan 15, 2026

Copy link
Copy Markdown
Author

Today I had more success with plain config, than with symlink variants mentioned in the docs.

Yes, it does work, and for most setups this is sufficient — this setup is also shown in https://nix-community.github.io/preservation/examples.html#simple.

However, in the first-boot section, the goal is not only to make machine-id preservation work, but to ensure compatibility with systemd's first-boot semantics.

@nazarewk

Copy link
Copy Markdown

yeah, it actually fails with a mountpoint until I add that ConditionFirstBoot = true;

Comment thread docs/src/examples.md
systemd.suppressedSystemUnits = [ "systemd-machine-id-commit.service" ];
boot.initrd.systemd.tmpfiles.settings.preservation."/sysroot/persistent/etc/machine-id".f = {
argument = "uninitialized";
};

@rebmit rebmit Mar 1, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth adding an explicit option for the tmpfiles argument, rather than requiring users to write something like boot.initrd.systemd.tmpfiles.settings.preservation."/sysroot/persistent/etc/machine-id".f.argument.

That would be more ergonomic and less coupled to the implementation details of preservation, making it less likely to break if the implementation changes in the future.

@ThinkChaos ThinkChaos May 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree: having to patch the generated tmpfiles rules is awkward.

I see 2 possible improvements (inclusive or'ed):

  1. add an option like initialContent to preserveAt.*.files
  2. have an opinionated option to setup machine-id properly: preservation.machine-id.preserveAt :: path that sets up everything (a preserveAt.${config.preservation.machine-id.preserveAt}.files entry, and patches the tmpfiles rule & systemd-machine-id-commit.service)

I think 2 would be nicer in the long term: on top of being more ergonomic than 1 (less specific knowledge needed about machine-id, and hiding implementation details better), it avoids users copy-pasting magic configuration that needs to be updated from time to time, which is easy to miss both initially and when updated.

@ThinkChaos ThinkChaos left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated documentation works for me, thank you!

Comment thread docs/src/examples.md
systemd.suppressedSystemUnits = [ "systemd-machine-id-commit.service" ];
boot.initrd.systemd.tmpfiles.settings.preservation."/sysroot/persistent/etc/machine-id".f = {
argument = "uninitialized";
};

@ThinkChaos ThinkChaos May 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree: having to patch the generated tmpfiles rules is awkward.

I see 2 possible improvements (inclusive or'ed):

  1. add an option like initialContent to preserveAt.*.files
  2. have an opinionated option to setup machine-id properly: preservation.machine-id.preserveAt :: path that sets up everything (a preserveAt.${config.preservation.machine-id.preserveAt}.files entry, and patches the tmpfiles rule & systemd-machine-id-commit.service)

I think 2 would be nicer in the long term: on top of being more ergonomic than 1 (less specific knowledge needed about machine-id, and hiding implementation details better), it avoids users copy-pasting magic configuration that needs to be updated from time to time, which is easy to miss both initially and when updated.

Flake lock file updates:

• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/4524271976b625a4a605beefd893f270620fd751?narHash=sha256-%2BuWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw%3D' (2025-09-01)
  → 'github:hercules-ci/flake-parts/f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb?narHash=sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4%3D' (2026-05-13)
• Updated input 'flake-parts/nixpkgs-lib':
    'github:nix-community/nixpkgs.lib/a73b9c743612e4244d865a2fdee11865283c04e6?narHash=sha256-x2rJ%2BOvzq0sCMpgfgGaaqgBSwY%2BLST%2BWbZ6TytnT9Rk%3D' (2025-08-10)
  → 'github:nix-community/nixpkgs.lib/f5901329dade4a6ea039af1433fb087bd9c1fe14?narHash=sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ%3D' (2026-04-26)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/8eb28adfa3dc4de28e792e3bf49fcf9007ca8ac9?narHash=sha256-NOrUtIhTkIIumj1E/Rsv1J37Yi3xGStISEo8tZm3KW4%3D' (2025-09-05)
  → 'github:nixos/nixpkgs/a799d3e3886da994fa307f817a6bc705ae538eeb?narHash=sha256-3av0pIjlOWQ6rDbNOmpUSvbNnJkGORQKKjb4LtCZsIY%3D' (2026-06-06)
@rebmit
rebmit force-pushed the firstboot-systemd-v258 branch from 1566cc1 to b1b12d1 Compare June 15, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

firstboot test fails since systemd v258

3 participants