summaryrefslogtreecommitdiffstats
path: root/lass/2configs/games.nix
blob: 50362cda4ce7de88d1d12bba5114eddeddc4e7c6 (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{ config, pkgs, ... }:

let
  mainUser = config.users.extraUsers.mainUser;
  vdoom = pkgs.writeDash "vdoom" ''
    ${pkgs.zandronum-bin}/bin/zandronum \
      -fov 120 \
      "$@"
  '';
  doom = pkgs.writeDash "doom" ''
    DOOM_DIR=''${DOOM_DIR:-~/doom/}
    ${vdoom} \
      -file $DOOM_DIR/lib/brutalv20.pk3 \
      "$@"
  '';
  doom1 = pkgs.writeDashBin "doom1" ''
    DOOM_DIR=''${DOOM_DIR:-~/doom/}
    ${doom} -iwad $DOOM_DIR/wads/stock/doom.wad "$@"
  '';
  doom2 = pkgs.writeDashBin "doom2" ''
    DOOM_DIR=''${DOOM_DIR:-~/doom/}
    ${doom} -iwad $DOOM_DIR/wads/stock/doom2.wad "$@"
  '';
  vdoom1 = pkgs.writeDashBin "vdoom1" ''
    DOOM_DIR=''${DOOM_DIR:-~/doom/}
    ${vdoom} -iwad $DOOM_DIR/wads/stock/doom.wad "$@"
  '';
  vdoom2 = pkgs.writeDashBin "vdoom2" ''
    DOOM_DIR=''${DOOM_DIR:-~/doom/}
    ${vdoom} -iwad $DOOM_DIR/wads/stock/doom2.wad "$@"
  '';

  doomservercfg = pkgs.writeText "doomserver.cfg" ''
    skill 7
    #survival true
    #sv_maxlives 4
    #sv_norespawn true
    #sv_weapondrop true
    no_jump true
    #sv_noweaponspawn true
    sv_sharekeys true
    sv_survivalcountdowntime 1
    sv_noteamselect true
    sv_updatemaster false
    #sv_coop_loseinventory true
    #cl_startasspectator false
    #lms_spectatorview false
  '';

  vdoomserver = pkgs.writeDashBin "vdoomserver" ''
    DOOM_DIR=''${DOOM_DIR:-~/doom/}

    ${pkgs.zandronum-bin}/bin/zandronum-server \
    +exec ${doomservercfg} \
    "$@"
  '';

in {
  environment.systemPackages = with pkgs; [
    (dwarf-fortress.override { theme = dwarf-fortress-packages.phoebus-theme; })
    doom1
    doom2
    vdoom1
    vdoom2
    vdoomserver
  ];

  users.extraUsers = {
    games = {
      name = "games";
      description = "user playing games";
      home = "/home/games";
      extraGroups = [ "audio" "video" "input" "loot" ];
      createHome = true;
      useDefaultShell = true;
      packages = with pkgs; [
        ftb
        minecraft
      ];
    };
  };

  hardware.pulseaudio.support32Bit = true;

  security.sudo.extraConfig = ''
    ${mainUser.name} ALL=(games) NOPASSWD: ALL
  '';

  krebs.iptables.tables.filter.INPUT.rules = [
    { predicate = "-p tcp --dport 10666"; target = "ACCEPT"; }
    { predicate = "-p udp --dport 10666"; target = "ACCEPT"; }
  ];
}