-
Notifications
You must be signed in to change notification settings - Fork 18
update firstboot examples in docs and tests #23
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
Open
rebmit
wants to merge
5
commits into
nix-community:main
Choose a base branch
from
rebmit:firstboot-systemd-v258
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b607860
tests/flake.lock: Update
rebmit c076add
tests: unbreak tests after flake update
rebmit f35e9e4
docs: update firstboot examples for systemd v258 compatibility
rebmit dbe64eb
tests: fix failed tests using new firstboot-compatible examples
rebmit b1b12d1
ci: run separate firstboot-bind-mount and firstboot-symlink tests
rebmit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| pkgs: | ||
| { | ||
| name = "preservation-firstboot-symlink"; | ||
|
|
||
| nodes.machine = | ||
| { pkgs, ... }: | ||
| { | ||
| imports = [ ../module.nix ]; | ||
|
|
||
| preservation = { | ||
| enable = true; | ||
| preserveAt."/persistent" = { | ||
| files = [ | ||
| { | ||
| file = "/etc/machine-id"; | ||
| inInitrd = true; | ||
| how = "symlink"; | ||
| configureParent = true; | ||
| createLinkTarget = true; | ||
| } | ||
| ]; | ||
| }; | ||
| }; | ||
|
|
||
| boot.initrd.systemd.tmpfiles.settings.preservation."/sysroot/persistent/etc/machine-id".f = { | ||
| argument = "uninitialized"; | ||
| }; | ||
|
|
||
| systemd.services.systemd-machine-id-commit = { | ||
| unitConfig.ConditionPathIsMountPoint = [ | ||
| "" "/persistent/etc/machine-id" | ||
| ]; | ||
| serviceConfig.ExecStart = [ | ||
| "" "systemd-machine-id-setup --commit --root /persistent" | ||
| ]; | ||
| }; | ||
|
|
||
| # test-specific configuration below | ||
| boot.initrd.systemd.enable = true; | ||
|
|
||
| networking.useNetworkd = true; | ||
|
|
||
| virtualisation = { | ||
| memorySize = 2048; | ||
| # separate block device for preserved state | ||
| emptyDiskImages = [ 23 ]; | ||
| fileSystems."/persistent" = { | ||
| device = "/dev/vdb"; | ||
| fsType = "ext4"; | ||
| neededForBoot = true; | ||
| autoFormat = true; | ||
| }; | ||
| }; | ||
|
|
||
| }; | ||
|
|
||
| testScript = | ||
| { nodes, ... }: | ||
| # python | ||
| '' | ||
| machine.start(allow_reboot=True) | ||
| machine.wait_for_unit("default.target") | ||
|
|
||
| with subtest("Initial boot meets ConditionFirstBoot"): | ||
| machine.require_unit_state("first-boot-complete.target","active") | ||
|
|
||
| with subtest("Machine ID linked and populated"): | ||
| machine.succeed("test -L /etc/machine-id") | ||
| machine.succeed("test -s /persistent/etc/machine-id") | ||
| machine_id = machine.succeed("cat /etc/machine-id") | ||
| t.assertNotEqual("uninitialized", machine_id, "machine id not populated") | ||
|
|
||
| with subtest("Machine ID persisted"): | ||
| first_id = machine.succeed("cat /etc/machine-id") | ||
| machine.reboot() | ||
| machine.wait_for_unit("default.target") | ||
| second_id = machine.succeed("cat /etc/machine-id") | ||
| t.assertEqual(first_id, second_id, "machine-id changed") | ||
|
|
||
| with subtest("Second boot does not meet ConditionFirstBoot"): | ||
| machine.require_unit_state("first-boot-complete.target", "inactive") | ||
|
|
||
| machine.shutdown() | ||
| ''; | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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):
initialContenttopreserveAt.*.filespreservation.machine-id.preserveAt :: paththat sets up everything (apreserveAt.${config.preservation.machine-id.preserveAt}.filesentry, 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.