diff options
author | Jan Malakhovski <oxij@oxij.org> | 2015-09-18 16:50:48 +0000 |
---|---|---|
committer | Jan Malakhovski <oxij@oxij.org> | 2016-01-08 22:26:15 +0000 |
commit | 119c8f91e7f17d2cb95f42985816820600c389cf (patch) | |
tree | 0bd34b6a522114777f34668fb6d6c36c331eaea1 /nixos/modules/services/ttys | |
parent | 732eb3c4ccaac3312fe9334b5d77b3b88140c971 (diff) | |
download | nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar.gz nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar.bz2 nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar.lz nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar.xz nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar.zst nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.zip |
nixos: introduce system.nixosLabel option and use it where appropriate
Setting nixosVersion to something custom is useful for meaningful GRUB menus and /nix/store paths, but actuallly changing it rebulids the whole system path (because of `nixos-version` script and manual pages). Also, changing it is not a particularly good idea because you can then be differentitated from other NixOS users by a lot of programs that read /etc/os-release. This patch introduces an alternative option that does all you want from nixosVersion, but rebuilds only the very top system level and /etc while using your label in the names of system /nix/store paths, GRUB and other boot loaders' menus, getty greetings and so on.
Diffstat (limited to 'nixos/modules/services/ttys')
-rw-r--r-- | nixos/modules/services/ttys/agetty.nix | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/nixos/modules/services/ttys/agetty.nix b/nixos/modules/services/ttys/agetty.nix index 85ee23c1a3dd..ea7196fc8733 100644 --- a/nixos/modules/services/ttys/agetty.nix +++ b/nixos/modules/services/ttys/agetty.nix @@ -2,6 +2,13 @@ with lib; +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 + { ###### interface @@ -21,9 +28,9 @@ with lib; greetingLine = mkOption { type = types.str; - default = ''<<< Welcome to NixOS ${config.system.nixosVersion} (\m) - \l >>>''; description = '' Welcome line printed by mingetty. + The default shows current NixOS version label, machine type and tty. ''; }; @@ -55,10 +62,11 @@ with lib; ###### implementation - 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 { + config = { + # Note: this is set here rather than up there so that changing + # nixosLabel would not rebuild manual pages + services.mingetty.greetingLine = mkDefault ''<<< Welcome to NixOS ${config.system.nixosLabel} (\m) - \l >>>''; + systemd.services."getty@" = { serviceConfig.ExecStart = gettyCmd "--noclear --keep-baud %I 115200,38400,9600 $TERM"; restartIfChanged = false; @@ -81,7 +89,7 @@ with lib; { serviceConfig.ExecStart = gettyCmd "--noclear --keep-baud console 115200,38400,9600 $TERM"; serviceConfig.Restart = "always"; restartIfChanged = false; - enable = mkDefault config.boot.isContainer; + enable = mkDefault config.boot.isContainer; }; environment.etc = singleton |