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

initrd: implement panic-on-fail interpreterless #390698

Merged

Conversation

britter
Copy link
Contributor

@britter britter commented Mar 17, 2025

In order to have initrd not depend on an interpreter like bash being present.

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.

@britter britter requested a review from WilliButz March 17, 2025 15:26
@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/` 6.topic: systemd labels Mar 17, 2025
@ofborg ofborg bot added the ofborg-internal-error Ofborg encountered an error label Mar 17, 2025
@britter britter force-pushed the britter/bashless/initrd/panic-on-fail branch from 48f522a to c88b299 Compare March 18, 2025 10:45
@ofborg ofborg bot removed the ofborg-internal-error Ofborg encountered an error label Mar 18, 2025
@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 Mar 18, 2025
@ElvishJerricco
Copy link
Contributor

ElvishJerricco commented Mar 18, 2025

In order to have initrd not depend on an interpreter like bash being present.

For the record, there are other script-based services in systemd initrd. But yea this is a step in that direction :)

I think the dd output summary will be a bit of log spam. It'll probably output something like this to the journal.

0+1 records in
0+1 records out
1 byte copied, 2.017e-05 s, 49.6 kB/s

We could instead do something like this maybe:

        serviceConfig = {
          Type = "oneshot";
          ExecStart = "${pkgs.coreutils}/bin/echo c";
          StandardOutput = "file:/proc/sysrq-trigger";
        };

Haven't tested it, but I assume it would work.

EDIT: I just realized how silly it is to worry about log spam in a service that crashes the kernel...

@britter
Copy link
Contributor Author

britter commented Mar 18, 2025

For the record, there are other script-based services in systemd initrd.

Yes that's true. This one was the easiest to fix because it does not require writing a new program. I think @WilliButz is working on replacing the other script uses with a Rust program.

@britter
Copy link
Contributor Author

britter commented Mar 18, 2025

@ElvishJerricco I think you're still raising a good point. Also your echo solution is more straight forward. I'm going add this change.

@britter britter force-pushed the britter/bashless/initrd/panic-on-fail branch from c88b299 to deb045e Compare March 19, 2025 09:23
Copy link
Member

@WilliButz WilliButz left a comment

Choose a reason for hiding this comment

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

Thank you!

@WilliButz WilliButz merged commit 4edfeaf into NixOS:master Mar 19, 2025
25 of 28 checks passed
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 6.topic: systemd 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