NixOS / nixos

OBSOLETE (go to NixOS/nixpkgs) - NixOS, a Linux distribution based on the Nix package manager - OBSOLETE (go to NixOS/nixpkgs)
MIT License
176 stars 102 forks source link

set ulimits #293

Closed peterromfeldhk closed 8 years ago

peterromfeldhk commented 9 years ago

Hi,

I already sent a mail to dev-nix but i figured here would be a better place ;)

i would like to be able to set ulimits in nixstyle

example:

security.ulimits = { ejabberd = { soft = { nofile = 65536; nproc = 65536; }; hard = { nofile = 65536; nproc = 65536; }; }; };

which translates in standard linux /etc/security/limits.d/ejabberd.conf

ejabberd soft nofile 65536 ejabberd hard nofile 65536 ejabberd hard nproc 65536 ejabberd soft nproc 65536

cheers, peter

bjornfor commented 9 years ago

(The nixos tree is deprecated, use nixpkgs tree instead.)

You can use the security.pam.loginLimits option for this.

atcol commented 8 years ago

Is anyone able to provide an example of a working security.pam.loginLimits? My nixos-rebuild switch --upgrade worked but the default limits are still used. Here's what I had:

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

which is wrong as - isn't a wildcard. I used * instead for domain which sets the defaults, as-per man limits.conf. Here's a complete example for anyone who stumbles on this:

  security.pam.loginLimits = [{
    domain = "*";
    type = "soft";
    item = "nofile";
    value = "4096";
  }];