Convert "kbd" (i18n)
svn path=/nixos/branches/fix-style/; revision=14361
This commit is contained in:
parent
a86ae923d7
commit
bca405ae44
|
@ -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,16 +1,44 @@
|
||||||
{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
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
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";
|
name = "kbd";
|
||||||
|
|
||||||
extraPath = [
|
extraPath = [
|
||||||
kbd
|
pkgs.kbd
|
||||||
];
|
];
|
||||||
|
|
||||||
job = "
|
job = "
|
||||||
|
@ -21,7 +49,7 @@ in
|
||||||
script
|
script
|
||||||
|
|
||||||
export LANG=${defaultLocale}
|
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
|
set +e # continue in case of errors
|
||||||
|
|
||||||
|
@ -30,7 +58,7 @@ in
|
||||||
# unicode_{start,stop}.
|
# unicode_{start,stop}.
|
||||||
echo 'Enabling or disabling Unicode mode...'
|
echo 'Enabling or disabling Unicode mode...'
|
||||||
|
|
||||||
charMap=$(${glibc}/bin/locale charmap)
|
charMap=$(${pkgs.glibc}/bin/locale charmap)
|
||||||
|
|
||||||
if test \"$charMap\" = UTF-8; then
|
if test \"$charMap\" = UTF-8; then
|
||||||
|
|
||||||
|
@ -43,7 +71,7 @@ in
|
||||||
done
|
done
|
||||||
|
|
||||||
# Set the keyboard driver in UTF-8 mode.
|
# Set the keyboard driver in UTF-8 mode.
|
||||||
${kbd}/bin/kbd_mode -u
|
${pkgs.kbd}/bin/kbd_mode -u
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
@ -57,22 +85,25 @@ in
|
||||||
|
|
||||||
# Set the keyboard driver in ASCII (or any 8-bit character
|
# Set the keyboard driver in ASCII (or any 8-bit character
|
||||||
# set) mode.
|
# set) mode.
|
||||||
${kbd}/bin/kbd_mode -a
|
${pkgs.kbd}/bin/kbd_mode -a
|
||||||
|
|
||||||
fi
|
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 New Issue