In which package, useradd command is bundled?

I’m trying to use useradd command in the script, which will be running on NixOS. I was trying to call this binary this way:

${pkgs.useradd}/bin/useradd -m user

But this idea failed, because, there’s no such package. So I want to know, in which package, useradd binary goes included, to be able to call it in such way

${pkgs.packageContainingUseradd}/bin/useradd -m user

Apparently it is in ‘shadow’:

$ nix-locate bin/useradd | grep -v "^("
shadow.out                                      144,648 x /nix/store/nsls44jp1bhbiianmnj67f2g5rvl7yzm-shadow-4.8/bin/useradd
1 Like

As a sidenote, I’d recommend managing users declaratively through users.users instead of using adduser or useradd.


Yep. That’s a better practice in terms of NixOS. But in my particular case, it just simpler to create user imperatively, then trying to update .nix configs via script, using sed or awk

It’s highly dependent on exactly what you’re doing, but you might be able to use fromJSON: