2014-04-14 15:26:48 +01:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
2009-03-06 12:27:15 +00:00
|
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
|
with lib;
|
2009-07-16 14:55:11 +01:00
|
|
|
|
|
2015-09-18 17:50:48 +01:00
|
|
|
|
let
|
2021-01-05 16:44:43 +00:00
|
|
|
|
cfg = config.services.getty;
|
2015-09-18 17:50:48 +01:00
|
|
|
|
|
2021-02-26 12:17:04 +00:00
|
|
|
|
baseArgs = [
|
2020-08-05 06:19:18 +01:00
|
|
|
|
"--login-program" "${cfg.loginProgram}"
|
2021-01-05 16:44:43 +00:00
|
|
|
|
] ++ optionals (cfg.autologinUser != null) [
|
|
|
|
|
"--autologin" cfg.autologinUser
|
|
|
|
|
] ++ optionals (cfg.loginOptions != null) [
|
|
|
|
|
"--login-options" cfg.loginOptions
|
2021-02-26 12:17:04 +00:00
|
|
|
|
] ++ cfg.extraArgs;
|
2021-01-05 16:44:43 +00:00
|
|
|
|
|
2021-02-26 12:17:04 +00:00
|
|
|
|
gettyCmd = args:
|
|
|
|
|
"@${pkgs.util-linux}/sbin/agetty agetty ${escapeShellArgs baseArgs} ${args}";
|
2015-09-18 17:50:48 +01:00
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
2009-07-16 14:55:11 +01:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
###### interface
|
2009-03-06 12:27:15 +00:00
|
|
|
|
|
2021-01-05 08:25:53 +00:00
|
|
|
|
imports = [
|
|
|
|
|
(mkRenamedOptionModule [ "services" "mingetty" ] [ "services" "getty" ])
|
|
|
|
|
];
|
|
|
|
|
|
2009-03-06 12:27:15 +00:00
|
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
|
2021-01-05 08:25:53 +00:00
|
|
|
|
services.getty = {
|
2009-07-16 14:55:11 +01:00
|
|
|
|
|
2015-04-12 03:14:24 +01:00
|
|
|
|
autologinUser = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
|
|
|
|
description = ''
|
|
|
|
|
Username of the account that will be automatically logged in at the console.
|
|
|
|
|
If unspecified, a login prompt is shown as usual.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-05 06:19:18 +01:00
|
|
|
|
loginProgram = mkOption {
|
|
|
|
|
type = types.path;
|
|
|
|
|
default = "${pkgs.shadow}/bin/login";
|
2021-10-03 17:06:03 +01:00
|
|
|
|
defaultText = literalExpression ''"''${pkgs.shadow}/bin/login"'';
|
2020-08-05 06:19:18 +01:00
|
|
|
|
description = ''
|
|
|
|
|
Path to the login binary executed by agetty.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2021-01-05 16:44:43 +00:00
|
|
|
|
loginOptions = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
|
|
|
|
description = ''
|
|
|
|
|
Template for arguments to be passed to
|
|
|
|
|
<citerefentry><refentrytitle>login</refentrytitle>
|
|
|
|
|
<manvolnum>1</manvolnum></citerefentry>.
|
|
|
|
|
|
|
|
|
|
See <citerefentry><refentrytitle>agetty</refentrytitle>
|
|
|
|
|
<manvolnum>1</manvolnum></citerefentry> for details,
|
|
|
|
|
including security considerations. If unspecified, agetty
|
|
|
|
|
will not be invoked with a <option>--login-options</option>
|
|
|
|
|
option.
|
|
|
|
|
'';
|
2021-02-26 12:17:04 +00:00
|
|
|
|
example = "-h darkstar -- \\u";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extraArgs = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [ ];
|
|
|
|
|
description = ''
|
|
|
|
|
Additional arguments passed to agetty.
|
|
|
|
|
'';
|
|
|
|
|
example = [ "--nohostname" ];
|
2021-01-05 16:44:43 +00:00
|
|
|
|
};
|
|
|
|
|
|
2009-07-16 14:55:11 +01:00
|
|
|
|
greetingLine = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
|
type = types.str;
|
2009-07-16 14:55:11 +01:00
|
|
|
|
description = ''
|
2021-01-05 08:25:53 +00:00
|
|
|
|
Welcome line printed by agetty.
|
2015-09-18 17:50:48 +01:00
|
|
|
|
The default shows current NixOS version label, machine type and tty.
|
2009-07-16 14:55:11 +01:00
|
|
|
|
'';
|
|
|
|
|
};
|
2009-03-06 12:27:15 +00:00
|
|
|
|
|
2009-07-16 14:55:11 +01:00
|
|
|
|
helpLine = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
|
type = types.lines;
|
2009-07-16 14:55:11 +01:00
|
|
|
|
default = "";
|
|
|
|
|
description = ''
|
2021-01-05 08:25:53 +00:00
|
|
|
|
Help line printed by agetty below the welcome line.
|
2009-07-16 14:55:11 +01:00
|
|
|
|
Used by the installation CD to give some hints on
|
|
|
|
|
how to proceed.
|
|
|
|
|
'';
|
2009-03-06 12:27:15 +00:00
|
|
|
|
};
|
2009-07-16 14:55:11 +01:00
|
|
|
|
|
2014-02-03 22:20:41 +00:00
|
|
|
|
serialSpeed = mkOption {
|
|
|
|
|
type = types.listOf types.int;
|
|
|
|
|
default = [ 115200 57600 38400 9600 ];
|
|
|
|
|
example = [ 38400 9600 ];
|
|
|
|
|
description = ''
|
|
|
|
|
Bitrates to allow for agetty's listening on serial ports. Listing more
|
|
|
|
|
bitrates gives more interoperability but at the cost of long delays
|
|
|
|
|
for getting a sync on the line.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2009-03-06 12:27:15 +00:00
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
|
2009-03-06 12:27:15 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2009-07-16 14:55:11 +01:00
|
|
|
|
###### implementation
|
|
|
|
|
|
2015-09-18 17:50:48 +01:00
|
|
|
|
config = {
|
|
|
|
|
# Note: this is set here rather than up there so that changing
|
2017-04-01 01:00:00 +01:00
|
|
|
|
# nixos.label would not rebuild manual pages
|
2021-01-05 08:25:53 +00:00
|
|
|
|
services.getty.greetingLine = mkDefault ''<<< Welcome to NixOS ${config.system.nixos.label} (\m) - \l >>>'';
|
2015-09-18 17:50:48 +01:00
|
|
|
|
|
2014-03-12 17:29:06 +00:00
|
|
|
|
systemd.services."getty@" =
|
2017-07-16 18:28:02 +01:00
|
|
|
|
{ serviceConfig.ExecStart = [
|
|
|
|
|
"" # override upstream default with an empty ExecStart
|
|
|
|
|
(gettyCmd "--noclear --keep-baud %I 115200,38400,9600 $TERM")
|
|
|
|
|
];
|
2014-03-12 17:29:06 +00:00
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
systemd.services."serial-getty@" =
|
2021-01-05 08:25:53 +00:00
|
|
|
|
let speeds = concatStringsSep "," (map toString config.services.getty.serialSpeed); in
|
2017-07-16 18:28:02 +01:00
|
|
|
|
{ serviceConfig.ExecStart = [
|
|
|
|
|
"" # override upstream default with an empty ExecStart
|
2021-06-25 08:50:52 +01:00
|
|
|
|
(gettyCmd "%I --keep-baud ${speeds} $TERM")
|
2017-07-16 18:28:02 +01:00
|
|
|
|
];
|
2014-04-16 15:10:11 +01:00
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
};
|
|
|
|
|
|
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-08-30 14:10:54 +01:00
|
|
|
|
systemd.services."autovt@" =
|
|
|
|
|
{ serviceConfig.ExecStart = [
|
|
|
|
|
"" # override upstream default with an empty ExecStart
|
|
|
|
|
(gettyCmd "--noclear %I $TERM")
|
|
|
|
|
];
|
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-16 15:10:11 +01:00
|
|
|
|
systemd.services."container-getty@" =
|
2017-08-13 18:07:38 +01:00
|
|
|
|
{ serviceConfig.ExecStart = [
|
|
|
|
|
"" # override upstream default with an empty ExecStart
|
|
|
|
|
(gettyCmd "--noclear --keep-baud pts/%I 115200,38400,9600 $TERM")
|
|
|
|
|
];
|
2014-03-12 17:29:06 +00:00
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
};
|
2012-07-20 16:36:09 +01:00
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
|
systemd.services.console-getty =
|
2017-08-13 18:07:38 +01:00
|
|
|
|
{ serviceConfig.ExecStart = [
|
|
|
|
|
"" # override upstream default with an empty ExecStart
|
|
|
|
|
(gettyCmd "--noclear --keep-baud console 115200,38400,9600 $TERM")
|
|
|
|
|
];
|
2014-08-25 01:45:11 +01:00
|
|
|
|
serviceConfig.Restart = "always";
|
|
|
|
|
restartIfChanged = false;
|
2015-09-18 17:50:48 +01:00
|
|
|
|
enable = mkDefault config.boot.isContainer;
|
2014-08-25 01:45:11 +01:00
|
|
|
|
};
|
|
|
|
|
|
2019-09-14 18:51:29 +01:00
|
|
|
|
environment.etc.issue =
|
2009-07-16 14:55:11 +01:00
|
|
|
|
{ # Friendly greeting on the virtual consoles.
|
2012-08-06 20:53:04 +01:00
|
|
|
|
source = pkgs.writeText "issue" ''
|
|
|
|
|
|
2021-01-05 08:25:53 +00:00
|
|
|
|
[1;32m${config.services.getty.greetingLine}[0m
|
|
|
|
|
${config.services.getty.helpLine}
|
2012-08-06 20:53:04 +01:00
|
|
|
|
|
|
|
|
|
'';
|
2009-07-16 14:55:11 +01:00
|
|
|
|
};
|
2012-06-18 22:58:31 +01:00
|
|
|
|
|
2009-07-16 14:55:11 +01:00
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
|
2006-11-19 20:07:45 +00:00
|
|
|
|
}
|