<commit_before>{stdenv, splashutils, backgrounds}:

rec {
  name = "tty-backgrounds";

  unpackTheme = theme: import ../helpers/unpack-theme.nix {
    inherit stdenv theme;
  };

  themesUnpacked = stdenv.mkDerivation {
    name = "splash-themes";
    builder = ./tty-backgrounds-combine.sh;
    # !!! Should use XML here.
    ttys = map (x: x.tty) backgrounds;
    themes = map (x: if x ? theme then (unpackTheme x.theme) else "default") backgrounds;
  };

  job = "
start on hardware-scan

start script

    rm -f /etc/splash
    ln -s ${themesUnpacked} /etc/splash

    # Critical: tell the kernel where to find splash_helper.  It calls
    # this program every time we switch between consoles.
    echo ${splashutils}/bin/splash_helper > /proc/sys/kernel/fbsplash

    # For each console...
    for tty in ${toString (map (x: x.tty) backgrounds)}; do
        # Make sure that the console exists.
        echo -n '' > /dev/tty$tty 

	# Set the theme as determined by tty-backgrounds-combine.sh
        # above.
        theme=$(readlink ${themesUnpacked}/$tty)
        ${splashutils}/bin/splash_util --tty $tty -c setcfg -t $theme || true
        ${splashutils}/bin/splash_util --tty $tty -c setpic -t $theme || true
        ${splashutils}/bin/splash_util --tty $tty -c on || true
    done

end script

respawn sleep 10000 # !!! Hack

stop script
    # Disable the theme on each console.<commit_msg>* tty-backgrounds: declare /etc/splash properly.<commit_after>{stdenv, splashutils, backgrounds}:

rec {
  name = "tty-backgrounds";

  unpackTheme = theme: import ../helpers/unpack-theme.nix {
    inherit stdenv theme;
  };

  themesUnpacked = stdenv.mkDerivation {
    name = "splash-themes";
    builder = ./tty-backgrounds-combine.sh;
    # !!! Should use XML here.
    ttys = map (x: x.tty) backgrounds;
    themes = map (x: if x ? theme then (unpackTheme x.theme) else "default") backgrounds;
  };

  extraEtc = [
    { source = themesUnpacked;
      target = "splash";
    }
  ];

  job = "
start on hardware-scan

start script

    # Critical: tell the kernel where to find splash_helper.  It calls
    # this program every time we switch between consoles.
    echo ${splashutils}/bin/splash_helper > /proc/sys/kernel/fbsplash

    # For each console...
    for tty in ${toString (map (x: x.tty) backgrounds)}; do
        # Make sure that the console exists.
        echo -n '' > /dev/tty$tty 

	# Set the theme as determined by tty-backgrounds-combine.sh
        # above.
        theme=$(readlink ${themesUnpacked}/$tty)
        ${splashutils}/bin/splash_util --tty $tty -c setcfg -t $theme || true
        ${splashutils}/bin/splash_util --tty $tty -c setpic -t $theme || true
        ${splashutils}/bin/splash_util --tty $tty -c on || true
    done

end script

respawn sleep 10000 # !!! Hack

stop script
    # Disable the theme on each console.
{'fraction_non_alphanumeric': 0.12425621281064053, 'fraction_numerical': 0.0035001750087504373, 'mean_word_length': 2.6829896907216493, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3376530', 'n_tokens_mistral': 970, 'n_tokens_neox': 915, 'n_words': 285}