push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,217 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.services.getty;
baseArgs = [
"--login-program"
"${cfg.loginProgram}"
]
++ optionals (cfg.autologinUser != null && !cfg.autologinOnce) [
"--autologin"
cfg.autologinUser
]
++ optionals (cfg.loginOptions != null) [
"--login-options"
cfg.loginOptions
]
++ cfg.extraArgs;
gettyCmd = args: "${lib.getExe' pkgs.util-linux "agetty"} ${escapeShellArgs baseArgs} ${args}";
autologinScript = ''
otherArgs="--noclear --keep-baud $TTY 115200,38400,9600 $TERM";
${lib.optionalString cfg.autologinOnce ''
autologged="/run/agetty.autologged"
if test "$TTY" = tty1 && ! test -f "$autologged"; then
touch "$autologged"
exec ${gettyCmd "$otherArgs --autologin ${cfg.autologinUser}"}
fi
''}
exec ${gettyCmd "$otherArgs"}
'';
in
{
###### interface
imports = [
(mkRenamedOptionModule [ "services" "mingetty" ] [ "services" "getty" ])
(mkRemovedOptionModule [ "services" "getty" "serialSpeed" ]
''set non-standard baudrates with `boot.kernelParams` i.e. boot.kernelParams = ["console=ttyS2,1500000"];''
)
];
options = {
services.getty = {
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.
'';
};
autologinOnce = mkOption {
type = types.bool;
default = false;
description = ''
If enabled the automatic login will only happen in the first tty
once per boot. This can be useful to avoid retyping the account
password on systems with full disk encrypted.
'';
};
loginProgram = mkOption {
type = types.path;
default = "${pkgs.shadow}/bin/login";
defaultText = literalExpression ''"''${pkgs.shadow}/bin/login"'';
description = ''
Path to the login binary executed by agetty.
'';
};
loginOptions = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Template for arguments to be passed to
{manpage}`login(1)`.
See {manpage}`agetty(1)` for details,
including security considerations. If unspecified, agetty
will not be invoked with a {option}`--login-options`
option.
'';
example = "-h darkstar -- \\u";
};
extraArgs = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
Additional arguments passed to agetty.
'';
example = [ "--nohostname" ];
};
greetingLine = mkOption {
type = types.str;
description = ''
Welcome line printed by agetty.
The default shows current NixOS version label, machine type and tty.
'';
};
helpLine = mkOption {
type = types.lines;
default = "";
description = ''
Help line printed by agetty below the welcome line.
Used by the installation CD to give some hints on
how to proceed.
'';
};
};
};
###### implementation
config = mkIf config.console.enable {
# Note: this is set here rather than up there so that changing
# nixos.label would not rebuild manual pages
services.getty.greetingLine = mkDefault ''<<< Welcome to ${config.system.nixos.distroName} ${config.system.nixos.label} (\m) - \l >>>'';
services.getty.helpLine = mkIf (
config.documentation.nixos.enable && config.documentation.doc.enable
) "\nRun 'nixos-help' for the NixOS manual.";
systemd.additionalUpstreamSystemUnits = [
"getty.target"
"getty-pre.target"
"getty@.service"
"serial-getty@.service"
"console-getty.service"
"container-getty@.service"
];
# We can't just rely on 'Conflicts=autovt@tty1.service' because
# 'switch-to-configuration switch' will start 'autovt@tty1.service'
# and kill the display manager.
systemd.targets.getty.wants =
lib.mkIf (!(config.systemd.services.display-manager.enable or false))
[
"autovt@tty1.service"
];
systemd.services."getty@" = {
serviceConfig.ExecStart = [
# override upstream default with an empty ExecStart
""
(pkgs.writers.writeDash "getty" autologinScript)
];
environment.TTY = "%I";
restartIfChanged = false;
};
systemd.services."serial-getty@" = {
serviceConfig.ExecStart = [
"" # override upstream default with an empty ExecStart
(gettyCmd "%I --keep-baud $TERM")
];
restartIfChanged = false;
};
systemd.services."autovt@" = {
serviceConfig.ExecStart = [
"" # override upstream default with an empty ExecStart
(gettyCmd "--noclear %I $TERM")
];
restartIfChanged = false;
};
systemd.services."container-getty@" = {
serviceConfig.ExecStart = [
"" # override upstream default with an empty ExecStart
(gettyCmd "--noclear --keep-baud pts/%I 115200,38400,9600 $TERM")
];
restartIfChanged = false;
};
systemd.services.console-getty = {
serviceConfig.ExecStart = [
"" # override upstream default with an empty ExecStart
(gettyCmd "--noclear --keep-baud console 115200,38400,9600 $TERM")
];
serviceConfig.Restart = "always";
restartIfChanged = false;
enable = mkDefault config.boot.isContainer;
};
environment.etc.issue = mkDefault {
# Friendly greeting on the virtual consoles.
source = pkgs.writeText "issue" ''
${config.services.getty.greetingLine}
${config.services.getty.helpLine}
'';
};
};
meta.maintainers = with maintainers; [ RossComputerGuy ];
}

View File

@@ -0,0 +1,61 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.services.gpm;
in
{
###### interface
options = {
services.gpm = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to enable GPM, the General Purpose Mouse daemon,
which enables mouse support in virtual consoles.
'';
};
protocol = mkOption {
type = types.str;
default = "ps/2";
description = "Mouse protocol to use.";
};
};
};
###### implementation
config = mkIf cfg.enable {
systemd.services.gpm = {
description = "Console Mouse Daemon";
wantedBy = [ "multi-user.target" ];
requires = [ "dev-input-mice.device" ];
after = [ "dev-input-mice.device" ];
serviceConfig.ExecStart = "@${pkgs.gpm}/sbin/gpm gpm -m /dev/input/mice -t ${cfg.protocol}";
serviceConfig.Type = "forking";
serviceConfig.PIDFile = "/run/gpm.pid";
};
};
}

View File

@@ -0,0 +1,154 @@
{
config,
pkgs,
lib,
...
}:
let
inherit (lib)
mkIf
mkEnableOption
mkOption
mkPackageOption
optional
optionals
types
;
cfg = config.services.kmscon;
autologinArg = lib.optionalString (cfg.autologinUser != null) "-f ${cfg.autologinUser}";
configDir = pkgs.writeTextFile {
name = "kmscon-config";
destination = "/kmscon.conf";
text = cfg.extraConfig;
};
in
{
options = {
services.kmscon = {
enable = mkEnableOption ''
kmscon as the virtual console instead of gettys.
kmscon is a kms/dri-based userspace virtual terminal implementation.
It supports a richer feature set than the standard linux console VT,
including full unicode support, and when the video card supports drm
should be much faster
'';
package = mkPackageOption pkgs "kmscon" { };
hwRender = mkEnableOption "3D hardware acceleration to render the console";
fonts = mkOption {
description = "Fonts used by kmscon, in order of priority.";
default = null;
example = lib.literalExpression ''[ { name = "Source Code Pro"; package = pkgs.source-code-pro; } ]'';
type =
with types;
let
fontType = submodule {
options = {
name = mkOption {
type = str;
description = "Font name, as used by fontconfig.";
};
package = mkOption {
type = package;
description = "Package providing the font.";
};
};
};
in
nullOr (nonEmptyListOf fontType);
};
useXkbConfig = mkEnableOption "" // {
description = "Whether to configure keymap from xserver keyboard settings.";
};
extraConfig = mkOption {
description = "Extra contents of the kmscon.conf file.";
type = types.lines;
default = "";
example = "font-size=14";
};
extraOptions = mkOption {
description = "Extra flags to pass to kmscon.";
type = types.separatedString " ";
default = "";
example = "--term xterm-256color";
};
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.
'';
};
};
};
config = mkIf cfg.enable {
systemd.packages = [ cfg.package ];
systemd.services."kmsconvt@" = {
after = [
"systemd-logind.service"
"systemd-vconsole-setup.service"
];
requires = [ "systemd-logind.service" ];
serviceConfig.ExecStart = [
""
''
${cfg.package}/bin/kmscon "--vt=%I" ${cfg.extraOptions} --seats=seat0 --no-switchvt --configdir ${configDir} --login -- ${pkgs.shadow}/bin/login -p ${autologinArg}
''
];
restartIfChanged = false;
aliases = [ "autovt@.service" ];
};
systemd.suppressedSystemUnits = [ "autovt@.service" ];
systemd.services.systemd-vconsole-setup.enable = false;
systemd.services.reload-systemd-vconsole-setup.enable = false;
services.kmscon.extraConfig =
let
xkb = optionals cfg.useXkbConfig (
lib.mapAttrsToList (n: v: "xkb-${n}=${v}") (
lib.filterAttrs (
n: v:
builtins.elem n [
"layout"
"model"
"options"
"variant"
]
&& v != ""
) config.services.xserver.xkb
)
);
render = optionals cfg.hwRender [
"drm"
"hwaccel"
];
fonts =
optional (cfg.fonts != null)
"font-name=${lib.concatMapStringsSep ", " (f: f.name) cfg.fonts}";
in
lib.concatLines (xkb ++ render ++ fonts);
hardware.graphics.enable = mkIf cfg.hwRender true;
fonts = mkIf (cfg.fonts != null) {
fontconfig.enable = true;
packages = map (f: f.package) cfg.fonts;
};
};
}