I3lock not configured correctly maybe due to bad PAM configurtion in default NixOS?

i3lock does not appear to be functioning correctly anymore. Anytime I input the correct password, it refused to unlock. I have been able to unlock by going to tty2 and running pkill i3lock after logging into that terminal session.

I also verified the password I was giving i3lock by running i3lock --debug in my terminal. It prints my key presses and I was able to see that I was in fact inputting my password correctly.

I did some research and it seems like this could be a setup issue on Nixos’s side of things? Specifically related to PAM. I have not touched PAM at all in my configuration but perhaps someone else is more familiar with what’s going on?

It seems to be related to a recent change on PAM handling. Which version of Nixpkgs are you following?

I am following the unstable branch.

    "nixpkgs": {
      "locked": {
        "lastModified": 1746141548,
        "narHash": "sha256-IgBWhX7A2oJmZFIrpRuMnw5RAufVnfvOgHWgIdds+hc=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "f02fddb8acef29a8b32f10a335d44828d7825b78",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },

Have you set programs.i3lock.enable to true?

Oh you know what, I do not. I did not do this because my i3lock installed manually through my home manager config.

I guess I’ll need to do something hacky here, but I can figure it out. I was trying to setup everything as much as possible through home manager, but it looks like that’s not really going to be possible here.

Okay unfortunately, I’m not completely sure that’s it. I am using the i3lock provided through programs.i3lock.enable.

Hmm. A few things to test:

  • Is there a symlink at /etc/pam.d/i3lock?
  • In a REPL loaded with your NixOS config (on a channels-based system, I’d do this with nix repl --file '<nixpkgs/nixos>'; I don’t know if that works for flakes too), can you confirm that
    • config.programs.i3lock.enable is definitely true?
    • config.security.pam.services.i3lock.enable is also true?

OH well I can confirm no such symlink exists on my system

So with flakes, I did the following

$ nix repl

nix-repl> x = builtins.getFlake “/path/to/project/dir”
nix-repl> x.nixosConfigurations.solaris.options.programs.i3lock.enable

{
__toString = «lambda __toString @ /nix/store/zggank8h7rfa8p2rrnwymjcpj3k4ds5l-source/lib/modules.nix:1091:20»;
_type = “option”;
declarationPositions = [ … ];
declarations = [ … ];
default = false;
definitions = [ … ];
definitionsWithLocations = [ … ];
description = “Whether to enable i3lock.”;
example = true;
files = [ … ];
highestPrio = 100;
isDefined = true;
loc = [ … ];
options = [ … ];
type = { … };
value = true;
}

But then take a look at this.

nix-repl> x.nixosConfigurations.solaris.options.security.pam.services.i3lock.enable
error: attribute ‘i3lock’ missing
at «string»:1:1:
1| x.nixosConfigurations.solaris.options.security.pam.services.i3lock.enable
| ^

I was able to autocomplete this until I got to the “security” attribute.

You’re showing me the options. tree; check config. instead please?

nix-repl> x.nixosConfigurations.solaris.config.programs.i3lock.enable
true

nix-repl> x.nixosConfigurations.solaris.config.security.pam.services.i3lock.enable
true

Sorry for the late reply, here we go!

I’m at a loss. With those values set to true, I don’t see how it could be possible that a system gets built without an /etc/pam.d/i3lock symlink. I guess double-check that you’re building what you think you’re building?

Hmmm weird, I just checked and have the symlink now and everything works. I did update my flakes sometime during this. But I think it’s very likely possible I mixed up configurations and didn’t have it enabled correctly either. I’m very sorry for the troubles. It looks like things are working find again.

After migrating von NixOS 24.11 (based on nix-channels) to NixOS 25.05 (switched to nix-flakes) I experienced the same issues.
The last time I touched my i3 and pam.d related config was 2 years ago.

So I assume that the way NixOS implements the pam.d related configuration was modified.
Edit: @GirardR1006 was right → I3lock not configured correctly maybe due to bad PAM configurtion in default NixOS? - #2 by GirardR1006

Your hints were very helpful to me to fix the issue on my machines - thank you for documenting your approach.

Same issue happend to me when I upgraded from the stable 25.05 channel to the unstable channel.

Before my config to install i3 was:

  services.xserver = {
    # enable = true;
    desktopManager = {
      xterm.enable = false;
    };
    windowManager.i3 = {
      enable = true;
      extraPackages = with pkgs; [
        dmenu #application launcher most people use
        i3status # gives you the default i3 status bar
        i3lock #default i3 screen locker
        i3blocks #if you are planning on using i3blocks over i3status
     ];
    };
  };

And I changed it to:

services.xserver = {
    # enable = true;
    desktopManager = {
      xterm.enable = false;
    };
    windowManager.i3 = {
      enable = true;
      extraPackages = with pkgs; [
        dmenu #application launcher most people use
        i3status # gives you the default i3 status bar
        i3blocks #if you are planning on using i3blocks over i3status
     ];
    };
  };
  programs.i3lock.enable = true;

Note that I added programs.i3lock.enable = true; and removed i3lock from the extra packages.

This has just been fixed: nixos/i3: fix i3lock default enable-ing by Ten0 · Pull Request #417193 · NixOS/nixpkgs · GitHub

Wait, are you saying I no longer need to use the program option anymore?

If you set services.xserver.windowManager.i3.enable = true;, yes. (Assuming the PR has hit the channel already. Haven’t checked.)

Ahh I guess it won’t apply to me. I do not use the full i3 suite.