Commit Graph

162 Commits

Author SHA1 Message Date
stuebinm
6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
edef
725bb4e48c lib: add xor
This gets clumsily reimplemented in various places, to no useful end.
2024-04-04 19:46:58 +00:00
Adam Stephens
790fb86a7f
nixos/users-groups: move linger to oneshot and add nixos test 2024-03-21 19:51:05 -04:00
Adam Stephens
564c3749d9
nixos/users-groups: fix broken linger 2024-03-21 13:47:15 -04:00
Jordan Williams
8558d7b1ce
nixos/users-groups: Fix the update-lingering activation script failing
The update-lingering activation script currently fails during rebuilds.
This happens when removing a user with linger enabled.
The call to loginctl disable-linger runs for the non-existent user.
This returns an error code which causes the failure.

To mitigate this, this PR removes any residual linger files.
These are files named for the user in /var/lib/systemd/linger.
A simple check for user existence determines whether to delete the file.
This happens before the call to disable-linger to avoid any errors.

Fixes #283769.
2024-03-03 12:00:25 -06:00
Maximilian Bosch
f6954309e8
nixos/users-groups: warn on ambiguous password settings
After 4b128008c5 it took me a while in a
test setup to find out why `root` didn't have the password anymore I
declared in my config.

Because of that I got reminded how the order of preference works for the
password options:

    hashedPassword > password > hashedPasswordFile

If the user is new, initialPassword & initialHashedPassword are also
relevant. Also, the override is silent in contrast to any other
conflicting definition in NixOS.

To make this less surprising I decided to warn in such a case -
assertions would probably break too much that technically works as
intended.

Also removed the `initialHashedPassword` for `root`. This would cause a
warning whenever you set something in your own config and a `!` is added
automatically by `users-groups.pl`.

`systemd-sysusers` also seems to implement these precedence rules, so
having the warning for that case also seems useful.
2024-02-09 16:44:35 +01:00
nikstur
eec1845744 nixos/systemd-sysusers: init 2024-01-18 23:08:14 +01:00
Alyssa Ross
59dc10b5a6 nixos/users-groups: fix confusing error message
If we include users with unset groups, we get this very confusing
message, with invalid Nix code:

       - The following users have a primary group that is undefined: qyliss
       Hint: Add this to your NixOS configuration:
         users.groups. = {};

We don't need to include such users in this check, since they'll be
caught anyway by this one:

       - users.users.qyliss.group is unset. This used to default to
       nogroup, but this is unsafe. For example you can create a group
       for this user with:
       users.users.qyliss.group = "qyliss";
       users.groups.qyliss = {};
2023-12-14 02:08:16 +01:00
Anthony Roussel
e30f48be94
treewide: fix redirected and broken URLs
Using the script in maintainers/scripts/update-redirected-urls.sh
2023-11-11 10:49:01 +01:00
Will Fancher
22325ce016 systemd-stage-1: Support for user shells 2023-10-21 13:24:16 -04:00
Vladimir Pouzanov
ed44cfb141
Merge branch 'master' into shellconfig 2023-10-14 08:38:25 +01:00
Artturi
5fabe8c9fd
Merge pull request #260764 from MatthewCash/fix/xdg-base-pam 2023-10-14 04:01:48 +03:00
Matthew_Cash
9c24f502b7
nixos/user-groups: fix environment.profiles using parameter expansion 2023-10-12 21:00:34 -07:00
Rebecca Kelly
e648d46465 nixos/users-groups: add user option to enable lingering
Adapted from
https://gist.github.com/graham33/fdbdcc18317a621d9dd54beb36be6683

Fixes #3702

Lingering users can still be managed mutably by root with `loginctl`,
but the settings here will take precedence when `nixos-rebuild` is run.
2023-10-10 08:53:48 -04:00
Bjørn Forsman
fa8ace3618 nixos: don't implicitly map missing user groups to nogroup
Before: `users.users.user1.group = "group-not-defined-anywhere-else"`
would result in user1 having the primary group `nogroup`, assigned at
activation time and only with a (easy to miss) warning from the
activation script. This behaviour is a security issue becase no files
should be owned by `nogroup` and it allows for unrelated users (and
services) to accidentally have access to files they shouldn't have.

After: The configuration above results in this eval error:
  - The following users have a primary group that is undefined: user1
  Hint: Add this to your NixOS config:
    users.groups.group-not-defined-anywhere-else = {};
2023-10-06 19:33:01 +02:00
Vladimir Pouzanov
093f354a17 nixos/users-groups: escape hatch for enabling a shell system-wide 2023-09-27 18:49:06 +02:00
Artturi
713af20167
Merge pull request #241518 from Gerg-L/use-xdg-base-directories 2023-09-25 00:45:31 +03:00
rnhmjoj
205b56cffc
nixos/user-groups: fixup of 5666a378 2023-09-13 11:44:19 +02:00
rnhmjoj
5666a378cb
nixos/users-groups: rename passwordFile in hashedPasswordFile
This avoids the possible confusion with `passwordFile` being the file
version of `password`, while it should contain the password hash.

Fixes issue #165858.
2023-09-08 21:19:40 +02:00
Ramses
76f8cf18d1 nixos/update-users-groups: no need to include extra package
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2023-09-03 11:26:37 +02:00
r-vdp
d560a5e07d nixos/update-users-groups: fix cross compilation
Since #246772, cross compiled NixOS is broken because the DateTime perl
package that was used in the update-users-groups.pl script depends on
Testutf8 which does not cross compile (see #198548).

This PR drops the DateTime dependency in favour of TimePiece, which has
less dependencies and whose closure does cross compile.
2023-09-03 11:26:37 +02:00
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
Gerg-L
bf383adf0a nixos/user-groups: Add to $NIX_PROFILES paths 2023-07-18 23:33:18 -04: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