Convert "kbd" (i18n)
svn path=/nixos/branches/fix-style/; revision=14361
This commit is contained in:
parent
a86ae923d7
commit
bca405ae44
47
system/i18n.nix
Normal file
47
system/i18n.nix
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
let
|
||||||
|
inherit (pkgs.lib) mkOption mkIf;
|
||||||
|
|
||||||
|
options = {
|
||||||
|
i18n = {
|
||||||
|
defaultLocale = mkOption {
|
||||||
|
default = "en_US.UTF-8";
|
||||||
|
example = "nl_NL.UTF-8";
|
||||||
|
description = "
|
||||||
|
The default locale. It determines the language for program
|
||||||
|
messages, the format for dates and times, sort order, and so on.
|
||||||
|
It also determines the character set, such as UTF-8.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
consoleFont = mkOption {
|
||||||
|
default = "lat9w-16";
|
||||||
|
example = "LatArCyrHeb-16";
|
||||||
|
description = "
|
||||||
|
The font used for the virtual consoles. Leave empty to use
|
||||||
|
whatever the <command>setfont</command> program considers the
|
||||||
|
default font.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
consoleKeyMap = mkOption {
|
||||||
|
default = "us";
|
||||||
|
example = "fr";
|
||||||
|
description = "
|
||||||
|
The keyboard mapping table for the virtual consoles.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
|
mkIf config.services.pulseaudio.enable {
|
||||||
|
require = [
|
||||||
|
options
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
|
@ -2083,39 +2083,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
i18n = {
|
|
||||||
|
|
||||||
defaultLocale = mkOption {
|
|
||||||
default = "en_US.UTF-8";
|
|
||||||
example = "nl_NL.UTF-8";
|
|
||||||
description = "
|
|
||||||
The default locale. It determines the language for program
|
|
||||||
messages, the format for dates and times, sort order, and so on.
|
|
||||||
It also determines the character set, such as UTF-8.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
consoleFont = mkOption {
|
|
||||||
default = "lat9w-16";
|
|
||||||
example = "LatArCyrHeb-16";
|
|
||||||
description = "
|
|
||||||
The font used for the virtual consoles. Leave empty to use
|
|
||||||
whatever the <command>setfont</command> program considers the
|
|
||||||
default font.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
consoleKeyMap = mkOption {
|
|
||||||
default = "us";
|
|
||||||
example = "fr";
|
|
||||||
description = "
|
|
||||||
The keyboard mapping table for the virtual consoles.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
nesting = {
|
nesting = {
|
||||||
children = mkOption {
|
children = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
|
@ -2154,6 +2121,9 @@ in
|
||||||
# security
|
# security
|
||||||
(import ../system/sudo.nix)
|
(import ../system/sudo.nix)
|
||||||
|
|
||||||
|
# i18n
|
||||||
|
(import ../system/i18n.nix)
|
||||||
|
|
||||||
# environment
|
# environment
|
||||||
(import ../etc/default.nix)
|
(import ../etc/default.nix)
|
||||||
|
|
||||||
|
@ -2186,6 +2156,9 @@ in
|
||||||
(import ../upstart-jobs/rogue.nix)
|
(import ../upstart-jobs/rogue.nix)
|
||||||
(import ../upstart-jobs/guest-users.nix)
|
(import ../upstart-jobs/guest-users.nix)
|
||||||
(import ../upstart-jobs/pulseaudio.nix)
|
(import ../upstart-jobs/pulseaudio.nix)
|
||||||
|
(import ../upstart-jobs/kbd.nix)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
(import ../system/fonts.nix)
|
(import ../system/fonts.nix)
|
||||||
|
|
|
@ -66,10 +66,7 @@ let
|
||||||
|
|
||||||
optional = cond: service: pkgs.lib.optional cond (makeJob service);
|
optional = cond: service: pkgs.lib.optional cond (makeJob service);
|
||||||
|
|
||||||
requiredTTYs =
|
requiredTTYs = config.requiredTTYs;
|
||||||
config.services.mingetty.ttys
|
|
||||||
++ config.boot.extraTTYs
|
|
||||||
++ [config.services.syslogd.tty];
|
|
||||||
|
|
||||||
jobs = map makeJob
|
jobs = map makeJob
|
||||||
([
|
([
|
||||||
|
@ -138,15 +135,6 @@ let
|
||||||
inherit nssModulesPath;
|
inherit nssModulesPath;
|
||||||
})
|
})
|
||||||
|
|
||||||
# Console font and keyboard maps.
|
|
||||||
(import ../upstart-jobs/kbd.nix {
|
|
||||||
inherit (pkgs) glibc kbd gzip;
|
|
||||||
ttyNumbers = requiredTTYs;
|
|
||||||
defaultLocale = config.i18n.defaultLocale;
|
|
||||||
consoleFont = config.i18n.consoleFont;
|
|
||||||
consoleKeyMap = config.i18n.consoleKeyMap;
|
|
||||||
})
|
|
||||||
|
|
||||||
# Handles the maintenance/stalled event (single-user shell).
|
# Handles the maintenance/stalled event (single-user shell).
|
||||||
(import ../upstart-jobs/maintenance-shell.nix {
|
(import ../upstart-jobs/maintenance-shell.nix {
|
||||||
inherit (pkgs) bash;
|
inherit (pkgs) bash;
|
||||||
|
|
|
@ -1,78 +1,109 @@
|
||||||
{glibc, kbd, gzip, ttyNumbers, defaultLocale, consoleFont, consoleKeyMap}:
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
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;
|
||||||
ttys = map (nr: "/dev/tty" + toString nr) ttyNumbers;
|
ttys = map (nr: "/dev/tty" + toString nr) ttyNumbers;
|
||||||
|
defaultLocale = config.i18n.defaultLocale;
|
||||||
|
consoleFont = config.i18n.consoleFont;
|
||||||
|
consoleKeyMap = config.i18n.consoleKeyMap;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
|
# most options are defined in i18n.nix
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "kbd";
|
|
||||||
|
|
||||||
extraPath = [
|
inherit requiredTTYs; # pass them to upstart-job/default.nix
|
||||||
kbd
|
|
||||||
|
# dummy option so that requiredTTYs can be passed, see above (FIXME)
|
||||||
|
require = [
|
||||||
|
{
|
||||||
|
requiredTTYs = mkOption {
|
||||||
|
default = [];
|
||||||
|
};
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
job = "
|
|
||||||
description \"Keyboard / console initialisation\"
|
|
||||||
|
|
||||||
start on udev
|
services = {
|
||||||
|
extraJobs = [{
|
||||||
script
|
name = "kbd";
|
||||||
|
|
||||||
export LANG=${defaultLocale}
|
|
||||||
export PATH=${gzip}/bin:$PATH # Needed by setfont
|
|
||||||
|
|
||||||
set +e # continue in case of errors
|
|
||||||
|
|
||||||
|
extraPath = [
|
||||||
|
pkgs.kbd
|
||||||
|
];
|
||||||
|
|
||||||
# Enable or disable UTF-8 mode. This is based on
|
job = "
|
||||||
# unicode_{start,stop}.
|
description \"Keyboard / console initialisation\"
|
||||||
echo 'Enabling or disabling Unicode mode...'
|
|
||||||
|
|
||||||
charMap=$(${glibc}/bin/locale charmap)
|
start on udev
|
||||||
|
|
||||||
if test \"$charMap\" = UTF-8; then
|
script
|
||||||
|
|
||||||
for tty in ${toString ttys}; do
|
export LANG=${defaultLocale}
|
||||||
|
export PATH=${pkgs.gzip}/bin:$PATH # Needed by setfont
|
||||||
|
|
||||||
# Tell the console output driver that the bytes arriving are
|
set +e # continue in case of errors
|
||||||
# UTF-8 encoded multibyte sequences.
|
|
||||||
echo -n -e '\\033%G' > $tty
|
|
||||||
|
|
||||||
done
|
|
||||||
|
# Enable or disable UTF-8 mode. This is based on
|
||||||
|
# unicode_{start,stop}.
|
||||||
|
echo 'Enabling or disabling Unicode mode...'
|
||||||
|
|
||||||
# Set the keyboard driver in UTF-8 mode.
|
charMap=$(${pkgs.glibc}/bin/locale charmap)
|
||||||
${kbd}/bin/kbd_mode -u
|
|
||||||
|
|
||||||
else
|
if test \"$charMap\" = UTF-8; then
|
||||||
|
|
||||||
for tty in ${toString ttys}; do
|
for tty in ${toString ttys}; do
|
||||||
|
|
||||||
# Tell the console output driver that the bytes arriving are
|
# Tell the console output driver that the bytes arriving are
|
||||||
# UTF-8 encoded multibyte sequences.
|
# UTF-8 encoded multibyte sequences.
|
||||||
echo -n -e '\\033%@' > $tty
|
echo -n -e '\\033%G' > $tty
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Set the keyboard driver in ASCII (or any 8-bit character
|
# Set the keyboard driver in UTF-8 mode.
|
||||||
# set) mode.
|
${pkgs.kbd}/bin/kbd_mode -u
|
||||||
${kbd}/bin/kbd_mode -a
|
|
||||||
|
|
||||||
fi
|
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.
|
# Set the console font.
|
||||||
for tty in ${toString ttys}; do
|
for tty in ${toString ttys}; do
|
||||||
${kbd}/bin/setfont -C $tty ${consoleFont}
|
${pkgs.kbd}/bin/setfont -C $tty ${consoleFont}
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# Set the keymap.
|
# Set the keymap.
|
||||||
${kbd}/bin/loadkeys '${consoleKeyMap}'
|
${pkgs.kbd}/bin/loadkeys '${consoleKeyMap}'
|
||||||
|
|
||||||
|
|
||||||
end script
|
end script
|
||||||
";
|
";
|
||||||
|
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue