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 = {
|
||||
children = mkOption {
|
||||
default = [];
|
||||
|
@ -2154,6 +2121,9 @@ in
|
|||
# security
|
||||
(import ../system/sudo.nix)
|
||||
|
||||
# i18n
|
||||
(import ../system/i18n.nix)
|
||||
|
||||
# environment
|
||||
(import ../etc/default.nix)
|
||||
|
||||
|
@ -2186,6 +2156,9 @@ in
|
|||
(import ../upstart-jobs/rogue.nix)
|
||||
(import ../upstart-jobs/guest-users.nix)
|
||||
(import ../upstart-jobs/pulseaudio.nix)
|
||||
(import ../upstart-jobs/kbd.nix)
|
||||
|
||||
|
||||
|
||||
# fonts
|
||||
(import ../system/fonts.nix)
|
||||
|
|
|
@ -66,10 +66,7 @@ let
|
|||
|
||||
optional = cond: service: pkgs.lib.optional cond (makeJob service);
|
||||
|
||||
requiredTTYs =
|
||||
config.services.mingetty.ttys
|
||||
++ config.boot.extraTTYs
|
||||
++ [config.services.syslogd.tty];
|
||||
requiredTTYs = config.requiredTTYs;
|
||||
|
||||
jobs = map makeJob
|
||||
([
|
||||
|
@ -138,15 +135,6 @@ let
|
|||
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).
|
||||
(import ../upstart-jobs/maintenance-shell.nix {
|
||||
inherit (pkgs) bash;
|
||||
|
|
|
@ -1,16 +1,44 @@
|
|||
{glibc, kbd, gzip, ttyNumbers, defaultLocale, consoleFont, consoleKeyMap}:
|
||||
{pkgs, config, ...}:
|
||||
|
||||
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;
|
||||
defaultLocale = config.i18n.defaultLocale;
|
||||
consoleFont = config.i18n.consoleFont;
|
||||
consoleKeyMap = config.i18n.consoleKeyMap;
|
||||
|
||||
in
|
||||
|
||||
###### implementation
|
||||
|
||||
# most options are defined in i18n.nix
|
||||
|
||||
{
|
||||
|
||||
inherit requiredTTYs; # pass them to upstart-job/default.nix
|
||||
|
||||
# dummy option so that requiredTTYs can be passed, see above (FIXME)
|
||||
require = [
|
||||
{
|
||||
requiredTTYs = mkOption {
|
||||
default = [];
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
services = {
|
||||
extraJobs = [{
|
||||
name = "kbd";
|
||||
|
||||
extraPath = [
|
||||
kbd
|
||||
pkgs.kbd
|
||||
];
|
||||
|
||||
job = "
|
||||
|
@ -21,7 +49,7 @@ in
|
|||
script
|
||||
|
||||
export LANG=${defaultLocale}
|
||||
export PATH=${gzip}/bin:$PATH # Needed by setfont
|
||||
export PATH=${pkgs.gzip}/bin:$PATH # Needed by setfont
|
||||
|
||||
set +e # continue in case of errors
|
||||
|
||||
|
@ -30,7 +58,7 @@ in
|
|||
# unicode_{start,stop}.
|
||||
echo 'Enabling or disabling Unicode mode...'
|
||||
|
||||
charMap=$(${glibc}/bin/locale charmap)
|
||||
charMap=$(${pkgs.glibc}/bin/locale charmap)
|
||||
|
||||
if test \"$charMap\" = UTF-8; then
|
||||
|
||||
|
@ -43,7 +71,7 @@ in
|
|||
done
|
||||
|
||||
# Set the keyboard driver in UTF-8 mode.
|
||||
${kbd}/bin/kbd_mode -u
|
||||
${pkgs.kbd}/bin/kbd_mode -u
|
||||
|
||||
else
|
||||
|
||||
|
@ -57,22 +85,25 @@ in
|
|||
|
||||
# Set the keyboard driver in ASCII (or any 8-bit character
|
||||
# set) mode.
|
||||
${kbd}/bin/kbd_mode -a
|
||||
${pkgs.kbd}/bin/kbd_mode -a
|
||||
|
||||
fi
|
||||
|
||||
|
||||
# Set the console font.
|
||||
for tty in ${toString ttys}; do
|
||||
${kbd}/bin/setfont -C $tty ${consoleFont}
|
||||
${pkgs.kbd}/bin/setfont -C $tty ${consoleFont}
|
||||
done
|
||||
|
||||
|
||||
# Set the keymap.
|
||||
${kbd}/bin/loadkeys '${consoleKeyMap}'
|
||||
${pkgs.kbd}/bin/loadkeys '${consoleKeyMap}'
|
||||
|
||||
|
||||
end script
|
||||
";
|
||||
|
||||
}];
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue