Skip to content

nixos/logind: migrate to settings option#435407

Merged
flokli merged 1 commit intoNixOS:masterfrom
Stunkymonkey:nixos/logind-LidSwitchIgnoreInhibited
Aug 25, 2025
Merged

nixos/logind: migrate to settings option#435407
flokli merged 1 commit intoNixOS:masterfrom
Stunkymonkey:nixos/logind-LidSwitchIgnoreInhibited

Conversation

@Stunkymonkey
Copy link
Copy Markdown
Contributor

@Stunkymonkey Stunkymonkey commented Aug 20, 2025

add services.logind.settings

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@Stunkymonkey Stunkymonkey marked this pull request as ready for review August 20, 2025 21:48
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 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 Software suite that provides an array of system components for Linux operating systems. labels Aug 20, 2025
@aanderse
Copy link
Copy Markdown
Member

oh... i thought we had a settings option here now

dang 😞

@Stunkymonkey
Copy link
Copy Markdown
Contributor Author

@aanderse maybe i should provide the settings option instead...?

@Stunkymonkey Stunkymonkey changed the title nixos/logind: add lidSwitchIgnoreInhibited option nixos/logind: migrate to settings option Aug 21, 2025
@Stunkymonkey Stunkymonkey force-pushed the nixos/logind-LidSwitchIgnoreInhibited branch from b4e3726 to 68eee75 Compare August 21, 2025 18:44
@Stunkymonkey Stunkymonkey marked this pull request as draft August 21, 2025 18:47
@aanderse
Copy link
Copy Markdown
Member

wow! what a generous offer @Stunkymonkey! i bet @LordGrimmauld appreciates the effort... i certainly do. thanks! 🚀

@Stunkymonkey Stunkymonkey force-pushed the nixos/logind-LidSwitchIgnoreInhibited branch 3 times, most recently from e38fdcc to c32d4d9 Compare August 21, 2025 19:08
@Stunkymonkey
Copy link
Copy Markdown
Contributor Author

@aanderse i am not an expert in deprecating options. But this is my first draft. So please help me out, what should be improved.

@Stunkymonkey Stunkymonkey force-pushed the nixos/logind-LidSwitchIgnoreInhibited branch from c32d4d9 to c35ec3a Compare August 21, 2025 19:17
@Stunkymonkey Stunkymonkey marked this pull request as ready for review August 21, 2025 19:20
@LordGrimmauld
Copy link
Copy Markdown
Contributor

Oh hey, more rfc 42 in systemd things, love to see it! I'll take a closer look tomorrow, but the over all approach looks reasonable enough. Care needs to be taken to ensure things like nixos VM tests still evaluate, though the rename redirects already do help a lot in that regard. I'll take a closer look once i have the time.

@LordGrimmauld LordGrimmauld self-requested a review August 21, 2025 20:16
@Stunkymonkey
Copy link
Copy Markdown
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 435407
Commit: c35ec3a8bdaba2cff3542ee9d9d03de5fd135824


x86_64-linux

⏩ 2 packages blacklisted:
  • nixos-install-tools
  • tests.nixos-functions.nixos-test
✅ 5 packages built:
  • tests.devShellTools.nixos
  • tests.testers.lycheeLinkCheck.network
  • tests.testers.nixosTest-example
  • tests.testers.runNixOSTest-example (tests.testers.runNixOSTest-extendNixOS)
  • tests.trivial-builders.references

@LordGrimmauld
Copy link
Copy Markdown
Contributor

side note, not relevant for this PR: seems i joined the systemd team, but am not listed in the systemd-related code owners listings. I'll have to open a PR to add myself to those too, then i'd have gotten a ping at the very beginning.

Copy link
Copy Markdown
Contributor

@ElvishJerricco ElvishJerricco left a comment

Choose a reason for hiding this comment

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

This should probably be done the way systemd.settings.Manager was done:

settings.Manager = mkOption {
default = { };
defaultText = lib.literalExpression ''
{
DefaultIOAccounting = true;
DefaultIPAccounting = true;
}
'';
type = lib.types.submodule {
freeformType = types.attrsOf unitOption;
};

For one thing, systemd conf files are not exactly the same as INI, as close as they might be. So the utils.systemdUtils.unitOptions.unitOption type, and the utils.systemdUtils.lib.attrsToSection function are the correct ones to use.

And we decided with settings.Manager that it was probably better to just explicitly have settings.Manager as the option, rather than having settings as an attrsOf of sections, because that config file allows only the one section. It's just a little more specific, leaves less room for people to mistakenly use the wrong section name, and still allows us to switch to attrsOf for more sections in the future if systemd ever adds more sections to that conf file. I suggest we do the same here for logind.

@Stunkymonkey Stunkymonkey force-pushed the nixos/logind-LidSwitchIgnoreInhibited branch from c35ec3a to c562c50 Compare August 21, 2025 22:00
@Stunkymonkey
Copy link
Copy Markdown
Contributor Author

@ElvishJerricco i adjusted the code. But the type lib.types.attrsOf utils.systemdUtils.unitOptions.unitOption; might be off? Appart from that. Is the new version in the way you like?

@Stunkymonkey
Copy link
Copy Markdown
Contributor Author

hey @LordGrimmauld,
please look at it now again. I was just going through them one-by-one to not miss anything. One thread is not perfectly done, but i commented on it.

@Stunkymonkey Stunkymonkey force-pushed the nixos/logind-LidSwitchIgnoreInhibited branch from 3111154 to 89526e1 Compare August 24, 2025 16:52
Copy link
Copy Markdown
Contributor

@LordGrimmauld LordGrimmauld left a comment

Choose a reason for hiding this comment

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

I'd still like to have a proper discussion with the systemd folks about whether we should align KillUserProcesses with upstream systemd defaults, but as a 1:1 migration this PR looks pretty good. That discussion can happen elsewhere. Thank you :)

@LordGrimmauld
Copy link
Copy Markdown
Contributor

I forgot to say, i did run the login nixos test successfully. That is probably the only one that is immediately relevant here.

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Aug 24, 2025
Copy link
Copy Markdown
Contributor

@r-vdp r-vdp left a comment

Choose a reason for hiding this comment

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

LGTM, I'll leave it to the systemd team to merge.

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Aug 24, 2025
'';
type = lib.types.submodule {
freeformType = lib.types.attrsOf utils.systemdUtils.unitOptions.unitOption;
options.KillUserProcesses = lib.mkOption {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This workaround might not be needed anymore at all, and we should probably drop this entirely (and add/update release notes).

tmux now spawns panes in separate cgroups, see tmux/tmux#3514.

@flokli flokli merged commit 6d3383c into NixOS:master Aug 25, 2025
32 of 34 checks passed
@flokli
Copy link
Copy Markdown
Member

flokli commented Aug 25, 2025

Let's deal with not overriding the upstream default in our defaults in a followup.

@Stunkymonkey
Copy link
Copy Markdown
Contributor Author

@flokli i am all for it. I first wanted migrate to the rfc42 style without changing the behavior.

brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Aug 26, 2025
NixOS/nixpkgs#435407

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Aug 26, 2025
NixOS/nixpkgs#435407

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
DaRacci added a commit to DaRacci/Jovian-NixOS that referenced this pull request Aug 26, 2025
There is a breaking change that landed in the upstream from this PR NixOS/nixpkgs#435407
@K900
Copy link
Copy Markdown
Contributor

K900 commented Aug 26, 2025

No backwards compatibility, seriously?

@LordGrimmauld
Copy link
Copy Markdown
Contributor

No backwards compatibility, seriously?

Hm, what do you mean? There is rename modules for the things that were renamed, just extraConfig was removed because that one just does not have an equivalent

@K900
Copy link
Copy Markdown
Contributor

K900 commented Aug 26, 2025

It would be nice to keep extraConfig at least for a time.

@LordGrimmauld
Copy link
Copy Markdown
Contributor

We did not retain extraConfig in #426692 either, so i did not assume it would be necessary. Further, jovians usage of extraConfig to set HandlePowerKey should have been replaced long ago: 520150f introduced the services.logind.powerKey option for that two years ago. I am not sure what retaining extraConfig would have helped if two years were not enough to migrate to the dedicated option there.

That said, yes, there is different things that did not have their dedicated options before. In those cases, retaining extraConfig could have helped. Is there any place where retaining obsolete extraConfig for backwards-compat is documented? I certainly didn't know that is something we can/should do (frankly, i disagree with letting anti-patterns live and be forgotten about).

brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Aug 28, 2025
NixOS/nixpkgs#435407

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Aug 31, 2025
NixOS/nixpkgs#435407

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Sep 1, 2025
NixOS/nixpkgs#435407

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Sep 1, 2025
NixOS/nixpkgs#435407

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Sep 2, 2025
NixOS/nixpkgs#435407

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Sep 3, 2025
NixOS/nixpkgs#435407

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
brianmcgillion added a commit to tiiuae/ghaf that referenced this pull request Sep 3, 2025
NixOS/nixpkgs#435407

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
unlsycn pushed a commit to unlsycn/Jovian-NixOS that referenced this pull request Sep 19, 2025
There is a breaking change that landed in the upstream from this PR NixOS/nixpkgs#435407
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 Software suite that provides an array of system components for Linux operating systems. 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants