summary refs log tree commit diff
path: root/modules/services/misc/rogue.nix
blob: 8760ce1251025fab5b76a4fe3d4267ca83126c04 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Execute the game `rogue' on tty 9.  Mostly used by the NixOS
# installation CD.

{ config, pkgs, ... }:

with pkgs.lib;

let

  cfg = config.services.rogue;

in
  
{
  ###### interface

  options = {
  
    services.rogue.enable = mkOption {
      default = false;
      description = ''
        Whether to enable the Rogue game on one of the virtual
        consoles.
      '';
    };

    services.rogue.tty = mkOption {
      default = "tty9";
      description = ''
        Virtual console on which to run Rogue.
      '';
    };

  };

  
  ###### implementation

  config = mkIf cfg.enable {

    boot.extraTTYs = [ cfg.tty ];
  
    jobs.rogue =
      { description = "Rogue dungeon crawling game";

        startOn = "started udev";

        extraConfig = "chdir /root";

        exec = "${pkgs.rogue}/bin/rogue < /dev/${cfg.tty} > /dev/${cfg.tty} 2>&1";
      };

    services.ttyBackgrounds.specificThemes = singleton
      { tty = cfg.tty;
        theme = pkgs.themes "theme-gnu";
      };

  };
    
}