Skip to content

Conversation

LordGrimmauld
Copy link
Contributor

@LordGrimmauld LordGrimmauld commented Jun 19, 2025

PAM now uses meson to build, so the package needed to essentially be rewritten.
PAM also now uses logind for login limits. To not get infinite recursion, PAM was first stripped from systemdMinimal, then systemdMinimal was used as logind lib.

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/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (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, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@LordGrimmauld
Copy link
Contributor Author

Building docs is super painful

@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 6.topic: systemd Software suite that provides an array of system components for Linux operating systems. labels Jun 19, 2025
@LordGrimmauld LordGrimmauld force-pushed the linux-pam-1.7.1 branch 2 times, most recently from 7093f80 to 849ce72 Compare June 21, 2025 15:45
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 2, 2025
@marcin-serwin
Copy link
Contributor

I was able to build the docs with the following patch:

diff --git a/pkgs/by-name/li/linux-pam/package.nix b/pkgs/by-name/li/linux-pam/package.nix
index ddd7a6db0d..6c00e445e1 100644
--- a/pkgs/by-name/li/linux-pam/package.nix
+++ b/pkgs/by-name/li/linux-pam/package.nix
@@ -16,6 +16,12 @@
   meson,
   pkg-config,
   systemdMinimal,
+  libxslt,
+  libxml2,
+  docbook_xsl_ns,
+  docbook5,
+  findXMLCatalogs,
+  w3m-batch,
 }:
 
 stdenv.mkDerivation (finalAttrs: {
@@ -43,8 +49,8 @@
 
   outputs = [
     "out"
-    # "doc"
-    # "man"
+    "doc"
+    "man"
     # "modules"
   ];
 
@@ -57,6 +63,13 @@
     ninja
     pkg-config
     gettext
+
+    libxslt
+    libxml2
+    w3m-batch
+    findXMLCatalogs
+    docbook_xsl_ns
+    docbook5
   ];
 
   buildInputs = [
@@ -71,6 +84,7 @@
 
   enableParallelBuilding = true;
 
+  mesonAutoFeatures = "auto";
   mesonFlags = [
     (lib.mesonEnable "logind" stdenv.buildPlatform.isLinux)
     (lib.mesonEnable "audit" stdenv.buildPlatform.isLinux)
@@ -81,7 +95,6 @@
     (lib.mesonEnable "elogind" false)
     (lib.mesonEnable "selinux" false)
     (lib.mesonEnable "nis" false)
-    (lib.mesonEnable "docs" false)
     (lib.mesonBool "xtests" false)
     (lib.mesonBool "examples" false)
   ];

@LordGrimmauld
Copy link
Contributor Author

Damn, nice work! I'll see to getting that patch in here and rebasing to solve the merge conflicts. docbook was painful to work with, not super discoverable what is missing. This is very helpful!

@LordGrimmauld LordGrimmauld force-pushed the linux-pam-1.7.1 branch 2 times, most recently from 2d84a35 to 8370c0c Compare July 28, 2025 07:14
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 28, 2025
@LordGrimmauld LordGrimmauld marked this pull request as ready for review July 28, 2025 07:34
@LordGrimmauld LordGrimmauld requested review from leona-ya, marcin-serwin and a team July 28, 2025 07:35
@LordGrimmauld LordGrimmauld force-pushed the linux-pam-1.7.1 branch 3 times, most recently from feb2692 to 494abac Compare July 28, 2025 10:15
@LordGrimmauld
Copy link
Contributor Author

All the tests pass on aarch64, and at least the build passes on x86_64

mesonFlags = [
(lib.mesonEnable "logind" stdenv.buildPlatform.isLinux)
(lib.mesonEnable "audit" stdenv.buildPlatform.isLinux)
(lib.mesonEnable "pam_lastlog" true) # TODO: switch to pam_lastlog2
Copy link
Member

Choose a reason for hiding this comment

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

Should we file a ticket for 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.

The switch to lastlog2 was planned for a while, just, noone actually did it yet because that needs module changes. I can file a ticket, sure. But the old lastlog and lastlog2 are not mutually exclusive, so if we do that switch we don't immediately need to disable old lastlog. Maybe TODO: remove after switch to lastlog2 would have been a better comment...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We had work on lastlog2 in #282337, and it seems our util-linux is new enough to now contain the lastlog2 code (i have not checked whether we enable the build though). I can try how far i get with that, but that is an orthogonal change (should not block this PAM update)

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 opened #429075

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

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

just a small side node

@@ -205,6 +205,8 @@ let
# $ curl -s https://api.github.com/repos/systemd/systemd/releases/latest | \
# jq '.created_at|strptime("%Y-%m-%dT%H:%M:%SZ")|mktime'
releaseTimestamp = "1734643670";

kbd' = if withPam then kbd else kbd.override { withVlock = false; };
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
kbd' = if withPam then kbd else kbd.override { withVlock = false; };
kbd' = kbd.override { withVlock = !withPam; };

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Jul 28, 2025
@LordGrimmauld
Copy link
Contributor Author

Also: I just realized pkgsMusl.pam gives inf rec, so that needs fixing before this is ready...

@LordGrimmauld
Copy link
Contributor Author

Okay, no more inf rec on musl. Required disabling nspawn for systemdLibs, and removing getent (its just used for checking the build configuration outside nspawn).

That said: the patches to make nspawn optional can be removed for systemd 258. Considering we will do a 25.05 staging next, there is no rush and #427968 should probably be merged first.

Comment on lines +261 to +273

# add nspawn build option flag
# required to disable nspawn for systemdLibs to avoid dependency on getent
# https://github.com/systemd/systemd/pull/36876, remove for systemd 258
(fetchpatch {
# required for the actual patch to apply
url = "https://github.com/systemd/systemd/commit/b1fb2d971c810e0bdf9ff0ae567a1c6c230e4e5d.patch";
hash = "sha256-JBheazg1OFkx8vUl2l8+34BoEPVURBQJHxqntOBYB60=";
includes = [ "src/nspawn/meson.build" ];
})
(fetchpatch {
url = "https://github.com/systemd/systemd/commit/d95818f5221d9b9b19648cffa0cb2407f023b27e.patch";
hash = "sha256-FTpWGec5ivlkyEEDMCPaLE+BH91e7JI0kH8pS88bBDY=";
excludes = [ "test/fuzz/meson.build" ];
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: wait for #427968

Copy link
Contributor

Choose a reason for hiding this comment

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

Does anyone even care about linux-pam on musl? Seems like a pretty esoteric use-case to me. I'd want to avoid waiting for the next systemd release (which will takes weeks if not months to land) as the rest of the PR is ready.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we just disable the logind support for now in pam on musl on since that wasn't present before either and re-enable it once we have the new systemd version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thats not the issue. Even if things don't work they should still build. systemd is still required on musl, after all.
The patches exist and seem to work fine, so if the conclusion is not to wait then probably this is ready as-is.

Copy link
Contributor

Choose a reason for hiding this comment

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

I hesitate to say it's a good idea to add patches to systemd to disable something so that some other software can build on a platform systemd doesn't even support.

What I'm thinking is basically something like this to make it build on musl:

index 13e8f55b1f39..21bc5114e38d 100644
--- i/pkgs/by-name/li/linux-pam/package.nix
+++ w/pkgs/by-name/li/linux-pam/package.nix
@@ -66,16 +66,19 @@ stdenv.mkDerivation (finalAttrs: {
     db4
     libxcrypt
   ]
-  ++ lib.optionals stdenv.buildPlatform.isLinux [
-    audit
-    systemdLibs
-  ];
+  ++ lib.optionals stdenv.buildPlatform.isLinux (
+    [
+      audit
+    ]
+    ++ lib.optionals (!stdenv.hostPlatform.isMusl) [
+      systemdLibs
+    ]
+  );

   enableParallelBuilding = true;

   mesonAutoFeatures = "auto";
   mesonFlags = [
-    (lib.mesonEnable "logind" stdenv.buildPlatform.isLinux)
     (lib.mesonEnable "audit" stdenv.buildPlatform.isLinux)
     (lib.mesonEnable "pam_lastlog" (!stdenv.hostPlatform.isMusl)) # TODO: switch to pam_lastlog2, pam_lastlog is deprecated and broken on ml
     (lib.mesonEnable "pam_unix" true)
@@ -87,6 +90,9 @@ stdenv.mkDerivation (finalAttrs: {
     (lib.mesonEnable "nis" false)
     (lib.mesonBool "xtests" false)
     (lib.mesonBool "examples" false)
+  ]
+  ++ lib.optionals (!stdenv.hostPlatform.isMusl) [
+    (lib.mesonEnable "logind" stdenv.buildPlatform.isLinux)
   ];

   doCheck = false; # fails

Copy link
Contributor

@nikstur nikstur Jul 30, 2025

Choose a reason for hiding this comment

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

I'd say we could even get away with not enabling logind at all (for any hostPlatform) because we didn't enable it before and it wasn't even introduced in this release. It was in linux-pam for a while (at least since 1.5.3, see this PR). In a way, you enabling logind here has nothing to do with upgrading the package.

I'm happy with waiting to enable logind support until the next systemd version. But we should get this package bumped asap. This would also allow us to avoid the dance with kbd and systemd entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

utmp has to die, and if logind is the replacement, we should enable it. pam was/is unmaintained in nixpkgs, it was long overdue someone actually took a look at it. As it stands, this PR is a full "lets do it properly" PR.
I also don't see the issue with patching in the nspawn toggle: our systemdLibs does not install nspawn anyways, so we might as well not build it either. This does not actually change anything in the package output, so i am not sure what the fuss is about.

@LordGrimmauld
Copy link
Contributor Author

Hmm, seems musl still fails (this time not inf rec):
meson.build:423:4: ERROR: Problem encountered: pam_lastlog module is enabled but logwtmp() is not available

Not sure how to fix this now. We might have to just disable pam_lastlog and try to do the lastlog2 transition instead

@LordGrimmauld LordGrimmauld force-pushed the linux-pam-1.7.1 branch 2 times, most recently from c6c2c99 to 4644447 Compare July 28, 2025 16:27
@LordGrimmauld
Copy link
Contributor Author

pr fail seems to be rate-limit issue, i'll try to restart that

@arianvp
Copy link
Member

arianvp commented Jul 28, 2025

Hmm, seems musl still fails (this time not inf rec): meson.build:423:4: ERROR: Problem encountered: pam_lastlog module is enabled but logwtmp() is not available

Not sure how to fix this now. We might have to just disable pam_lastlog and try to do the lastlog2 transition instead

Did this ever work?

https://www.openwall.com/lists/musl/2013/12/04/11 seems to suggest this has been an issue for more than a decade.

@LordGrimmauld
Copy link
Contributor Author

#404169
indeed seems this was broken before. So yes, we should probably switch to lastlog2 in hopes of also fixing musl. I suppose lastlog not being built is fine then. We still don't want the inf rec, but disabling lastlog on musl seems reasonable then.

LordGrimmauld and others added 5 commits August 10, 2025 11:04
PAM switched to meson build upstream, which requires some care:
- build with logind support
- reenable lastlog
- clean up autotools remnants
- disable debug as it slows down test making it fail
Co-Authored-by: Marcin Serwin <marcin@serwin.dev>
@K900 K900 merged commit 48a82c8 into NixOS:staging Aug 10, 2025
23 of 27 checks passed
@vcunat vcunat mentioned this pull request Aug 10, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: systemd Software suite that provides an array of system components for Linux operating systems. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants