Skip to content
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-boot: strip newline from machine-id #375298

Merged
merged 1 commit into from
Mar 24, 2025

Conversation

jmbaur
Copy link
Contributor

@jmbaur jmbaur commented Jan 20, 2025

To make each line in the entry file consistent, strip the newline from the machine-id content.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jan 20, 2025
@nix-owners nix-owners bot requested a review from JulienMalka January 20, 2025 10:20
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Jan 20, 2025
@@ -277,7 +277,7 @@ def get_profiles() -> list[str]:
def install_bootloader(args: argparse.Namespace) -> None:
try:
with open("/etc/machine-id") as machine_file:
machine_id = machine_file.readlines()[0]
machine_id = machine_file.readlines()[0].strip()
Copy link
Member

@Mic92 Mic92 Jan 20, 2025

Choose a reason for hiding this comment

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

Looks about right. Systemd will add a newline by default when it writes this file
and we do this:

            f.write("machine-id %s\n" % machine_id)

@jmbaur
Copy link
Contributor Author

jmbaur commented Feb 13, 2025

@Mic92 is this PR good to go?

@Mic92
Copy link
Member

Mic92 commented Feb 14, 2025

@jmbaur have you run one of the systemd boot tests? I know the change is trivial but for bootloader script changes I am always extra careful.

To make each line in the entry file consistent, strip the newline from
the machine-id content.
@jmbaur jmbaur force-pushed the machine-id-no-newline branch from ae30255 to 3de7bcc Compare February 14, 2025 02:52
@jmbaur
Copy link
Contributor Author

jmbaur commented Feb 14, 2025

@ofborg test systemd-boot.basic

@jmbaur
Copy link
Contributor Author

jmbaur commented Feb 14, 2025

@jmbaur have you run one of the systemd boot tests? I know the change is trivial but for bootloader script changes I am always extra careful.

I should've done that awhile ago, thanks! Tested locally by building nixosTests.systemd-boot.basic, unfortunately getting strange ofborg output.

@jmbaur
Copy link
Contributor Author

jmbaur commented Mar 23, 2025

cc @NixOS/systemd

@JulienMalka JulienMalka merged commit e219046 into NixOS:master Mar 24, 2025
32 checks passed
@jmbaur jmbaur deleted the machine-id-no-newline branch March 24, 2025 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants