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/acpid: refactor and add initrd support #277898

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

outfoxxed
Copy link
Contributor

Description of changes

Adds initrd/stage1 support to the acpid module. Also pretty much a complete refactor.

Things done

Tested stage1 and stage2 support in personal configurations using powerEventCommands and handlers.

(self) Reviewed points
  • changes are backward compatible
  • (N/A) removed options are declared with mkRemovedOptionModule
  • (N/A) changes that are not backward compatible are documented in release notes
  • (N/A) module tests succeed on ARCHITECTURE
  • options types are appropriate
  • options description is set
  • options example is provided
  • documentation affected by the changes is updated

Add a 👍 reaction to pull requests you find important.

@outfoxxed
Copy link
Contributor Author

Not sure why docs are failing. Building locally with the same command CI runs gives this

> NIX_PATH=nixpkgs=$(pwd) nix-build --option restrict-eval true nixos/release.nix -A manual.x86_64-linux
/nix/store/1zw2hk2x57bg2cb78g9lwfmq7m8qb4ka-nixos-manual-html

I did notice that the options listing is missing the boot.initrd.services.acpid entries, but I have no idea why.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/3239

Comment on lines +6 to +7
stage1Cfg = config.boot.initrd.services.acpid;
stage2Cfg = config.services.acpid;
Copy link
Member

Choose a reason for hiding this comment

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

This might be confusing as initrd has stage 1 and 2, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so would initrdCfg / mainCfg work? I'm not sure what to name the one under config.services.

nixos/modules/services/hardware/acpid.nix Outdated Show resolved Hide resolved
nixos/modules/services/hardware/acpid.nix Outdated Show resolved Hide resolved
nixos/modules/services/hardware/acpid.nix Outdated Show resolved Hide resolved
'' + lib.optionalString (!stage2) ''

::: {.note}
Many events will require kernel modules to be available via `boot.initrd.availableKernelModules`.
Copy link
Member

Choose a reason for hiding this comment

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

Are there any other useful information we can give or link how to know which ones are required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +137 to +138
# Acpid requires /var/run to exist but dosen't create it, and no systemd service seems to create it either.
# Note this is only a problem for stage1.
Copy link
Member

Choose a reason for hiding this comment

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

We should rather patch this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Patch what here? Making acpid create or link /var/run seems out of scope imo.

nixos/modules/services/hardware/acpid.nix Outdated Show resolved Hide resolved
Comment on lines +140 to +141
ln -s /run /var/run || true

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ln -s /run /var/run || true

${cfg.package}/bin/acpid \
--foreground \
--netlink \
--confdir "${acpiConfFor cfg}/handlers" \
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the trailing \ causing problems when logEvents is not appended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it behaves similarly to running it interactively

> echo hi \
>  \
>  \
>  \
>
hi
>

boot.initrd.services.acpid = options false;
};

config = mkMerge [
Copy link
Member

Choose a reason for hiding this comment

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

We shoudl avoid mkMerge on config. For me that often caused hard to debug infinite recusions but I am not sure if that was only on me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've never experienced this issue and mkMerge assists readability a lot. Would you mind linking relevant issues so I can try to reproduce it or work around it?

@outfoxxed
Copy link
Contributor Author

Not sure if that commit should be squashed or not

@deviantsemicolon
Copy link
Contributor

it would be so based if this got merged 🥺

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/3635

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants