2009-03-06 13:25:38 +01:00
|
|
|
{pkgs, config, ...}:
|
2007-04-04 19:10:38 +02:00
|
|
|
|
|
|
|
let
|
2009-03-06 13:25:38 +01:00
|
|
|
inherit (pkgs.lib) mkOption;
|
|
|
|
|
|
|
|
# think about where to put this chunk of code!
|
|
|
|
# required by other pieces as well
|
|
|
|
requiredTTYs = config.services.mingetty.ttys
|
|
|
|
++ config.boot.extraTTYs
|
|
|
|
++ [config.services.syslogd.tty];
|
|
|
|
ttyNumbers = requiredTTYs;
|
2007-04-04 19:10:38 +02:00
|
|
|
ttys = map (nr: "/dev/tty" + toString nr) ttyNumbers;
|
2009-03-06 13:25:38 +01:00
|
|
|
defaultLocale = config.i18n.defaultLocale;
|
|
|
|
consoleFont = config.i18n.consoleFont;
|
|
|
|
consoleKeyMap = config.i18n.consoleKeyMap;
|
2007-04-04 19:10:38 +02:00
|
|
|
|
|
|
|
in
|
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
###### implementation
|
|
|
|
|
|
|
|
# most options are defined in i18n.nix
|
|
|
|
|
2007-04-04 19:10:38 +02:00
|
|
|
{
|
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
inherit requiredTTYs; # pass them to upstart-job/default.nix
|
|
|
|
|
|
|
|
# dummy option so that requiredTTYs can be passed, see above (FIXME)
|
|
|
|
require = [
|
|
|
|
{
|
|
|
|
requiredTTYs = mkOption {
|
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
}
|
2007-04-04 19:10:38 +02:00
|
|
|
];
|
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
services = {
|
|
|
|
extraJobs = [{
|
|
|
|
name = "kbd";
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
extraPath = [
|
|
|
|
pkgs.kbd
|
|
|
|
];
|
|
|
|
|
|
|
|
job = "
|
|
|
|
description \"Keyboard / console initialisation\"
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
start on udev
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
script
|
2007-04-04 19:10:38 +02:00
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
export LANG=${defaultLocale}
|
|
|
|
export PATH=${pkgs.gzip}/bin:$PATH # Needed by setfont
|
|
|
|
|
|
|
|
set +e # continue in case of errors
|
|
|
|
|
|
|
|
|
|
|
|
# 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-03-06 13:25:38 +01: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
|
|
|
|
# UTF-8 encoded multibyte sequences.
|
|
|
|
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.
|
|
|
|
${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
|
|
|
|
# UTF-8 encoded multibyte sequences.
|
|
|
|
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}'
|
2007-04-04 19:10:38 +02:00
|
|
|
|
|
|
|
|
2009-03-06 13:25:38 +01:00
|
|
|
end script
|
|
|
|
";
|
|
|
|
|
|
|
|
}];
|
|
|
|
};
|
2007-04-04 19:10:38 +02:00
|
|
|
|
|
|
|
}
|