diff options
author | Alyssa Ross <hi@alyssa.is> | 2022-05-31 09:59:33 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2022-05-31 09:59:57 +0000 |
commit | 9ff36293d1e428cd7bf03e8d4b03611b6d361c28 (patch) | |
tree | 1ab51a42b868c55b83f6ccdb80371b9888739dd9 /nixos/modules/services/ttys/getty.nix | |
parent | 1c4fcd0d4b0541e674ee56ace1053e23e562cc80 (diff) | |
parent | ddc3c396a51918043bb0faa6f676abd9562be62c (diff) | |
download | nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar.gz nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar.bz2 nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar.lz nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar.xz nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar.zst nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.zip |
Last good Nixpkgs for Weston+nouveau? archive
I came this commit hash to terwiz[m] on IRC, who is trying to figure out what the last version of Spectrum that worked on their NUC with Nvidia graphics is.
Diffstat (limited to 'nixos/modules/services/ttys/getty.nix')
-rw-r--r-- | nixos/modules/services/ttys/getty.nix | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/nixos/modules/services/ttys/getty.nix b/nixos/modules/services/ttys/getty.nix new file mode 100644 index 00000000000..7021a2c80f8 --- /dev/null +++ b/nixos/modules/services/ttys/getty.nix @@ -0,0 +1,162 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.getty; + + baseArgs = [ + "--login-program" "${cfg.loginProgram}" + ] ++ optionals (cfg.autologinUser != null) [ + "--autologin" cfg.autologinUser + ] ++ optionals (cfg.loginOptions != null) [ + "--login-options" cfg.loginOptions + ] ++ cfg.extraArgs; + + gettyCmd = args: + "@${pkgs.util-linux}/sbin/agetty agetty ${escapeShellArgs baseArgs} ${args}"; + +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. + ''; + }; + + 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 + <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. + ''; + 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 = { + # 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 NixOS ${config.system.nixos.label} (\m) - \l >>>''; + + systemd.services."getty@" = + { serviceConfig.ExecStart = [ + "" # override upstream default with an empty ExecStart + (gettyCmd "--noclear --keep-baud %I 115200,38400,9600 $TERM") + ]; + 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 = + { # Friendly greeting on the virtual consoles. + source = pkgs.writeText "issue" '' + + [1;32m${config.services.getty.greetingLine}[0m + ${config.services.getty.helpLine} + + ''; + }; + + }; + +} |