Create /etc/locale.conf and /etc/vconsole.conf

Systemd's systemd-vconsole-setup.service reads locale and console
font/keymap settings from these files.  In particular, it sets the
virtual console to UTF-8 mode depending on the LANG setting.

This removed the need for the kbd job.
This commit is contained in:
Eelco Dolstra 2012-07-24 13:53:17 -04:00
parent 71ca633431
commit e4ed2120fd
2 changed files with 29 additions and 75 deletions

View file

@ -1,8 +1,10 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
###### interface
let
inherit (pkgs.lib) mkOption mkIf;
options = {
i18n = {
@ -45,16 +47,15 @@ let
The keyboard mapping table for the virtual consoles.
";
};
};
};
in
###### implementation
let
glibcLocales = pkgs.glibcLocales.override {
allLocales = pkgs.lib.any (x: x == "all") config.i18n.supportedLocales;
allLocales = any (x: x == "all") config.i18n.supportedLocales;
locales = config.i18n.supportedLocales;
};
@ -63,10 +64,19 @@ in
{
require = options;
environment.systemPackages = [glibcLocales];
environment.systemPackages = [ glibcLocales ];
environment.shellInit =
''
export LANG=${config.i18n.defaultLocale}
'';
# /etc/locale.conf is used by systemd.
environment.etc = singleton
{ target = "locale.conf";
source = pkgs.writeText "locale.conf"
''
LANG=${config.i18n.defaultLocale}
'';
};
}

View file

@ -10,7 +10,6 @@ let
++ config.boot.extraTTYs
++ [ config.services.syslogd.tty ];
ttys = map (dev: "/dev/${dev}") requiredTTYs;
defaultLocale = config.i18n.defaultLocale;
consoleFont = config.i18n.consoleFont;
consoleKeyMap = config.i18n.consoleKeyMap;
@ -23,6 +22,7 @@ in
# most options are defined in i18n.nix
# FIXME: still needed?
boot.extraTTYs = mkOption {
default = [];
example = ["tty8" "tty9"];
@ -56,73 +56,17 @@ in
environment.systemPackages = [ pkgs.kbd ];
/* FIXME - remove; this is handled by systemd now.
jobs.kbd =
{ description = "Keyboard / console initialisation";
startOn = "started udev";
task = true;
script = ''
export LANG=${defaultLocale}
export LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
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)
if test "$charMap" = UTF-8; then
for tty in ${toString ttys}; do
# Tell the console output driver that the bytes arriving are
# UTF-8 encoded multibyte sequences.
echo -n -e '\033%G' > $tty
done
# Set the keyboard driver in UTF-8 mode.
# !!! 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
else
for tty in ${toString ttys}; do
# Tell the console output driver that the bytes arriving are
# UTF-8 encoded multibyte sequences.
echo -n -e '\033%@' > $tty
done
# Set the keyboard driver in ASCII (or any 8-bit character
# set) mode.
${pkgs.kbd}/bin/kbd_mode -a
fi
# Set the console font.
for tty in ${toString ttys}; do
${pkgs.kbd}/bin/setfont -C $tty ${consoleFont}
done
# Set the keymap.
${pkgs.kbd}/bin/loadkeys '${consoleKeyMap}'
'';
# Let systemd-vconsole-setup.service do the work of setting up the
# virtual consoles. FIXME: trigger a restart of
# systemd-vconsole-setup.service if /etc/vconsole.conf changes.
environment.etc = singleton
{ target = "vconsole.conf";
source = pkgs.writeText "vconsole.conf"
''
KEYMAP=${consoleKeyMap}
FONT=${consoleFont}
'';
};
*/
};