94 Commits
Author SHA1 Message Date
Grimmauld 557ffb2ffa nixos/treewide: use security.pam.pam_unixModulePath 2026-07-21 14:57:21 +02:00
Sam Pointon 9d280168cc nixos/getty: allow disabling
https://github.com/NixOS/nixpkgs/pull/480686 made getty unconditional, fixing 
several bugs and bad interactions. This imposes no runtime costs due to lazy 
systemd-based activation, but it does drag getty and its closure in to images. 
For many NixOS installations, this is fine - they want console login and such 
anyway - but it's a burden on lights-out containers aiming for minimal image 
sizes.

This change adds a new configuration knob to totally disable getty for these 
sorts of headless/lights-out/appliance-style set-ups. The option's description 
is deliberately made stern to hopefully dissuade anyone from toggling it if 
their system isn't in that class. As the option defaults to enabling getty, 
there should be no behaviour change for anyone not explicitly opting themselves 
in - hopefully with full knowledge of the consequences.

My local testing chopped a whole 15% off one of my images by being able to 
remove getty (the big contributor being util-linux and its friends), and that's 
just for one random image - others might be even bigger relative gains. I think 
that's more than enough to justify this configuration knob.

I had a look for uses of getty in NixOS to see if anywhere wanted to either 
have a hard dependency on getty and hence explicitly enable it (so that weird 
configurations get picked up at evaluation time rather than runtime) or disable 
it. The use sites fall into two categories:

0. Virtualised set-ups that wire up units to getty listening on ttyS0. These 
probably don't want a hard dependency: it's reasonable to run these lights-out, 
and just disabling getty will DTRT here.

1. `modules/profiles/headless.nix`, which disables some of the getty units. 
This _could_ instead disable getty as a whole, but that might break e.g. 
`machinectl shell`, and I can imagine set-ups where you want that even without 
console login, so I have left it alone. Maybe someone else feels differently 
and more strongly, and then that someone else can put together a PR and argue 
their case.
2026-06-27 07:58:53 +01:00
Arian van PuttenandGitHub b9ce8900b0 nixos/getty: do not conditionalize on console. (#480686) 2026-06-22 11:31:00 +00:00
ccicnce113424 9b9e0a021a nixos/kmscon: RFC42 treatment, support version 10.0.0
This commit includes changes from #483195, #523569, and #523955.
2026-05-31 20:34:53 +08:00
r-vdp 1b68f40be1 nixos/getty: pass --issue-file explicitly
util-linux 2.42 switched agetty's default issue-file lookup from a
hardcoded "/etc/issue" to ${sysconfdir}, which is $out/etc in nixpkgs,
so the greeting is no longer found.

Point agetty at the real paths explicitly. The list matches what 2.41
searched. Placed before extraArgs so users can still override it.

This is a non-mass-rebuild stopgap until util-linux is built with
--sysconfdir=/etc on staging.

Fixes #514060
2026-04-27 20:20:15 +02:00
ccicnce113424 192343cd24 nixos/kmscon: spawn kmscon on tty1 only if the display manager is disabled 2026-04-26 18:58:01 +08:00
ccicnce113424 54f2c96200 nixos/kmscon: remove dependency on agetty 2026-04-23 01:45:55 +08:00
Arian van Putten 1ad99d9e4b nixos/getty: do not conditionalize on console
## What this fixes: 

Currently ; logging in to nixos containers is broken as they do not get spawned a login shell at all. This was noticed in https://github.com/NixOS/nixpkgs/pull/470248.  Also no login shell is spawned when the bashless profile is enabled. 

##  How it fixes this

It makes it so that `console.enable` really just controls whether virtual console setup is done or not.

all the tty units are just unconditionally included as before instead of masked.

Systemd already takes care of not starting them up when they're not needed through `Condition` clauses and through the `systemd-getty-generator`.   There is no reason to manually mask (what is what `enable =  false; does) getty units. systemd already does the right thing.

## How we got here:

We have `modules/config/console.nix` . This module is what sets up the **virtual console**. That is; the graphical console that Linux ships with that by default is on `/dev/tty1` (and thus on `/dev/console` on single-user instances).

This module used to disable `systemd-vconsole-setup` when `isContainer`  was `true` as  nspawn containers do not have a virtual console; instead `/dev/console`  is a PTS device that gets mounted into the container.

https://github.com/NixOS/nixpkgs/pull/197867/changes  was then merged that made it so that the entire module gets disabled in containers. This is nice because this means we don't install `kbd` package etc in container profile which reduces the footprint.

Somebody commented that they expected this module to also disable TTY services when set to disable due to the wording being `enable virtual console`.   

However, getty services and virtual console have nothing to do with eachother. This module is to configure the virtual console fonts; not to configure gettys!    

It's perfectly possible to have TTYs without having a virtual console!  Namely serial consoles and hypervisors consoles `ttyS0`, `ttyAMA0`, `hvc0` .

A comment was made by  rnhmjoj  correctly pointing this out

> > Tried out false, does not disable the getty target/services.
> 
> It's not mean to: this module solely takes care of configuring the console (keymap, font, colors, ...), not providing one. That's why I say the "enable virtual console" description is misleading.
https://github.com/NixOS/nixpkgs/pull/197867#issuecomment-1294204444 

However, instead of thus just merging as is; a change was made to start disabling _some_ getty services.  However (probably by accident); `console-getty.service` and `container-getty@.service` were *not* disabled. So nixos-containers kept working.

> Ok, that makes sense.
> 
> I think if this goes in it either needs a doc change like you asked for, or to also toggle the getty service so it does what the current docs imply.

https://github.com/NixOS/nixpkgs/pull/197867#issuecomment-1294383386

At this point; disabling the virtual console module would break setups that don't have a virtual console in the first place!  This includes: servers, containers, anything without a graphical display. However; because the tty list was incomplete and `console-getty.service` was *not* disabled; containers kept working.

A follow-up PR was then made (even though the original code was not correct) that added the remaining gettys https://github.com/NixOS/nixpkgs/pull/363533 . This meant all the use-cases where there is no virtual console and disable the virtual console are now properly broken. 

To date that is the [bashless profile](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/profiles/bashless.nix) and the [container profile](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/virtualisation/container-config.nix)

This then got noticed by  https://github.com/NixOS/nixpkgs/pull/470248 as it uncovered that login shells are not being spawned anymore inside nspawn containers.  

I then started looking into the PRs and backtracked how we got here.
2026-04-04 10:27:25 +02:00
r-vdp f2c276dae1 systemd: 259.5 -> 260
Changes:
- autovt@.service moved from a static meson-installed symlink to an
  [Install] Alias= on getty@.service upstream. We do not process
  [Install] sections, and logind still hardcodes spawning
  autovt@ttyN.service on VT switch, so recreate the alias.
- kmscon: suppress getty@.service instead of autovt@.service.
  Add static pull-in of kmsconvt@tty1 via getty.target since logind
  does not spawn autovt on tty1 by design.
- modprobe@.service: upstream switched ExecStart from /sbin/modprobe to
  a bare 'modprobe' relying on PATH. Update the substitution to match
  the new form, since DEFAULT_PATH on NixOS is systemd's own bindir
  which has no modprobe.
- Remove stale substituteInPlace patterns for paths removed upstream
  (/bin/echo in test-fileio.c, /bin/cat in cat.c, /usr/bin/getent in
  nspawn-setuid.c)
- Remove dead CFLAGS overrides for POLKIT_AGENT_BINARY_PATH (replaced
  by runtime find_executable) and SYSTEMD_CGROUP_AGENTS_PATH (cgroup-v1
  leftover, gone before v259). Use --replace-fail for the remaining
  config.h substitution so future removals fail loudly.
- Remove deprecated meson options (sysvinit-path, sysvrcnd-path, libidn)
- Handle new pull-oci.c tar references
- Drop upstreamed patch 0017-meson.build-do-not-create-systemdstatedir.patch
2026-03-25 11:39:22 +01:00
RamsesandGitHub 44cf8e66f9 nixos/getty: revert overzealous assertion (#502957) 2026-03-24 09:27:47 +00:00
Alyssa Ross a5635ffcb7 nixos/getty: revert overzealous assertion
It is not true that autoLoginUser has no effect when loginOptions is
set.  Partial revert of be703cf473 ("nixos/kmscon: run agetty under
kmscon").
2026-03-24 08:49:42 +01:00
bokicoderandGitHub 0a83ee6f0a nixos/kmscon: revert hwRender option 2026-03-24 15:07:59 +08:00
hustleroneandccicnce113424 be703cf473 nixos/kmscon: run agetty under kmscon
Cherry-picked from NixOS/nixpkgs#391574

Co-authored-by: ccicnce113424 <ccicnce113424@gmail.com>
2026-03-18 22:00:00 +08:00
K900 e49259f489 nixos/display-managers: move "generic" DM unit to its own option set
This is the first step towards deprecating it.
2026-01-17 16:00:48 +03:00
Sandro Jäckel cc651f49de nixos/kmscon: fix option descriptions 2025-09-09 16:25:00 +02:00
Wolfgang WaltherandGitHub 9a35d07c7c nixos/kmscon: add package option (#400296) 2025-09-07 13:50:27 +00:00
Acid Bong d3f06b74b1 nixos/kmscon: declare boolean options with mkEnableOption 2025-09-06 18:17:07 +03:00
Acid Bong 3534d7209d nixos/kmscon: add package option
Fixes #399859
2025-09-06 18:17:07 +03:00
Will Fancher 8cb99658bd nixos/display-manager: Disable the dependency on autovt@tty1 rather than masking it 2025-07-31 08:41:30 -04:00
Will Fancher 570ae8423d nixos/autovt: Pull in autovt@tty1 in Nix, not generateUnits 2025-07-28 14:46:39 -04:00
Wolfgang Walther 5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Silvan Mosberger 374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Michele Guerini RoccoandGitHub d05074f981 nixos/getty: only include if config.console.enable == true (#363533) 2025-02-18 11:44:42 +01:00
Moritz Sanft 7fb2f407c0 nixos/getty: only include if config.console.enable
This makes it so that the getty units are only included if
`config.console.enable` is set to `true`. Previously, they would be
included, but disabled in that case, which is unnecessary.
2024-12-16 08:45:10 +01:00
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
rnhmjoj 565f972ded nixos/getty: add option to autologin once per boot, take 2
Another attempt to bring ae48df3e while avoiding the Nix symlink bug[1].
I guess the bug was triggered by the sbin -> bin symlink in util-linux.

[1]: https://github.com/NixOS/nix/issues/9579
2024-10-13 12:45:15 +02:00
pancho horrillo 1f88956b95 nixos/kmscon: fix cfgfile missing trailing newline
Currently, the `kmscon.conf` file that is generated is missing a
trailing newline.  This breaks `kmscon`, since its parser assumes
well-formedness.

I noticed this while trying to specify a font, whose spec ended up on
the last line, but without the trailing newline, `kmscon` would not honor it.
2024-07-27 15:54:41 +02:00
Sandro Jäckel 6868a97e5e nixos/kmscon: fix eval 2024-07-03 00:01:12 +02:00
Doron BeharandGitHub 3063d28384 Merge pull request #271914 from kingarrrt/kmscon
kmscon: configure keymap from xserver xkb config
2024-06-30 10:53:15 +03:00
Arthur Noel 6447fae5d0 kmscon: configure keymap from xserver xkb config 2024-06-30 00:29:16 +01:00
SandroandGitHub 273f6bdff8 Merge pull request #244684 from m-bdf/kmscon-use-upstream-service-file
nixos/kmscon: use upstream service file
2024-06-26 19:29:28 +02:00
K900 98cef4c273 treewide: big opengl cleanup
- rename hardware.opengl to hardware.graphics
- remove hardware.opengl.driSupport, which does nothing
- remove hardware.opengl.setLdLibraryPath, which should never be done
- rename hardware.opengl.driSupport32Bit to hardware.graphics.enable32Bit
- lost of small docs / formatting cleanups
2024-06-16 14:11:33 +03:00
Tristan Ross 49d5b2b7ba nixos/getty: use distro name in default greeting line 2024-06-12 20:08:41 -07:00
stuebinmandJonathan Ringer 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
K900andGitHub 084ce1ee88 Revert "nixos/getty: add option to autologin once per boot" 2024-04-11 15:05:26 +03:00
rnhmjoj ae48df3ebb nixos/getty: add option to autologin once per boot 2024-02-04 15:59:03 +01:00
Sandro Jäckel b0c67b4b6e treewide: rename fonts.fonts to fonts.packages 2023-07-24 17:34:39 +02:00
Maëlys Bras de fer dff96ae65d nixos/kmscon: use upstream service file 2023-07-21 16:15:55 +00:00
Matthew_Cash ae234ed1ab nixos/kmscon: disable reload-systemd-vconsole-setup service 2023-06-16 19:12:07 -07:00
Ian McFarlane 49c4a6d602 nixos/getty: mkdefault for etc/issue 2022-10-05 12:46:23 -04:00
pennaeandGitHub 50f9b3107a Merge pull request #185474 from pennae/option-docs-md
nixos/*: more options md conversion
2022-08-12 23:23:26 +02:00
Robert HensingandGitHub 661c29c806 Merge pull request #181222 from hercules-ci/module-specialArgs
`_module.specialArgs` + unit test for nixos/documentation module
2022-08-08 11:53:10 +02:00
pennae 087472b1e5 nixos/*: automatically convert option docs 2022-08-06 20:39:12 +02:00
pennae 423545fe48 nixos/*: normalize manpage references to single-line form
now nix-doc-munge will not introduce whitespace changes when it replaces
manpage references with the MD equivalent.

no change to the manpage, changes to the HTML manual are whitespace only.
2022-08-05 18:34:50 +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
Robert Hensing 5a98c63077 nixos: Move getty helpLine definition to getty module
Working towards a unit-testable documentation module.
2022-07-21 15:32:00 +02:00
nicoo 11bbb28f8a nixos/kmscon: Add fonts option 2022-04-18 15:56:34 +02:00
Michael Schneider 1331b3d252 nixos/getty: remove serialSpeed
It is expected that the baudrate is already initialized before the getty is started. Therefore the serialSpeed option is redundant.
2021-11-19 10:17:26 +01:00
Naïm Favier 2ddc335e6f nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
Andreas RammholdandJörg Thalheim 64556974b6 systemd: 247.6 -> 249.4
This updates systemd to version v249.4 from version v247.6.

Besides the many new features that can be found in the upstream
repository they also introduced a bunch of cleanup which ended up
requiring a few more patches on our side.

a) 0022-core-Handle-lookup-paths-being-symlinks.patch:
  The way symlinked units were handled was changed in such that the last
  name of a unit file within one of the unit directories
  (/run/systemd/system, /etc/systemd/system, ...) is used as the name
  for the unit. Unfortunately that code didn't take into account that
  the unit directories themselves could already be symlinks and thus
  caused all our units to be recognized slightly different.

  There is an upstream PR for this new patch:
    https://github.com/systemd/systemd/pull/20479

b) The way the APIVFS is setup has been changed in such a way that we
   now always have /run. This required a few changes to the
   confinement tests which did assert that they didn't exist. Instead of
   adding another patch we can just adopt the upstream behavior. An
   empty /run doesn't seem harmful.

   As part of this work I refactored the confinement test just a little
   bit to allow better debugging of test failures. Previously it would
   just fail at some point and it wasn't obvious which of the many
   commands failed or what the unexpected string was. This should now be
   more obvious.

c) Again related to the confinement tests the way a file was tested for
   being accessible was optimized. Previously systemd would in some
   situations open a file twice during that check. This was reduced to
   one operation but required the procfs to be mounted in a units
   namespace.

   An upstream bug was filed and fixed. We are now carrying the
   essential patch to fix that issue until it is backported to a new
   release (likely only version 250). The good part about this story is
   that upstream systemd now has a test case that looks very similar to
   one of our confinement tests. Hopefully that will lead to less
   friction in the long run.

   https://github.com/systemd/systemd/issues/20514
   https://github.com/systemd/systemd/pull/20515

d) Previously we could grep for dlopen( somewhat reliably but now
   upstream started using a wrapper around dlopen that is most of the
   time used with linebreaks. This makes using grep not ergonomic
   anymore.

   With this bump we are grepping for anything that looks like a
   dynamic library name (in contrast to a dlopen(3) call) and replace
   those instead. That seems more robust. Time will tell if this holds.

   I tried using coccinelle to patch all those call sites using its
   tooling but unfornately it does stumble upon the _cleanup_
   annotations that are very common in the systemd code.

e) We now have some machinery for libbpf support in our systemd build.
   That being said it doesn't actually work as generating some skeletons
   doesn't work just yet. It fails with the below error message and is
   disabled by default (in both minimal and the regular build).

   > FAILED: src/core/bpf/socket_bind/socket-bind.skel.h
   > /build/source/tools/build-bpf-skel.py --clang_exec /nix/store/x1bi2mkapk1m0zq2g02nr018qyjkdn7a-clang-wrapper-12.0.1/bin/clang --llvm_strip_exec /nix/store/zm0kqan9qc77x219yihmmisi9g3sg8ns-llvm-12.0.1/bin/llvm-strip --bpftool_exec /nix/store/l6dg8jlbh8qnqa58mshh3d8r6999dk0p-bpftools-5.13.11/bin/bpftool --arch x86_64 ../src/core/bpf/socket_bind/socket-bind.bpf.c src/core/bpf/socket_bind/socket-bind.skel.h
   > libbpf: elf: socket_bind_bpf is not a valid eBPF object file
   > Error: failed to open BPF object file: BPF object format invalid
   > Traceback (most recent call last):
   >   File "/build/source/tools/build-bpf-skel.py", line 128, in <module>
   >     bpf_build(args)
   >   File "/build/source/tools/build-bpf-skel.py", line 92, in bpf_build
   >     gen_bpf_skeleton(bpftool_exec=args.bpftool_exec,
   >   File "/build/source/tools/build-bpf-skel.py", line 63, in gen_bpf_skeleton
   >     skel = subprocess.check_output(bpftool_args, universal_newlines=True)
   >   File "/nix/store/81lwy2hfqj4c1943b1x8a0qsivjhdhw9-python3-3.9.6/lib/python3.9/subprocess.py", line 424, in check_output
   >     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
   >   File "/nix/store/81lwy2hfqj4c1943b1x8a0qsivjhdhw9-python3-3.9.6/lib/python3.9/subprocess.py", line 528, in run
   >     raise CalledProcessError(retcode, process.args,
   > subprocess.CalledProcessError: Command '['/nix/store/l6dg8jlbh8qnqa58mshh3d8r6999dk0p-bpftools-5.13.11/bin/bpftool', 'g', 's', '../src/core/bpf/socket_bind/socket-bind.bpf.o']' returned non-zero exit status 255.
   > [102/1457] Compiling C object src/journal/libjournal-core.a.p/journald-server.c.oapture output)put)ut)
   > ninja: build stopped: subcommand failed.

  f) We do now have support for TPM2 based disk encryption in our
     systemd build. The actual bits and pieces to make use of that are
     missing but there are various ongoing efforts in that direction.
     There is also the story about systemd in our initrd to enable this
     being used for root volumes. None of this will yet work out of the
     box but we can start improving on that front.

  g) FIDO2 support was added systemd and consequently we can now use
     that. Just with TPM2 there hasn't been any integration work with
     NixOS and instead this just adds that capability to work on that.

Co-Authored-By: Jörg Thalheim <joerg@thalheim.io>
2021-09-12 23:45:49 +02:00