mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-11 15:27:20 +03:00
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,78 +1,109 @@
|
||||
{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
|
||||
|
||||
{
|
||||
name = "kbd";
|
||||
|
||||
extraPath = [
|
||||
kbd
|
||||
inherit requiredTTYs; # pass them to upstart-job/default.nix
|
||||
|
||||
# dummy option so that requiredTTYs can be passed, see above (FIXME)
|
||||
require = [
|
||||
{
|
||||
requiredTTYs = mkOption {
|
||||
default = [];
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
job = "
|
||||
description \"Keyboard / console initialisation\"
|
||||
|
||||
start on udev
|
||||
|
||||
script
|
||||
|
||||
export LANG=${defaultLocale}
|
||||
export PATH=${gzip}/bin:$PATH # Needed by setfont
|
||||
|
||||
set +e # continue in case of errors
|
||||
services = {
|
||||
extraJobs = [{
|
||||
name = "kbd";
|
||||
|
||||
extraPath = [
|
||||
pkgs.kbd
|
||||
];
|
||||
|
||||
# Enable or disable UTF-8 mode. This is based on
|
||||
# unicode_{start,stop}.
|
||||
echo 'Enabling or disabling Unicode mode...'
|
||||
job = "
|
||||
description \"Keyboard / console initialisation\"
|
||||
|
||||
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
|
||||
# UTF-8 encoded multibyte sequences.
|
||||
echo -n -e '\\033%G' > $tty
|
||||
set +e # continue in case of errors
|
||||
|
||||
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.
|
||||
${kbd}/bin/kbd_mode -u
|
||||
charMap=$(${pkgs.glibc}/bin/locale charmap)
|
||||
|
||||
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
|
||||
# UTF-8 encoded multibyte sequences.
|
||||
echo -n -e '\\033%@' > $tty
|
||||
# Tell the console output driver that the bytes arriving are
|
||||
# UTF-8 encoded multibyte sequences.
|
||||
echo -n -e '\\033%G' > $tty
|
||||
|
||||
done
|
||||
done
|
||||
|
||||
# Set the keyboard driver in ASCII (or any 8-bit character
|
||||
# set) mode.
|
||||
${kbd}/bin/kbd_mode -a
|
||||
# Set the keyboard driver in UTF-8 mode.
|
||||
${pkgs.kbd}/bin/kbd_mode -u
|
||||
|
||||
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.
|
||||
for tty in ${toString ttys}; do
|
||||
${kbd}/bin/setfont -C $tty ${consoleFont}
|
||||
done
|
||||
# Set the console font.
|
||||
for tty in ${toString ttys}; do
|
||||
${pkgs.kbd}/bin/setfont -C $tty ${consoleFont}
|
||||
done
|
||||
|
||||
|
||||
# Set the keymap.
|
||||
${kbd}/bin/loadkeys '${consoleKeyMap}'
|
||||
# Set the keymap.
|
||||
${pkgs.kbd}/bin/loadkeys '${consoleKeyMap}'
|
||||
|
||||
|
||||
end script
|
||||
";
|
||||
|
||||
end script
|
||||
";
|
||||
|
||||
}];
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user