From 9cc11cbdbb7edb456f82c0bec3dd5e5edb141fc5 Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Fri, 21 Oct 2022 17:14:48 +0200 Subject: [PATCH] srb2k v1.3 -> v1.5 --- flake.lock | 50 +++++++------- hosts/dark-firepit/authorizedKeys.nix | 2 +- hosts/dark-firepit/default.nix | 10 +++ hosts/dark-firepit/yugoslavia-best.nix | 2 +- modules/services/gitea.nix | 1 + modules/services/srb2k.nix | 82 ++++++++++++++++++++++ packages/srb2k/default.nix | 29 -------- packages/srb2kart/default.nix | 96 ++++++++++++++++++++++++++ result | 2 +- 9 files changed, 217 insertions(+), 57 deletions(-) create mode 100644 modules/services/srb2k.nix delete mode 100644 packages/srb2k/default.nix create mode 100644 packages/srb2kart/default.nix diff --git a/flake.lock b/flake.lock index 20aeaec..fdd87b3 100755 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1652712410, - "narHash": "sha256-hMJ2TqLt0DleEnQFGUHK9sV2aAzJPU8pZeiZoqRozbE=", + "lastModified": 1665870395, + "narHash": "sha256-Tsbqb27LDNxOoPLh0gw2hIb6L/6Ow/6lIBvqcHzEKBI=", "owner": "ryantm", "repo": "agenix", - "rev": "7e5e58b98c3dcbf497543ff6f22591552ebfe65b", + "rev": "a630400067c6d03c9b3e0455347dc8559db14288", "type": "github" }, "original": { @@ -87,11 +87,11 @@ ] }, "locked": { - "lastModified": 1656169755, - "narHash": "sha256-Nlnm4jeQWEGjYrE6hxi/7HYHjBSZ/E0RtjCYifnNsWk=", + "lastModified": 1665996265, + "narHash": "sha256-/k9og6LDBQwT+f/tJ5ClcWiUl8kCX5m6ognhsAxOiCY=", "owner": "nix-community", "repo": "home-manager", - "rev": "4a3d01fb53f52ac83194081272795aa4612c2381", + "rev": "b81e128fc053ab3159d7b464d9b7dedc9d6a6891", "type": "github" }, "original": { @@ -107,11 +107,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1659775351, - "narHash": "sha256-W1vRnGF4+JCr8BSempyaB2rNFlkUAzSR7RjXiF+5GnQ=", + "lastModified": 1666029887, + "narHash": "sha256-QtyGcQ9DFUqXRe5x/BEV4QQQoSaoSfmcW8dHP7CkTgY=", "ref": "main", - "rev": "55476dce96057b62d8ff4ae666a5084c709e06d8", - "revCount": 19, + "rev": "72f30e2b8e007751731f8f1dd979f4f2e3ef8f8b", + "revCount": 27, "type": "git", "url": "file:///home/oatmealine/jillo" }, @@ -147,11 +147,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1661267391, - "narHash": "sha256-5u33JsRQCq6Fotjj3/+JbQNmDujLVX8i/82ruFsDbMc=", + "lastModified": 1666188576, + "narHash": "sha256-cBsCLCxT3V6wo3lJcRZSF4cngXm2VQNKzmr5EbndJrg=", "owner": "Infinidoge", "repo": "nix-minecraft", - "rev": "3442139e21642082000271849abb1209484e8909", + "rev": "75ac91689d19bb4944f4794082d7f13ad99ef40a", "type": "github" }, "original": { @@ -162,11 +162,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1660407119, - "narHash": "sha256-04lWO0pDbhAXFdL4v2VzzwgxrZ5IefKn+TmZPiPeKxg=", + "lastModified": 1665987993, + "narHash": "sha256-MvlaIYTRiqefG4dzI5p6vVCfl+9V8A1cPniUjcn6Ngc=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "12620020f76b1b5d2b0e6fbbda831ed4f5fe56e1", + "rev": "0e6593630071440eb89cd97a52921497482b22c6", "type": "github" }, "original": { @@ -193,11 +193,11 @@ }, "nixpkgs-master": { "locked": { - "lastModified": 1661278267, - "narHash": "sha256-eqJH9nHQrFsAGpG7YRfUipAT0mG8ZW0AusI5MeX716s=", + "lastModified": 1666203765, + "narHash": "sha256-r/wcNaof81uEkd9cx3ijSNMzg84NdT2FI/SI6o+jARk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1ded9c47d54c1fcd3a9e6a4ed4e2bb65984ca691", + "rev": "2df2b52806129828a1dafaa093027f10817e5b3b", "type": "github" }, "original": { @@ -209,11 +209,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1661239211, - "narHash": "sha256-pNJzBlSNpWEiFJZnLF2oETYq8cGWx1DJPW33aMtG6n8=", + "lastModified": 1666109165, + "narHash": "sha256-BMLyNVkr0oONuq3lKlFCRVuYqF75CO68Z8EoCh81Zdk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5e804cd8a27f835a402b22e086e36e797716ef8b", + "rev": "32096899af23d49010bd8cf6a91695888d9d9e73", "type": "github" }, "original": { @@ -256,11 +256,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1661187878, - "narHash": "sha256-/wCqoQB1BsaVi4nb8Iz0PreeBNMTim0p78NLtyWejFE=", + "lastModified": 1666164185, + "narHash": "sha256-5v+YB4ijeUfg5LCz9ck4gIpCPhIS+qn02OyPJO48bCE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "52527082ea267fe486f0648582d57c85486b2031", + "rev": "c5203abb1329f7ea084c04acda330ca75d5b9fb5", "type": "github" }, "original": { diff --git a/hosts/dark-firepit/authorizedKeys.nix b/hosts/dark-firepit/authorizedKeys.nix index 0c8e8c8..3ea2571 100644 --- a/hosts/dark-firepit/authorizedKeys.nix +++ b/hosts/dark-firepit/authorizedKeys.nix @@ -16,6 +16,6 @@ } { hostname = "mayflower@BMW-M550d-xDrive"; # car 5 - ssh = "AAAAB3NzaC1yc2EAAAADAQABAAABAQCVH1q8t7fnIlS8sUFnnfTqTK2d6wmaqUE2xJ/jNFCj3hNK4uR7aU7D85M4vMgXfTqacdrmdiNlWehOjlPf2cWxAqYFqIVcBaka0lf6iUzuEJmHtdXlSHvTK/G38pC2aE9SQkYqY5pEUrniKWNdjqmqK2bYVqXIwimI5eFLRipKYXZzzIf67vu4Zu3oaxAVn02XyWasO7660vab/gMVdn/uzj56pJ1iscuOc/IuoMPQE0TdMH1OMJ8oJMR844DdTx45+vxv1u5Jz9ECbJo91tCq7kIATfHHm739pI7ZYY7oDH0OzUKFeU5y4E8o/SaJWPvBkeXZXUxPwY5I1TBfnKAV"; + ssh = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCIeoFll8XBRwu6vbQHUj4LNbvRvLMTdqUP1su9hGxow8olGKIZf/nINkt+/B5w4UumLFnOOROIWVhSH/04oxGVCWdk29ibPo3yYJIAoQrqOXYWCrGpMDd0z2n/0CwyXRAqmQ4rubnUZtnlabYCLh0eWMu9ZRSsSrQ+MiaUHES/vv1MxlLWHoEGfhLzoq7SyIsK88Mirgu9lSeHd/+2JybkQ9kNEWTxnzUPKwOMT0zLGo7vNLmfPhJ1WilQoV4F8skDbbgFNRuLO13ZDn6W2jqZ+zjf3H9khzPivG+oaKfHLMDD/zCwHM3rm3JyJzX7GF9EV73AqbNkzzsf54vKhYRT"; } ] diff --git a/hosts/dark-firepit/default.nix b/hosts/dark-firepit/default.nix index 05a50fe..547fc89 100644 --- a/hosts/dark-firepit/default.nix +++ b/hosts/dark-firepit/default.nix @@ -27,6 +27,7 @@ in { users.groups.yugoslavia = {}; normalUsers = { + # aether??? is that... reference.../.??? aether https://www.curseforge.com/minecraft/mc-mods/aether mod Curseforge minecraft Forge Patreon Chat twitter code license Assets license All rights reserved categories Last Updated apr 17 2021 Game Version 1.12.2 aether aether = { conf = { packages = with pkgs; [ bat duf broot nftables tmux ]; @@ -134,6 +135,15 @@ in { domain = "matrix.aether.gay"; }; + srb2k = with lib; with builtins; let + addonDir = "/var/lib/srb2k/firepit/"; + fileNames = attrNames (readDir (/. + addonDir)); + addonFileNames = filter (n: hasSuffix ".lua" n || hasSuffix ".kart" n || hasSuffix ".pk3" n || hasSuffix ".wad" n) fileNames; + in { + enable = true; + addons = map (n: "${addonDir}${n}") addonFileNames; + }; + minecraft = { enable = true; servers = { diff --git a/hosts/dark-firepit/yugoslavia-best.nix b/hosts/dark-firepit/yugoslavia-best.nix index a2e6ca2..fdbc06e 100644 --- a/hosts/dark-firepit/yugoslavia-best.nix +++ b/hosts/dark-firepit/yugoslavia-best.nix @@ -38,7 +38,7 @@ in { locations."/srb2kaddons/" = { extraConfig = '' autoindex on; - alias /home/oatmealine/.srb2kart/firepit/; + alias /var/lib/srb2k/firepit/; sub_filter ''; sub_filter
 ' ';
diff --git a/modules/services/gitea.nix b/modules/services/gitea.nix
index ad83b4f..4fbe25c 100644
--- a/modules/services/gitea.nix
+++ b/modules/services/gitea.nix
@@ -50,6 +50,7 @@ in {
         # thanks nginx
         #locations."/".proxyPass = "http://127.0.0.1:${toString cfg.port};";
         locations."/".extraConfig = ''
+          client_max_body_size 600M;
           proxy_pass http://127.0.0.1:${toString cfg.port};
         '';
       };
diff --git a/modules/services/srb2k.nix b/modules/services/srb2k.nix
new file mode 100644
index 0000000..592c7f2
--- /dev/null
+++ b/modules/services/srb2k.nix
@@ -0,0 +1,82 @@
+{ lib, config, options, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.modules.services.srb2k;
+  flags = [
+    "-dedicated"
+    "+advertise 1"
+    "-port ${toString cfg.port}"
+    "-serverport ${toString cfg.port}"
+  ];
+in {
+  options.modules.services.srb2k = {
+    enable = mkOption {
+      type = types.bool;
+      default = false;
+    };
+
+    package = mkOption {
+      type = types.package;
+      default = pkgs._.srb2kart;
+    };
+
+    dataDir = mkOption {
+      type = types.str or types.path;
+      default = "/var/lib/srb2k";
+      description = "The directory where srb2k will store addons and state information";
+    };
+
+    port = mkOption {
+      type = types.port;
+      default = 5029;
+      description = "The default port for the srb2k server to run on";
+    };
+
+    addons = mkOption {
+      type = types.listOf (types.str or types.path);
+      default = [];
+      description = "Locations of srb2k addons and also fungus spore tasty in your body they grow happy you grow happy";
+    };
+  };
+
+  config = mkIf cfg.enable {
+    users.users.srb2k = {
+      home = cfg.dataDir;
+      createHome = true;
+      isSystemUser = true;
+      group = "srb2k";
+    };
+    users.groups.srb2k = {};
+
+    systemd.services.srb2k = {
+      description = "srb2k server =)";
+      wantedBy = [ "multi-user.target" ];
+      after = [ "network.target" ];
+
+      serviceConfig = {
+        User = "srb2k";
+        Restart = "always";
+        WorkingDirectory = cfg.dataDir;
+
+        ExecStart = #''
+#          ${getBin pkgs.tmux}/bin/tmux -S ${cfg.dataDir}/srb2k.sock new -d \
+        ''
+          ${cfg.package}/bin/srb2kart ${concatStringsSep " " flags} -file \
+          ${concatStringsSep " " (map (path: "\"${path}\"") cfg.addons)}
+        '';
+      };
+
+      postStart = ''
+        ${pkgs.coreutils}/bin/chmod 775 -R ${cfg.dataDir}
+        ${pkgs.coreutils}/bin/chmod 660 ${cfg.dataDir}/srb2k.sock
+        ${pkgs.coreutils}/bin/chgrp srb2k ${cfg.dataDir}/srb2k.sock
+      '';
+    };
+
+    networking.firewall = {
+      allowedTCPPorts = [ cfg.port ];
+      allowedUDPPorts = [ cfg.port ];
+    };
+  };
+}
diff --git a/packages/srb2k/default.nix b/packages/srb2k/default.nix
deleted file mode 100644
index 808471c..0000000
--- a/packages/srb2k/default.nix
+++ /dev/null
@@ -1,29 +0,0 @@
-{ lib
-, stdenv
-, SDL2
-, SDL2_mixer
-, libgme
-, fetchFromGitLab
-, cmake
-}:
-
-stdenv.mkDerivation rec {
-  pname = "srb2k";
-  version = "1.3";
-
-  src = fetchFromGitLab {
-    owner = "himie";
-    repo = "kart-public";
-    rev = "8cd205cd2807c6a2064935c8b873972c6570e715";
-    sha256 = "0";
-  };
-
-  buldInputs = [
-    SDL2
-    SDL2_mixer
-    libgme
-    cmake
-  ];
-
-  cmakeFlags = [ "-march=native" ];
-}
diff --git a/packages/srb2kart/default.nix b/packages/srb2kart/default.nix
new file mode 100644
index 0000000..92b0c4c
--- /dev/null
+++ b/packages/srb2kart/default.nix
@@ -0,0 +1,96 @@
+{ lib
+, stdenv
+, fetchurl
+, fetchFromGitLab
+, writeTextFile
+, substituteAll
+, cmake
+, curl
+, nasm
+, unzip
+, game-music-emu
+, libpng
+, SDL2
+, SDL2_mixer
+, zlib
+}:
+
+let
+
+releaseTag = "v1.5";
+
+assets = fetchurl {
+  url = "https://github.com/STJr/Kart-Public/releases/download/${releaseTag}/AssetsLinuxOnly.zip";
+  sha256 = "sha256-A4HkxnDGQICucsJyHXYc5GCRbMP0M4NjreohhFOQarA=";
+};
+
+in stdenv.mkDerivation rec {
+  pname = "srb2kart";
+  version = "1.5.0";
+
+  src = fetchFromGitLab {
+    owner = "KartKrew";
+    repo = "Kart-Public";
+    domain = "git.do.srb2.org";
+    rev = "a69b3b0260665b8b0acac950a808a68e5a40894c";
+    sha256 = "sha256-pWnCvBb+XkUjCVmlT3MgqPWICaERFO0POFAItIyA6Ns=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    nasm
+    unzip
+  ];
+
+  buildInputs = [
+    curl
+    game-music-emu
+    libpng
+    SDL2
+    SDL2_mixer
+    zlib
+  ];
+
+  cmakeFlags = [
+    #"-DSRB2_ASSET_DIRECTORY=/build/source/assets"
+    "-DGME_INCLUDE_DIR=${game-music-emu}/include"
+    "-DSDL2_MIXER_INCLUDE_DIR=${lib.getDev SDL2_mixer}/include/SDL2"
+    "-DSDL2_INCLUDE_DIR=${lib.getDev SDL2}/include/SDL2"
+  ];
+
+  patches = [
+    #./disablemd5checks.patch
+  ];
+
+/*
+  postPatch = ''
+    substituteInPlace src/sdl/i_system.c \
+        --replace '@wadlocation@' $out
+  '';
+*/
+
+  preConfigure = ''
+    mkdir -p assets/installer
+    pushd assets/installer
+    unzip ${assets}
+    popd
+    ls
+    ls assets
+    ls assets/installer
+  '';
+
+
+  postInstall = ''
+    mkdir -p $out/bin $out/share/games/SRB2Kart
+    mv $out/srb2kart* $out/bin/
+    mv $out/*.kart $out/share/games/SRB2Kart
+  '';
+
+  meta = with lib; {
+    description = "SRB2Kart is a classic styled kart racer";
+    homepage = "https://mb.srb2.org/threads/srb2kart.25868/";
+    platforms = platforms.linux;
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ viric ];
+  };
+}
diff --git a/result b/result
index 970486e..f326e4f 120000
--- a/result
+++ b/result
@@ -1 +1 @@
-/nix/store/js089ixiqw488kiakkbxr4kfy671f98v-nixos-system-dark-firepit-22.05.20220822.5252708
\ No newline at end of file
+/nix/store/gzfm8qnjflwp4yd8v5ikjf7pz86957z5-nixos-system-dark-firepit-22.05.20221019.c5203ab
\ No newline at end of file