Unable to increase ulimit nofile

I am looking to increase the maximum no. of open file descriptors in nixos using the following

security.pam.loginLimits = [
      {domain = "*";type = "-";item = "memlock";value = "infinity";}
      {domain = "*";type = "-";item = "nofile";value = "8192";}

I did both sudo nixos-rebuild switch and reboot. However, I still get 1024, when I do ulimit -a? Is there something that I am missing?

but looking at googlechrome.nix - ghuntley/ghuntley - Sourcegraph

there might be something else wrong.

i just tried

    security.pam.loginLimits = [
    { domain = "*"; item = "nofile"; type = "-"; value = "65536"; }

and it worked???

Tried, that. ulimit -a still reports 1024.

Interesting… you may have to file a bug , I’m stumped.

You might want to configure this via user slices instead, as systemd will most likely ignore/override what’s set via limits.conf/PAM.

See also systemd.resource-control

Not super related to the discussion above, but for systemd services, you want to do:

systemd.services.<name>.serviceConfig.LimitNOFILE = <uint>;

A users login is not a service, what unit type should we use instead?

A user’s login is part of the instantiated service user@.service, whose resources are controlled by the corresponding slice user-%U.slice, so on most systems this would be:
user@1000.service and user-1000.slice.

Run systemctl show user-1000.slice to see what resources are currently set.
You might be able to override them as suggested by @jonringer by setting LimitNOFile for user@1000.service.

1 Like

is this something that has changed? because the OP’s code works in 21.11

My nixos version

$ nixos-version
22.05pre353535.48d63e924a2 (Quokka)

Is there a particular property name that I should be looking at? I executed the command but see no property related to NOFile

Done. opened as issue. https://github.com/NixOS/nixpkgs/issues/159964

it quite possible unstable has a regression on this.

Thanks. If you want a smother ride , down grade to stable.

Unless you want to help us fix stuff , which quite welcome too.