From 6f4ec604abab8c63d2646cfbcdb0297353631f25 Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Sat, 11 May 2024 10:25:05 +0200 Subject: [PATCH] start move steam to seperate module --- hosts/default/configuration.nix | 113 +++++++++++++++----------------- modules/games/default.nix | 11 ++-- modules/games/minecraft.nix | 11 ++++ modules/games/steam.nix | 18 +++++ 4 files changed, 88 insertions(+), 65 deletions(-) create mode 100644 modules/games/minecraft.nix create mode 100644 modules/games/steam.nix diff --git a/hosts/default/configuration.nix b/hosts/default/configuration.nix index 6f2e25e..f0da8a1 100644 --- a/hosts/default/configuration.nix +++ b/hosts/default/configuration.nix @@ -9,6 +9,7 @@ rec { [ # Include the results of the hardware scan. ./hardware-configuration.nix inputs.home-manager.nixosModules.default + ../../modules/games/steam.nix ]; # Bootloader. @@ -34,7 +35,6 @@ rec { driSupport = true; driSupport32Bit = true; }; - services.xserver.videoDrivers = [ "nvidia" ]; # Allow unfree packages nixpkgs.config = { @@ -93,24 +93,6 @@ rec { LC_TIME = "nl_NL.UTF-8"; }; - services.xserver = { - enable = true; - xkb = { - layout = "us"; - variant = "intl"; - }; - }; - - services.greetd = { - enable = true; - settings = rec { - initial_session = { - command = "${pkgs.hyprland}/bin/Hyprland"; - user = "noa"; - }; - default_session = initial_session; - }; - }; # Configure console keymap console.keyMap = "us-acentos"; @@ -168,11 +150,6 @@ rec { programs = { zsh.enable = true; - steam.enable = true; - steam.gamescopeSession.enable = true; - - gamemode.enable = true; - hyprland = { enable = true; package = inputs.hyprland.packages.${pkgs.system}.hyprland; @@ -185,41 +162,67 @@ rec { ]; }; + modules.games.steam.enable = true; + users.defaultUserShell = pkgs.zsh; security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - jack.enable = true; - }; - services.fail2ban = { - enable = true; - maxretry = 5; - bantime = "1s"; - bantime-increment = { + services = { + pipewire = { enable = true; - formula = "ban.Time * math.exp(float(ban.Count+1)*banFactor)/math.exp(1*banFactor)"; - maxtime = "1h"; - overalljails = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; }; - - jails = { - go-login.settings = { - enabled = true; - filter = "go-login"; - action = ''iptables-multiport[name=HTTP, port="http,https,2000"]''; - logpath = "/home/noa/Documents/programming/SODS/login.log"; - backend = "systemd"; - findtime = 600; - bantime = 600; - maxretry = 5; + fail2ban = { + enable = true; + maxretry = 5; + bantime = "1s"; + bantime-increment = { + enable = true; + formula = "ban.Time * math.exp(float(ban.Count+1)*banFactor)/math.exp(1*banFactor)"; + maxtime = "1h"; + overalljails = true; + }; + jails = { + go-login.settings = { + enabled = true; + filter = "go-login"; + action = ''iptables-multiport[name=HTTP, port="http,https,2000"]''; + logpath = "/home/noa/Documents/programming/SODS/login.log"; + backend = "systemd"; + findtime = 600; + bantime = 600; + maxretry = 5; + }; }; }; + greetd = { + enable = true; + settings = rec { + initial_session = { + command = "${pkgs.hyprland}/bin/Hyprland"; + user = "noa"; + }; + default_session = initial_session; + }; + }; + openssh = { + enable = true; + settings.PasswordAuthentication = false; + settings.KbdInteractiveAuthentication = false; + }; + xserver = { + enable = true; + xkb = { + layout = "us"; + variant = "intl"; + }; + videoDrivers = [ "nvidia" ]; + }; }; environment.etc = { @@ -242,16 +245,6 @@ rec { ''; security.polkit.enable = true; - # List services that you want to enable: - - # Enable the OpenSSH daemon. - services.openssh = { - enable = true; - - settings.PasswordAuthentication = false; - settings.KbdInteractiveAuthentication = false; - }; - # Open ports in the firewall. networking.firewall.allowedTCPPorts = [ 80 443 53317 ]; networking.firewall.allowedUDPPorts = [ 80 443 53317 ]; diff --git a/modules/games/default.nix b/modules/games/default.nix index 5a4c3a3..d137bb0 100644 --- a/modules/games/default.nix +++ b/modules/games/default.nix @@ -5,13 +5,14 @@ in { options.modules.games = { enable = lib.mkEnableOption "enable gaming services"; + minecraft.enable = lib.mkEnableOption "enable minecraft"; }; + imports = [ + ./minecraft.nix + ]; + config = lib.mkIf cfg.enable { - - home.packages = [ - pkgs.prismlauncher - ]; - + modules.games.minecraft.enable = true; }; } diff --git a/modules/games/minecraft.nix b/modules/games/minecraft.nix new file mode 100644 index 0000000..2cdd14b --- /dev/null +++ b/modules/games/minecraft.nix @@ -0,0 +1,11 @@ +{ lib, config, pkgs, ... }: +let + cfg = config.modules.games.minecraft; +in +{ + config = lib.mkIf cfg.enable { + home.packages = [ + pkgs.prismlauncher + ]; + }; +} diff --git a/modules/games/steam.nix b/modules/games/steam.nix new file mode 100644 index 0000000..bbef86f --- /dev/null +++ b/modules/games/steam.nix @@ -0,0 +1,18 @@ +{ lib, config, ... }: +{ + options.modules.games.steam = { + enable = lib.mkEnableOption "enable steam"; + }; + config = lib.mkIf config.modules.games.steam.enable { + programs = { + steam = { + enable = true; + remotePlay.openFirewall = true; + gamescopeSession.enable = true; + dedicatedServer.openFirewall = true; + }; + + gamemode.enable = true; + }; + }; +}