Convert "tty-backgrounds"
svn path=/nixos/branches/fix-style/; revision=14396
This commit is contained in:
parent
3679813f37
commit
98ea167131
@ -380,69 +380,6 @@ in
|
|||||||
";
|
";
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
|
||||||
|
|
||||||
|
|
||||||
ttyBackgrounds = {
|
|
||||||
|
|
||||||
enable = mkOption {
|
|
||||||
default = true;
|
|
||||||
description = "
|
|
||||||
Whether to enable graphical backgrounds for the virtual consoles.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultTheme = mkOption {
|
|
||||||
default = pkgs.fetchurl {
|
|
||||||
#url = http://www.bootsplash.de/files/themes/Theme-BabyTux.tar.bz2;
|
|
||||||
url = http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo/distfiles/Theme-BabyTux.tar.bz2;
|
|
||||||
md5 = "a6d89d1c1cff3b6a08e2f526f2eab4e0";
|
|
||||||
};
|
|
||||||
description = "
|
|
||||||
The default theme for the virtual consoles. Themes can be found
|
|
||||||
at <link xlink:href='http://www.bootsplash.de/' />.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultSpecificThemes = mkOption {
|
|
||||||
default = [
|
|
||||||
/*
|
|
||||||
{ tty = 6;
|
|
||||||
theme = pkgs.fetchurl { # Yeah!
|
|
||||||
url = http://www.bootsplash.de/files/themes/Theme-Pativo.tar.bz2;
|
|
||||||
md5 = "9e13beaaadf88d43a5293e7ab757d569";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
{ tty = 10;
|
|
||||||
theme = pkgs.fetchurl {
|
|
||||||
#url = http://www.bootsplash.de/files/themes/Theme-GNU.tar.bz2;
|
|
||||||
url = http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo/distfiles/Theme-GNU.tar.bz2;
|
|
||||||
md5 = "61969309d23c631e57b0a311102ef034";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
description = "
|
|
||||||
This option sets specific themes for virtual consoles. If you
|
|
||||||
just want to set themes for additional consoles, use
|
|
||||||
<option>services.ttyBackgrounds.specificThemes</option>.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
specificThemes = mkOption {
|
|
||||||
default = [
|
|
||||||
];
|
|
||||||
description = "
|
|
||||||
This option allows you to set specific themes for virtual
|
|
||||||
consoles.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
nesting = {
|
nesting = {
|
||||||
children = mkOption {
|
children = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
@ -547,6 +484,7 @@ in
|
|||||||
(import ../upstart-jobs/dovecot.nix)
|
(import ../upstart-jobs/dovecot.nix)
|
||||||
(import ../upstart-jobs/bind.nix)
|
(import ../upstart-jobs/bind.nix)
|
||||||
(import ../upstart-jobs/mingetty.nix) # The terminals on ttyX.
|
(import ../upstart-jobs/mingetty.nix) # The terminals on ttyX.
|
||||||
|
(import ../upstart-jobs/tty-backgrounds.nix)
|
||||||
|
|
||||||
# nix
|
# nix
|
||||||
(import ../upstart-jobs/nix.nix) # nix options and daemon
|
(import ../upstart-jobs/nix.nix) # nix options and daemon
|
||||||
|
@ -140,37 +140,6 @@ let
|
|||||||
["reboot" "halt" "system-halt" "power-off"]
|
["reboot" "halt" "system-halt" "power-off"]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Transparent TTY backgrounds.
|
|
||||||
++ optional (config.services.ttyBackgrounds.enable && kernelPackages.splashutils != null)
|
|
||||||
(import ../upstart-jobs/tty-backgrounds.nix {
|
|
||||||
inherit (pkgs) stdenv;
|
|
||||||
inherit (kernelPackages) splashutils;
|
|
||||||
|
|
||||||
backgrounds =
|
|
||||||
|
|
||||||
let
|
|
||||||
|
|
||||||
specificThemes =
|
|
||||||
config.services.ttyBackgrounds.defaultSpecificThemes
|
|
||||||
++ config.services.ttyBackgrounds.specificThemes;
|
|
||||||
|
|
||||||
overridenTTYs = map (x: x.tty) specificThemes;
|
|
||||||
|
|
||||||
# Use the default theme for all the mingetty ttys and for the
|
|
||||||
# syslog tty, except those for which a specific theme is
|
|
||||||
# specified.
|
|
||||||
defaultTTYs =
|
|
||||||
pkgs.lib.filter (x: !(pkgs.lib.elem x overridenTTYs)) requiredTTYs;
|
|
||||||
|
|
||||||
in
|
|
||||||
(map (ttyNumber: {
|
|
||||||
tty = ttyNumber;
|
|
||||||
theme = config.services.ttyBackgrounds.defaultTheme;
|
|
||||||
}) defaultTTYs)
|
|
||||||
++ specificThemes;
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
# User-defined events.
|
# User-defined events.
|
||||||
++ (map makeJob (config.services.extraJobs));
|
++ (map makeJob (config.services.extraJobs));
|
||||||
|
|
||||||
|
@ -1,11 +1,100 @@
|
|||||||
{stdenv, splashutils, backgrounds}:
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
rec {
|
###### interface
|
||||||
name = "tty-backgrounds";
|
let
|
||||||
|
inherit (pkgs.lib) mkOption mkIf;
|
||||||
|
|
||||||
unpackTheme = theme: import ../helpers/unpack-theme.nix {
|
options = {
|
||||||
inherit stdenv theme;
|
services = {
|
||||||
|
ttyBackgrounds = {
|
||||||
|
|
||||||
|
enable = mkOption {
|
||||||
|
default = true;
|
||||||
|
description = "
|
||||||
|
Whether to enable graphical backgrounds for the virtual consoles.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultTheme = mkOption {
|
||||||
|
default = pkgs.fetchurl {
|
||||||
|
#url = http://www.bootsplash.de/files/themes/Theme-BabyTux.tar.bz2;
|
||||||
|
url = http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo/distfiles/Theme-BabyTux.tar.bz2;
|
||||||
|
md5 = "a6d89d1c1cff3b6a08e2f526f2eab4e0";
|
||||||
|
};
|
||||||
|
description = "
|
||||||
|
The default theme for the virtual consoles. Themes can be found
|
||||||
|
at <link xlink:href='http://www.bootsplash.de/' />.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultSpecificThemes = mkOption {
|
||||||
|
default = [
|
||||||
|
/*
|
||||||
|
{ tty = 6;
|
||||||
|
theme = pkgs.fetchurl { # Yeah!
|
||||||
|
url = http://www.bootsplash.de/files/themes/Theme-Pativo.tar.bz2;
|
||||||
|
md5 = "9e13beaaadf88d43a5293e7ab757d569";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
{ tty = 10;
|
||||||
|
theme = pkgs.fetchurl {
|
||||||
|
#url = http://www.bootsplash.de/files/themes/Theme-GNU.tar.bz2;
|
||||||
|
url = http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo/distfiles/Theme-GNU.tar.bz2;
|
||||||
|
md5 = "61969309d23c631e57b0a311102ef034";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
description = "
|
||||||
|
This option sets specific themes for virtual consoles. If you
|
||||||
|
just want to set themes for additional consoles, use
|
||||||
|
<option>services.ttyBackgrounds.specificThemes</option>.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
specificThemes = mkOption {
|
||||||
|
default = [
|
||||||
|
];
|
||||||
|
description = "
|
||||||
|
This option allows you to set specific themes for virtual
|
||||||
|
consoles.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (pkgs) stdenv;
|
||||||
|
kernelPackages = config.boot.kernelPackages;
|
||||||
|
splashutils = kernelPackages.splashutils;
|
||||||
|
requiredTTYs = config.requiredTTYs;
|
||||||
|
backgrounds =
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
specificThemes =
|
||||||
|
config.services.ttyBackgrounds.defaultSpecificThemes
|
||||||
|
++ config.services.ttyBackgrounds.specificThemes;
|
||||||
|
|
||||||
|
overridenTTYs = map (x: x.tty) specificThemes;
|
||||||
|
|
||||||
|
# Use the default theme for all the mingetty ttys and for the
|
||||||
|
# syslog tty, except those for which a specific theme is
|
||||||
|
# specified.
|
||||||
|
defaultTTYs =
|
||||||
|
pkgs.lib.filter (x: !(pkgs.lib.elem x overridenTTYs)) requiredTTYs;
|
||||||
|
|
||||||
|
in
|
||||||
|
(map (ttyNumber: {
|
||||||
|
tty = ttyNumber;
|
||||||
|
theme = config.services.ttyBackgrounds.defaultTheme;
|
||||||
|
}) defaultTTYs)
|
||||||
|
++ specificThemes;
|
||||||
|
|
||||||
|
|
||||||
themesUnpacked = stdenv.mkDerivation {
|
themesUnpacked = stdenv.mkDerivation {
|
||||||
name = "splash-themes";
|
name = "splash-themes";
|
||||||
@ -15,46 +104,71 @@ rec {
|
|||||||
themes = map (x: if x ? theme then (unpackTheme x.theme) else "default") backgrounds;
|
themes = map (x: if x ? theme then (unpackTheme x.theme) else "default") backgrounds;
|
||||||
};
|
};
|
||||||
|
|
||||||
extraEtc = [
|
unpackTheme = theme: import ../helpers/unpack-theme.nix {
|
||||||
{ source = themesUnpacked;
|
inherit stdenv theme;
|
||||||
target = "splash";
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
# FIXME see xfs
|
||||||
|
# assert splashutils != null;
|
||||||
|
|
||||||
|
mkIf (config.services.ttyBackgrounds.enable && kernelPackages.splashutils != null) {
|
||||||
|
require = [
|
||||||
|
options
|
||||||
];
|
];
|
||||||
|
|
||||||
job = ''
|
|
||||||
start on udev
|
|
||||||
|
|
||||||
start script
|
environment = {
|
||||||
|
etc = [
|
||||||
|
{ source = themesUnpacked;
|
||||||
|
target = "splash";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# Critical: tell the kernel where to find splash_helper. It calls
|
|
||||||
# this program every time we switch between consoles.
|
|
||||||
helperProcFile=${splashutils.helperProcFile}
|
|
||||||
if test -e /proc/sys/fbcondecor; then helperProcFile=/proc/sys/fbcondecor; fi
|
|
||||||
echo ${splashutils}/${splashutils.helperName} > $helperProcFile
|
|
||||||
|
|
||||||
# For each console...
|
services = {
|
||||||
for tty in ${toString (map (x: x.tty) backgrounds)}; do
|
extraJobs = [ rec {
|
||||||
# Make sure that the console exists.
|
name = "tty-backgrounds";
|
||||||
echo -n "" > /dev/tty$tty
|
|
||||||
|
|
||||||
# Set the theme as determined by tty-backgrounds-combine.sh
|
job = ''
|
||||||
# above.
|
start on udev
|
||||||
theme=$(readlink ${themesUnpacked}/$tty)
|
|
||||||
${splashutils}/${splashutils.controlName} --tty $tty -c setcfg -t $theme || true
|
|
||||||
${splashutils}/${splashutils.controlName} --tty $tty -c setpic -t $theme || true
|
|
||||||
${splashutils}/${splashutils.controlName} --tty $tty -c on || true
|
|
||||||
done
|
|
||||||
|
|
||||||
end script
|
start script
|
||||||
|
|
||||||
respawn sleep 10000 # !!! Hack
|
# Critical: tell the kernel where to find splash_helper. It calls
|
||||||
|
# this program every time we switch between consoles.
|
||||||
|
helperProcFile=${splashutils.helperProcFile}
|
||||||
|
if test -e /proc/sys/fbcondecor; then helperProcFile=/proc/sys/fbcondecor; fi
|
||||||
|
echo ${splashutils}/${splashutils.helperName} > $helperProcFile
|
||||||
|
|
||||||
stop script
|
# For each console...
|
||||||
# Disable the theme on each console.
|
for tty in ${toString (map (x: x.tty) backgrounds)}; do
|
||||||
for tty in ${toString (map (x: x.tty) backgrounds)}; do
|
# Make sure that the console exists.
|
||||||
${splashutils}/${splashutils.controlName} --tty $tty -c off || true
|
echo -n "" > /dev/tty$tty
|
||||||
done
|
|
||||||
end script
|
# Set the theme as determined by tty-backgrounds-combine.sh
|
||||||
'';
|
# above.
|
||||||
|
theme=$(readlink ${themesUnpacked}/$tty)
|
||||||
|
${splashutils}/${splashutils.controlName} --tty $tty -c setcfg -t $theme || true
|
||||||
|
${splashutils}/${splashutils.controlName} --tty $tty -c setpic -t $theme || true
|
||||||
|
${splashutils}/${splashutils.controlName} --tty $tty -c on || true
|
||||||
|
done
|
||||||
|
|
||||||
|
end script
|
||||||
|
|
||||||
|
respawn sleep 10000 # !!! Hack
|
||||||
|
|
||||||
|
stop script
|
||||||
|
# Disable the theme on each console.
|
||||||
|
for tty in ${toString (map (x: x.tty) backgrounds)}; do
|
||||||
|
${splashutils}/${splashutils.controlName} --tty $tty -c off || true
|
||||||
|
done
|
||||||
|
end script
|
||||||
|
'';
|
||||||
|
}];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user