1 { config, lib, pkgs, ... }:
3 cfg = config.services.mame;
4 mame = "mame${lib.optionalString pkgs.stdenv.hostPlatform.is64bit "64"}";
9 enable = lib.mkOption {
10 type = lib.types.bool;
13 Whether to setup TUN/TAP Ethernet interface for MAME emulator.
19 User from which you run MAME binary.
22 hostAddr = lib.mkOption {
25 IP address of the host system. Usually an address of the main network
26 adapter or the adapter through which you get an internet connection.
28 example = "192.168.31.156";
30 emuAddr = lib.mkOption {
33 IP address of the guest system. The same you set inside guest OS under
34 MAME. Should be on the same subnet as {option}`services.mame.hostAddr`.
36 example = "192.168.31.155";
41 config = lib.mkIf cfg.enable {
42 environment.systemPackages = [ pkgs.mame ];
44 security.wrappers."${mame}" = {
47 capabilities = "cap_net_admin,cap_net_raw+eip";
48 source = "${pkgs.mame}/bin/${mame}";
51 systemd.services.mame = {
52 description = "MAME TUN/TAP Ethernet interface";
53 after = [ "network.target" ];
54 wantedBy = [ "multi-user.target" ];
55 path = [ pkgs.iproute2 ];
58 RemainAfterExit = true;
59 ExecStart = "${pkgs.mame}/bin/taputil.sh -c ${cfg.user} ${cfg.emuAddr} ${cfg.hostAddr} -";
60 ExecStop = "${pkgs.mame}/bin/taputil.sh -d ${cfg.user}";
65 meta.maintainers = [ ];