about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/misc/rogue.nix
blob: aae02e384c97f8e8dfa4df7b4b3f7317af42d51c (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
61
62
# Execute the game `rogue' on tty 9.  Mostly used by the NixOS
# installation CD.

{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.services.rogue;

in

{
  ###### interface

  options = {

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

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

  };


  ###### implementation

  config = mkIf cfg.enable {

    boot.extraTTYs = [ cfg.tty ];

    systemd.services.rogue =
      { description = "Rogue dungeon crawling game";
        wantedBy = [ "multi-user.target" ];
        serviceConfig =
          { ExecStart = "${pkgs.rogue}/bin/rogue";
            StandardInput = "tty";
            StandardOutput = "tty";
            TTYPath = "/dev/${cfg.tty}";
            TTYReset = true;
            TTYVTDisallocate = true;
            WorkingDirectory = "/tmp";
            Restart = "always";
          };
      };

  };

}