2009-10-12 19:27:57 +02:00
|
|
|
{ config, pkgs, ... }:
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-09-25 21:55:08 +02:00
|
|
|
with pkgs.lib;
|
|
|
|
|
2007-04-04 19:10:38 +02:00
|
|
|
let
|
2009-05-28 18:03:48 +02:00
|
|
|
|
2009-07-15 13:19:11 +02:00
|
|
|
# think about where to put this chunk of code!
|
|
|
|
# required by other pieces as well
|
|
|
|
requiredTTYs = config.services.mingetty.ttys
|
|
|
|
++ config.boot.extraTTYs
|
2009-09-25 21:55:08 +02:00
|
|
|
++ [ config.services.syslogd.tty ];
|
|
|
|
ttys = map (dev: "/dev/${dev}") requiredTTYs;
|
2009-07-15 13:19:11 +02:00
|
|
|
defaultLocale = config.i18n.defaultLocale;
|
|
|
|
consoleFont = config.i18n.consoleFont;
|
|
|
|
consoleKeyMap = config.i18n.consoleKeyMap;
|
2009-05-28 18:03:48 +02:00
|
|
|
|
2009-07-15 13:19:11 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
###### interface
|
2009-05-28 18:03:48 +02:00
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2009-07-15 13:19:11 +02:00
|
|
|
# most options are defined in i18n.nix
|
|
|
|
|
2009-09-25 21:55:08 +02:00
|
|
|
boot.extraTTYs = mkOption {
|
2009-05-28 18:03:48 +02:00
|
|
|
default = [];
|
2009-09-25 21:55:08 +02:00
|
|
|
example = ["tty8" "tty9"];
|
|
|
|
description = ''
|
2009-05-28 18:03:48 +02:00
|
|
|
Tty (virtual console) devices, in addition to the consoles on
|
|
|
|
which mingetty and syslogd run, that must be initialised.
|
|
|
|
Only useful if you have some program that you want to run on
|
|
|
|
some fixed console. For example, the NixOS installation CD
|
|
|
|
opens the manual in a web browser on console 7, so it sets
|
2009-09-25 21:55:08 +02:00
|
|
|
<option>boot.extraTTYs</option> to <literal>["tty7"]</literal>.
|
|
|
|
'';
|
2009-05-28 18:03:48 +02:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-05-28 18:03:48 +02:00
|
|
|
# dummy option so that requiredTTYs can be passed
|
2009-09-25 21:55:08 +02:00
|
|
|
requiredTTYs = mkOption {
|
2009-05-28 18:03:48 +02:00
|
|
|
default = [];
|
|
|
|
description = "
|
|
|
|
FIXME: find another place for this option.
|
|
|
|
FIXME: find a good description.
|
|
|
|
";
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-07-15 13:19:11 +02:00
|
|
|
};
|
2007-04-04 19:10:38 +02:00
|
|
|
|
|
|
|
|
2009-07-15 13:19:11 +02:00
|
|
|
###### implementation
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2011-09-14 20:20:50 +02:00
|
|
|
config = {
|
|
|
|
|
2009-07-15 13:19:11 +02:00
|
|
|
inherit requiredTTYs; # pass it to ./modules/tasks/tty-backgrounds.nix
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-07-15 13:19:11 +02:00
|
|
|
environment.systemPackages = [pkgs.kbd];
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-12 20:09:34 +02:00
|
|
|
jobs.kbd =
|
2009-10-12 19:27:57 +02:00
|
|
|
{ description = "Keyboard / console initialisation";
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-11-06 20:20:09 +01:00
|
|
|
startOn = "started udev";
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-11-06 20:20:09 +01:00
|
|
|
task = true;
|
|
|
|
|
|
|
|
script = ''
|
2009-03-06 13:25:38 +01:00
|
|
|
export LANG=${defaultLocale}
|
2009-06-05 19:18:20 +02:00
|
|
|
export LOCALE_ARCHIVE=/var/run/current-system/sw/lib/locale/locale-archive
|
2009-03-06 13:25:38 +01:00
|
|
|
export PATH=${pkgs.gzip}/bin:$PATH # Needed by setfont
|
|
|
|
|
|
|
|
set +e # continue in case of errors
|
|
|
|
|
2009-07-15 13:19:11 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
# Enable or disable UTF-8 mode. This is based on
|
|
|
|
# unicode_{start,stop}.
|
|
|
|
echo 'Enabling or disabling Unicode mode...'
|
|
|
|
|
|
|
|
charMap=$(${pkgs.glibc}/bin/locale charmap)
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-06-05 19:18:20 +02:00
|
|
|
if test "$charMap" = UTF-8; then
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
for tty in ${toString ttys}; do
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
# Tell the console output driver that the bytes arriving are
|
2011-09-14 20:20:50 +02:00
|
|
|
# UTF-8 encoded multibyte sequences.
|
2009-06-05 19:18:20 +02:00
|
|
|
echo -n -e '\033%G' > $tty
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
done
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
# Set the keyboard driver in UTF-8 mode.
|
2010-04-20 16:35:12 +02:00
|
|
|
# !!! Commented out because it running this while the X
|
|
|
|
# server is running kicks the X server out of raw mode.
|
|
|
|
# UTF-8 mode is the default nowadays anyway.
|
|
|
|
# ${pkgs.kbd}/bin/kbd_mode -u
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
else
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
for tty in ${toString ttys}; do
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
# Tell the console output driver that the bytes arriving are
|
2011-09-14 20:20:50 +02:00
|
|
|
# UTF-8 encoded multibyte sequences.
|
2009-06-05 19:18:20 +02:00
|
|
|
echo -n -e '\033%@' > $tty
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
done
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
# Set the keyboard driver in ASCII (or any 8-bit character
|
|
|
|
# set) mode.
|
|
|
|
${pkgs.kbd}/bin/kbd_mode -a
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
fi
|
2007-04-04 19:10:38 +02:00
|
|
|
|
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
# Set the console font.
|
|
|
|
for tty in ${toString ttys}; do
|
|
|
|
${pkgs.kbd}/bin/setfont -C $tty ${consoleFont}
|
|
|
|
done
|
2007-04-04 19:10:38 +02:00
|
|
|
|
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
# Set the keymap.
|
|
|
|
${pkgs.kbd}/bin/loadkeys '${consoleKeyMap}'
|
2009-09-25 21:55:08 +02:00
|
|
|
'';
|
|
|
|
};
|
2009-07-15 13:19:11 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
};
|
2007-04-04 19:10:38 +02:00
|
|
|
|
|
|
|
}
|