Commit graph

140 commits

Author SHA1 Message Date
Franz Pletz da37904672
Merge pull request #246772 from R-VdP/nixos-user-expiry
nixos/update-users-groups: add support for account expiry
2023-08-26 02:41:34 +02:00
Lily Foster e9207b0501
nixos/*: unhide remaining systemd stage-1 options
These options were missed in NixOS/nixpkgs#226237, but they all were
specifically added for systemd stage-1.
2023-07-03 08:41:38 -04:00
Victor Engmark b0a9abedea refactor: Use dummy variable name for unused value
As recommended by ShellCheck
<https://github.com/koalaman/shellcheck/wiki/SC2034>.
2023-06-08 15:11:35 +12:00
Will Fancher e70b42bf61 systemd-initrd: Add users and groups with static IDs. 2023-04-12 13:55:50 -04:00
Jan Tojnar 5a3eb4f6fe nixos/users-groups: Fix password scheme validation
0d7cd66652 broke validation for hashes with options
such as those generated with `mkpasswd --method=sha-512 --rounds=1000000`:

    $6$rounds=1000000$xpzZ6Rfg873gZnDY$RxS7lpVnohfDrrKG3lt9UFHED1KoiPGzH7zQv/HzwalZepo/IfFtxw05ap25duEJSKYhC14.Fn9eXszEpWVtF.

This fixes it.
2023-04-03 02:16:07 +02:00
github-actions[bot] f2ead7fbda
Merge master into staging-next 2023-03-24 12:01:43 +00:00
Ryan Lahfa a119bfc80d
Merge pull request #211603 from farcaller/fish
Assert that fish configuration is enabled if any user has fish as their shell
2023-03-24 12:05:22 +01:00
Martin Weinelt 0d7cd66652
nixos/users-groups: Update password scheme validation
Updates the warnings message for statefully set up passwords, now that
weak algorithms have been removed from our libxcrypt package.

Additionall we now add proper validation for hashing schemes used in
`hashedPassword`.

Neither will prevent a rebuiild, but instead issue a warning, that this
requires immediate remediation, or else users will be unable to login.

Reuses the crypt scheme ids as provided by the libxcrypt package.
2023-03-13 07:54:27 +01:00
Lily Foster c56e5ef801 nixos/users-groups: update option description to clarify initial* option precedence 2023-02-25 14:27:35 -05:00
Sandro d26c778ade
Merge pull request #153127 from eyJhb/user-uids-fix
nixos/users+nixos/lightdm: fixed users starting at 1000, and system users below 1000
2023-01-30 11:32:10 +01:00
Vladimir Pouzanov 631b7f6f88 Add support for the other shells 2023-01-19 16:59:11 +00:00
Vladimir Pouzanov 59296fbbc3 Assert that fish configuration is enabled if any user has fish as their shell.
Suggested-By: matthiasbeyer
2023-01-19 16:28:54 +00:00
pennae 4c1cfbdb84 modules: add mkAliasOptionModuleMD
mkAliasOptionModule should not default to mdDoc descriptions because
that can break out-of-tree users of documentation infrastructure. add an
explicitly-MD variant for now, to be removed some time after the MD
transition is complete.
2023-01-05 02:33:13 +01:00
Sandro 73c0b5c4e8 nixos/users-groups: make isNormalUser description readable 2022-12-27 18:23:21 +01:00
figsoda 7dfc2a1369 nixos/user-groups: remove unnecessary parentheses 2022-11-30 17:58:55 -05:00
zimbatm 9da75fdaf1
nixos/update-users-groups: add support for account expiry
Introduce a `users.users.<name>.expires` option to allows setting an
expiry date to user accounts.

This is useful when members should gain temporary access and you don't
want to have to roll out another system update to disable them.
2022-11-30 21:09:41 +01:00
Martin Weinelt 78155df21d
nixos/users-groups: Warn about deprecated hashes at activation
To allow for a reasonably fast deprecation of weak password hashing
schemes we provide an activation script that checks existing hashes in
/etc/shadow and issues a warning for user accounts that still rely on
deprecated hashes.

Co-Authored-By: oxalica <oxalicc@pm.me>
2022-11-19 14:07:59 +01:00
Martin Weinelt f391e6dbcc
nixos/user: Don't recommend mkpasswd methods
Instead rely on the default, which at this time is yescrypt.
2022-11-19 14:07:59 +01:00
Franz Pletz 32e7482074
nixos/tests/shadow: new hashes support with libxcrypt 2022-10-09 18:09:41 +02:00
pennae 7f6d0d1674 nixos/users-groups: convert remaining descriptions to MD
manpage is unchanged, html change is only in whitespace
2022-08-27 19:18:29 +02:00
pennae 61e93df189 nixos/*: automatically convert option docs to MD
once again using nix-doc-munge (69d080323a)
2022-08-03 22:46:41 +02:00
pennae 3aebb4a2be nixos/*: normalize link format
make (almost) all links appear on only a single line, with no
unnecessary whitespace, using double quotes for attributes. this lets us
automatically convert them to markdown easily.

the few remaining links are extremely long link in a gnome module, we'll
come back to those at a later date.
2022-08-03 21:57:46 +02:00
pennae 9c8531c8a5 nixos/*: replace <replaceable>s with «thing»
we can't embed syntactic annotations of this kind in markdown code
blocks without yet another extension. replaceable is rare enough to make
this not much worth it, so we'll go with «thing» instead. the module
system already uses this format for its placeholder names in attrsOf
paths.
2022-08-03 21:08:58 +02:00
pennae 16102dce2f nixos/*: replace <code> in option docs with <literal>
markdown can't represent the difference without another extension and
both the html manual and the manpage render them the same, so keeping the
distinction is not very useful on its own. with the distinction removed
we can automatically convert many options that use <code> tags to markdown.

the manpage remains unchanged, html manual does not render
differently (but class names on code tags do change from "code" to "literal").
2022-08-03 21:03:23 +02:00
pennae 2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00
Klemens Nanni 574a90771f lib.types, nixos/users: Make passwdEntry available
More nixpkgs code such as `boot.initrd.systemd.emergencyAccess` defines
options that takes hashed passwords, so move the type definition from
modules/ into lib/.

The type definition itself stays unchanged.
2022-06-25 16:34:47 +04:00
Janne Heß e9bdd5fa74
Merge pull request #168168 from fedeinthemix/home-mode
nixos/users-group: Add 'homeMode' option.
2022-05-23 12:27:49 +02:00
Jared Baur 5463b86d03
nixos/users: Fix typo 2022-05-22 22:13:39 -07:00
Federico Beffa 311aa6d05d nixos/users-group: Update description of 'homeMode' option. 2022-05-14 11:59:44 +02:00
Federico Beffa 9fc01af1cc nixos/users-group: Add 'homeMode' option. 2022-04-11 13:16:38 +02:00
eyjhb db74bf5375
nixos/users: isSystemUser below 1000 above 400
To reflect changes done in 23d920c8f0
2022-02-26 22:53:03 +01:00
Robert Hensing e3cfad0b9e nixos/users: Fix type error
Fixes what seems to be a programming error that went undetected by
me and @pasqui23

See https://github.com/NixOS/nixpkgs/issues/158279
2022-02-05 22:38:56 +01:00
Pasquale 07abf6942f
nixos/users:added users.allowLoginless
Correct the assertion logic

Fixed indentation

Better wording od allowLoginless' description

Co-authored-by: Eelco Dolstra <edolstra@gmail.com>

Better formatting

Co-authored-by: Eelco Dolstra <edolstra@gmail.com>

allowLoginless -> allowNoPasswordLogin

Clarified users.allowNoPasswordLogin's  description

Clarified assertion expression

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>

Reworded assertion message to gude to safer alternative
2022-02-05 16:00:55 +01:00
Nikolay Amiantov f2c5970a76 users-groups service: add autoSubUidGidRange option
Previously we allocated subuids automatically for all normal users.
Make this explicitly configurable, so that one can use this for system
users too (or explicitly disable for normal users). Also don't allocate
automatically by default if a user already has ranges specified statically.
2022-01-09 09:43:55 +03:00
Artturin fc4df13e26 nixos: add sgx group with gid 304
fix Unknown group 'sgx', ignoring message from udev
2021-12-05 01:37:43 +02:00
Naïm Favier 2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
Guillaume Girol 3592034595
Merge pull request #133166 from symphorien/nonogroup
Don't default to nogroup for the primary group of users.
2021-09-13 18:29:21 +00:00
Janne Heß a851b4d20e
nixos/users-groups: Add dry mode 2021-09-07 10:30:42 +02:00
Guillaume Girol 0f15a8f489 nixos/users-groups: don't default users.users.<name>.group to nogroup
this is unsafe, as many distinct services may be running as the same
nogroup group.
2021-09-03 21:22:07 +02:00
Silvan Mosberger ea00f991c0 nixos/users: Populate group members option
This change makes it so that accessing config.users.groups.*.members isn't
empty by default, but instead contains all the users whose `extraGroups`
includes that group, allowing fancy things like

  { config, ... }: {
    users.groups.libvirt.members = config.users.groups.wheel.members;
  }

to add all users in the wheel group to the libvirt group
2021-08-08 18:40:06 +02:00
Ben Siraphob b63a54f81c
Merge pull request #110742 from siraben/deprecate-fold 2021-07-27 15:13:31 +07:00
Alyssa Ross 9e400a8b93 nixos/users-groups: check format of passwd entries
Things will get quite broken if an /etc/passwd entry contains a
colon (which terminates a field), or a newline (which terminates a
record).  I know because I just accidentally made a user whose home
directory path contained a newline!

So let's make sure that can't happen.
2021-04-22 13:18:38 +00:00
Symphorien Gibol 7a87973b4c nixos/users: require one of users.users.name.{isSystemUser,isNormalUser}
As the only consequence of isSystemUser is that if the uid is null then
it's allocated below 500, if a user has uid = something below 500 then
we don't require isSystemUser to be set.

Motivation: https://github.com/NixOS/nixpkgs/issues/112647
2021-04-14 20:40:00 +02:00
Jan Tojnar c04a14edd6 Merge branch 'master' into staging-next 2021-04-06 16:01:14 +02:00
rnhmjoj 61b7cab481
treewide: use perl.withPackages when possible
Since 03eaa48 added perl.withPackages, there is a canonical way to
create a perl interpreter from a list of libraries, for use in script
shebangs or generic build inputs. This method is declarative (what we
are doing is clear), produces short shebangs[1] and needs not to wrap
existing scripts.

Unfortunately there are a few exceptions that I've found:

  1. Scripts that are calling perl with the -T switch. This makes perl
  ignore PERL5LIB, which is what perl.withPackages is using to inform
  the interpreter of the library paths.

  2. Perl packages that depends on libraries in their own path. This
  is not possible because perl.withPackages works at build time. The
  workaround is to add `-I $out/${perl.libPrefix}` to the shebang.

In all other cases I propose to switch to perl.withPackages.

[1]: https://lwn.net/Articles/779997/
2021-03-31 21:35:37 +02:00
Kovacsics Robert af4adb1dd2 nixos/users-groups: Use user name not attribute name for /etc/profiles/...
This cropped up, because I have a set-up where my work username is
different to my home desktop username, and I am using a parameterized
config for both, so I have something akin to

    config.users.users.default-user = ...;

and using

    config.users.users.default-user.{name, home}

in certain places to cope with this. Noticed my home-manager bought in
packages (which use the users.users.<name>.packages hence NixOS issue
not home-manager) weren't present.
2021-02-27 12:45:49 +00:00
Lassulus 2489d95c1c
Merge pull request #110627 from 4z3/use-real-user-name-for-per-user-packages
nixos/users: use proper name for per-user packages
2021-02-15 12:45:24 +01:00
Ben Siraphob 1c2a2b0a08 treewide: fold -> foldr 2021-01-26 10:57:07 +07:00
volth bc0d605cf1 treewide: fix double quoted strings in meta.description
Signed-off-by: Ben Siraphob <bensiraphob@gmail.com>
2021-01-24 19:56:59 +07:00
tv 530d3ffbcc nixos/users: use proper name for per-user packages
Fixes #107353
2021-01-23 21:36:14 +01:00