summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorlethalman <lucabru@src.gnome.org>2015-04-15 15:37:12 +0200
committerlethalman <lucabru@src.gnome.org>2015-04-15 15:37:12 +0200
commit8330d64af4d664a0a5971a36ce198a3134c9d912 (patch)
treef7feaf356c32c3d706c0c0ee8b5879de930e6c02 /nixos
parent77a153a6552f08766d7d3b2747e5c70ca3b99879 (diff)
parent25062f56d465d864f61b390ecd7647a3028a514a (diff)
downloadnixlib-8330d64af4d664a0a5971a36ce198a3134c9d912.tar
nixlib-8330d64af4d664a0a5971a36ce198a3134c9d912.tar.gz
nixlib-8330d64af4d664a0a5971a36ce198a3134c9d912.tar.bz2
nixlib-8330d64af4d664a0a5971a36ce198a3134c9d912.tar.lz
nixlib-8330d64af4d664a0a5971a36ce198a3134c9d912.tar.xz
nixlib-8330d64af4d664a0a5971a36ce198a3134c9d912.tar.zst
nixlib-8330d64af4d664a0a5971a36ce198a3134c9d912.zip
Merge pull request #7372 from dezgeg/getty-autologin
[nixos] agetty: Add autologinUser config option
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/profiles/installation-device.nix5
-rw-r--r--nixos/modules/services/ttys/agetty.nix23
2 files changed, 21 insertions, 7 deletions
diff --git a/nixos/modules/profiles/installation-device.nix b/nixos/modules/profiles/installation-device.nix
index 5aab2a2954e7..f1e733080573 100644
--- a/nixos/modules/profiles/installation-device.nix
+++ b/nixos/modules/profiles/installation-device.nix
@@ -30,11 +30,14 @@ with lib;
     # the full glibcLocales package.
     i18n.supportedLocales = ["en_US.UTF-8/UTF-8" "en_US/ISO-8859-1"];
 
+    # Automatically log in at the virtual consoles.
+    services.mingetty.autologinUser = "root";
+
     # Some more help text.
     services.mingetty.helpLine =
       ''
 
-        Log in as "root" with an empty password.  ${
+        The "root" account has an empty password.  ${
           optionalString config.services.xserver.enable
             "Type `start display-manager' to\nstart the graphical user interface."}
       '';
diff --git a/nixos/modules/services/ttys/agetty.nix b/nixos/modules/services/ttys/agetty.nix
index 3958be33df2c..85ee23c1a3dd 100644
--- a/nixos/modules/services/ttys/agetty.nix
+++ b/nixos/modules/services/ttys/agetty.nix
@@ -10,6 +10,15 @@ with lib;
 
     services.mingetty = {
 
+      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.
+        '';
+      };
+
       greetingLine = mkOption {
         type = types.str;
         default = ''<<< Welcome to NixOS ${config.system.nixosVersion} (\m) - \l >>>'';
@@ -46,28 +55,30 @@ with lib;
 
   ###### implementation
 
-  config = {
-
+  config = let
+    autologinArg = optionalString (config.services.mingetty.autologinUser != null) "--autologin ${config.services.mingetty.autologinUser}";
+    gettyCmd = extraArgs: "@${pkgs.utillinux}/sbin/agetty agetty --login-program ${pkgs.shadow}/bin/login ${autologinArg} ${extraArgs}";
+  in {
     systemd.services."getty@" =
-      { serviceConfig.ExecStart = "@${pkgs.utillinux}/sbin/agetty agetty --noclear --login-program ${pkgs.shadow}/bin/login --keep-baud %I 115200,38400,9600 $TERM";
+      { serviceConfig.ExecStart = gettyCmd "--noclear --keep-baud %I 115200,38400,9600 $TERM";
         restartIfChanged = false;
       };
 
     systemd.services."serial-getty@" =
       { serviceConfig.ExecStart =
           let speeds = concatStringsSep "," (map toString config.services.mingetty.serialSpeed);
-          in "@${pkgs.utillinux}/sbin/agetty agetty --login-program ${pkgs.shadow}/bin/login %I ${speeds} $TERM";
+          in gettyCmd "%I ${speeds} $TERM";
         restartIfChanged = false;
       };
 
     systemd.services."container-getty@" =
       { unitConfig.ConditionPathExists = "/dev/pts/%I"; # Work around being respawned when "machinectl login" exits.
-        serviceConfig.ExecStart = "@${pkgs.utillinux}/sbin/agetty agetty --noclear --login-program ${pkgs.shadow}/bin/login --keep-baud pts/%I 115200,38400,9600 $TERM";
+        serviceConfig.ExecStart = gettyCmd "--noclear --keep-baud pts/%I 115200,38400,9600 $TERM";
         restartIfChanged = false;
       };
 
     systemd.services."console-getty" =
-      { serviceConfig.ExecStart = "@${pkgs.utillinux}/sbin/agetty agetty --noclear --login-program ${pkgs.shadow}/bin/login --keep-baud console 115200,38400,9600 $TERM";
+      { serviceConfig.ExecStart = gettyCmd "--noclear --keep-baud console 115200,38400,9600 $TERM";
         serviceConfig.Restart = "always";
         restartIfChanged = false;
 	enable = mkDefault config.boot.isContainer;