Skip to content

Commit 7fb2f40

Browse files
committed
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.
1 parent afb08a9 commit 7fb2f40

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

nixos/modules/config/console.nix

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,6 @@ in
128128
'');
129129
}
130130

131-
(lib.mkIf (!cfg.enable) {
132-
systemd.services = {
133-
"serial-getty@ttyS0".enable = false;
134-
"serial-getty@hvc0".enable = false;
135-
"getty@tty1".enable = false;
136-
"autovt@".enable = false;
137-
systemd-vconsole-setup.enable = false;
138-
};
139-
})
140-
141131
(lib.mkIf cfg.enable (lib.mkMerge [
142132
{ environment.systemPackages = [ pkgs.kbd ];
143133

@@ -178,6 +168,10 @@ in
178168
"${cfg.keyMap}"
179169
];
180170

171+
systemd.additionalUpstreamSystemUnits = [
172+
"systemd-vconsole-setup.service"
173+
];
174+
181175
systemd.services.reload-systemd-vconsole-setup =
182176
{ description = "Reset console on configuration changes";
183177
wantedBy = [ "multi-user.target" ];

nixos/modules/services/ttys/getty.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,21 @@ in
120120

121121
###### implementation
122122

123-
config = {
123+
config = mkIf config.console.enable {
124124
# Note: this is set here rather than up there so that changing
125125
# nixos.label would not rebuild manual pages
126126
services.getty.greetingLine = mkDefault ''<<< Welcome to ${config.system.nixos.distroName} ${config.system.nixos.label} (\m) - \l >>>'';
127127
services.getty.helpLine = mkIf (config.documentation.nixos.enable && config.documentation.doc.enable) "\nRun 'nixos-help' for the NixOS manual.";
128128

129+
systemd.additionalUpstreamSystemUnits = [
130+
"getty.target"
131+
"getty-pre.target"
132+
133+
134+
"console-getty.service"
135+
136+
];
137+
129138
systemd.services."getty@" =
130139
{ serviceConfig.ExecStart = [
131140
# override upstream default with an empty ExecStart

nixos/modules/system/boot/systemd.nix

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@ let
6060
# hwdb.bin is managed by NixOS
6161
# "systemd-hwdb-update.service"
6262

63-
# Consoles.
64-
"getty.target"
65-
"getty-pre.target"
66-
67-
68-
"console-getty.service"
69-
70-
"systemd-vconsole-setup.service"
71-
7263
# Hardware (started by udev when a relevant device is plugged in).
7364
"sound.target"
7465
"bluetooth.target"

0 commit comments

Comments
 (0)