feat(koi): uxplay server

This commit is contained in:
alina 🌸 2024-03-17 05:59:15 +03:00
parent 9ec641fb19
commit 1b165364de
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
6 changed files with 93 additions and 2 deletions

View file

@ -16,6 +16,7 @@
./services/coredns.nix ./services/coredns.nix
./services/nginx.nix ./services/nginx.nix
./containers/uxplay.nix
./containers/torrent.nix ./containers/torrent.nix
./containers/puffer.nix ./containers/puffer.nix
./containers/sharkey ./containers/sharkey

View file

@ -143,6 +143,10 @@ let
sftpgoConfig sftpgoConfig
]; ];
environment.systemPackages = with pkgs; [
uxplay
];
users.groups.puffer = { }; users.groups.puffer = { };
users.users.smb-guest = { users.users.smb-guest = {
isNormalUser = true; isNormalUser = true;
@ -157,7 +161,8 @@ let
"d /mnt/puffer/Backups 0755 smb-guest puffer - -" "d /mnt/puffer/Backups 0755 smb-guest puffer - -"
]; ];
networking.firewall.allowedTCPPorts = [ 22 ]; networking.firewall.allowedTCPPorts = [ 22 7000 7001 7002 ];
networking.firewall.allowedUDPPorts = [ 22 7000 7001 7002 ];
}; };
mounts = { mounts = {

View file

@ -0,0 +1,47 @@
{ abs, lib, pkgs, config, ... }@inputs:
let
containers = import (abs "lib/containers.nix") inputs;
uxplay = import (abs "services/uxplay.nix") inputs;
in
{
imports = [
(containers.mkNixosContainer {
name = "uxplay";
ip = "10.42.0.6";
private = false;
config = { ... }: {
imports = [
(uxplay {
params = [
"-p 7000"
"-vs 0"
"-async"
"-n koi -nh"
];
withAvahi = true;
})
];
networking.firewall.allowedTCPPorts = [ 7000 7001 7002 ];
networking.firewall.allowedUDPPorts = [ 7000 7001 7002 ];
services.avahi.openFirewall = true;
};
containerConfig.extraFlags = [
"--bind=/run/pipewire"
"--bind=/dev/snd"
"--bind=/dev/shm"
];
})
];
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
systemWide = true;
};
}

View file

@ -55,4 +55,5 @@ in
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
hardware.firmware = [ pkgs.alsa-firmware ];
} }

37
services/uxplay.nix Executable file
View file

@ -0,0 +1,37 @@
{ lib, pkgs, ... }:
{
# UXPlay parameters
params ? [ ]
# Whether to also set up avahi daemon
, withAvahi ? false
, # Name of the systemd service
serviceName ? "uxplay"
, # UXPlay package
package ? pkgs.uxplay
, serviceConfig ? { }
}:
let
paramsJoined = builtins.concatStringsSep " " params;
in
{
systemd.services.${serviceName} = {
description = "${serviceName} Daemon";
after = [ "network.target" ] ++ lib.optionals withAvahi [ "avahi-daemon.service" ];
wantedBy = [ "multi-user.target" ];
serviceConfig.PrivateTmp = true;
script = ''
sleep 5 # idk needed for some reason
exec ${package}/bin/uxplay ${paramsJoined}
'';
} // serviceConfig;
} // lib.optionalAttrs withAvahi {
services.avahi = {
enable = true;
nssmdns4 = true;
publish = {
enable = true;
userServices = true;
};
};
}

View file

@ -3,7 +3,7 @@
{ {
users.users.teidesu = { users.users.teidesu = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" "kvm" "docker" ]; extraGroups = [ "wheel" "kvm" "docker" "pipewire" ];
shell = pkgs.zsh; shell = pkgs.zsh;
openssh.authorizedKeys.keyFiles = [ openssh.authorizedKeys.keyFiles = [