From 0e6a882c6e5ba38c16e69a6564d23dcc7fed022a Mon Sep 17 00:00:00 2001 From: Kat Inskip Date: Sun, 12 Oct 2025 00:11:49 -0700 Subject: [PATCH] feat: mewtris now external --- flake.lock | 25 ++++ flake.nix | 7 + modules/nixos/mewtris.nix | 244 --------------------------------- nixos/profiles/gaming/wine.nix | 16 +-- tree.nix | 1 + 5 files changed, 36 insertions(+), 257 deletions(-) delete mode 100644 modules/nixos/mewtris.nix diff --git a/flake.lock b/flake.lock index bc05de72..1340c1f9 100644 --- a/flake.lock +++ b/flake.lock @@ -773,6 +773,30 @@ "type": "github" } }, + "mewtris": { + "inputs": { + "flake-compat": [ + "flake-compat" + ], + "nix-std": [ + "nix-std" + ] + }, + "locked": { + "lastModified": 1760252779, + "narHash": "sha256-6CZQ43gEb+TVsgdhUEeFyZGwpfHAgMlMKEsczz6+yp4=", + "owner": "kittywitch", + "repo": "mewtris", + "rev": "d63e69689cc65dfc26ef4e65359023001b5cfe89", + "type": "github" + }, + "original": { + "owner": "kittywitch", + "ref": "main", + "repo": "mewtris", + "type": "github" + } + }, "microvm": { "inputs": { "flake-utils": [ @@ -1382,6 +1406,7 @@ "infrastructure": "infrastructure", "konawall-py": "konawall-py", "lanzaboote": "lanzaboote", + "mewtris": "mewtris", "microvm": "microvm", "minecraft": "minecraft", "naersk": "naersk", diff --git a/flake.nix b/flake.nix index db766f13..c85605ee 100644 --- a/flake.nix +++ b/flake.nix @@ -304,6 +304,13 @@ flake-compat.follows = "flake-compat"; }; }; + mewtris = { + url = "github:kittywitch/mewtris/main"; + inputs = { + nix-std.follows = "nix-std"; + flake-compat.follows = "flake-compat"; + }; + }; # a bunch of modules (also arcnmx is good) arcexprs = { #url = "github:kittywitch/arcexprs/master"; diff --git a/modules/nixos/mewtris.nix b/modules/nixos/mewtris.nix deleted file mode 100644 index b9f96d96..00000000 --- a/modules/nixos/mewtris.nix +++ /dev/null @@ -1,244 +0,0 @@ -{ - config, - pkgs, - lib, - std, - ... -}: let - inherit (lib.meta) getExe'; -in { - options.mewtris = let - inherit (lib.types) path attrsOf submodule str nullOr enum either package lines listOf; - inherit (lib.options) mkEnableOption mkOption; - in { - enable = mkEnableOption "Enable mewtris"; - createDesktopItems = mkEnableOption "Create XDG desktop items for starting, stopping and killing all the installed mewtris games, for use with dmenu or wofi for example"; - umuLauncher = mkOption { - description = "umu-launcher package"; - type = package; - default = pkgs.umu-launcher; - }; - gameStorage = mkOption { - description = "Where is the base directory for your game runner storage?"; - type = nullOr path; - default = null; - }; - runnerEnvironments = mkOption { - description = "Sets of environments to compose for your games"; - type = attrsOf (attrsOf str); - default = {}; - }; - runnerVariants = mkOption { - description = "Contains references to proton version bin/ folders"; - type = attrsOf (either path package); - default = {}; - }; - winTimezoneVariant = mkOption { - description = '' - Please refer to https://www.ibm.com/docs/en/idr/11.4.0?topic=zos-time-zone-codes-tz-environment-variable - For Proton, this allows you to fix weird timezone issues. - ''; - type = nullOr str; - default = null; - }; - globalPrerun = mkOption { - description = "Commands to run before every runner"; - default = '' - export WINE_CPU_TOPOLOGY=$(${getExe' pkgs.coreutils "nproc"} --all) - ''; - type = lines; - }; - games = let - nixosConfig = config; - gameSubmodule = { - name, - config, - ... - }: let - cfg = nixosConfig.mewtris; - in { - options = { - name = mkOption { - description = "Systemd service name for the game, a shorthand"; - type = str; - default = name; - }; - long_name = mkOption { - description = "Longhand name of the game"; - type = nullOr str; - }; - prefixFolder = mkOption { - description = "Where is the game's wine prefix?"; - type = either path str; - }; - gameFolder = mkOption { - description = "Where is the game's folder?"; - type = nullOr (either path str); - default = null; - }; - gameExecutable = mkOption { - description = "Where is the EXE to run?"; - type = either path str; - }; - gameArguments = mkOption { - description = "What arguments do we run the game with?"; - type = listOf str; - default = []; - }; - prefixArch = mkOption { - description = "Wine prefix architecture"; - type = enum [ - "win64" - "win32" - ]; - default = "win64"; - }; - runner = mkOption { - description = "What runner system to use?"; - type = enum [ - "proton" - "wine" - ]; - default = "proton"; - }; - prerun = mkOption { - description = "Commands to run before the game"; - default = ""; - type = lines; - }; - environments = mkOption { - description = "What environments to compose into the runner?"; - type = listOf str; - default = []; - }; - environment = mkOption { - description = "Any game specific environment variables?"; - type = attrsOf str; - default = {}; - }; - variant = mkOption { - description = "What variant of the runner?"; - type = nullOr str; - }; - startLine = mkOption { - description = "What do we run to start this game as a systemd service?"; - type = package; - internal = true; - }; - }; - config = let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.strings) escapeShellArgs optionalString; - inherit (lib.attrsets) optionalAttrs; - in - mkMerge [ - { - environment = { - WINEPREFIX = config.prefixFolder; - WINEARCH = config.prefixArch; - }; - } - (mkIf (config.runner == "wine") { - startLine = pkgs.writeShellScript "${config.name}" '' - export PATH="$PATH:${lib.makeBinPath (with pkgs; [ - coreutils - umu-launcher - mangohud - vkbasalt - wine-tkg - ])}" - ${cfg.globalPrerun} - ${config.prerun} - ${optionalString (config.gameFolder != null) '' - "cd ${config.gameFolder}" - ''} - "${getExe' cfg.runnerVariants.${config.variant} "wine"}" "${config.gameExecutable}" ${escapeShellArgs config.gameArguments} - ''; - }) - (mkIf (config.runner == "proton") { - environment = - (optionalAttrs (cfg.winTimezoneVariant != null) { - TZ = cfg.winTimezoneVariant; - }) - // { - PROTONPATH = cfg.runnerVariants.${config.variant}; - }; - startLine = let - protonLauncher = getExe' cfg.umuLauncher "umu-run"; - in - pkgs.writeShellScript "${config.name}" '' - export PATH="$PATH:${lib.makeBinPath (with pkgs; [ - coreutils - umu-launcher - mangohud - vkbasalt - wine-tkg - ])}" - ${cfg.globalPrerun} - ${config.prerun} - cd "${config.gameFolder}" - "${protonLauncher}" "${config.gameExecutable}" ${escapeShellArgs config.gameArguments} - ''; - }) - ]; - }; - in - mkOption { - type = attrsOf (submodule gameSubmodule); - default = {}; - }; - }; - config = let - cfg = config.mewtris; - inherit (lib.lists) singleton concatMap concatLists; - inherit (lib.strings) replaceStrings; - inherit (lib.attrsets) mapAttrs nameValuePair mapAttrs' attrNames attrValues mapAttrsToList; - inherit (lib.modules) mkIf; - inherit (std.set) merge; - in - mkIf cfg.enable { - environment.systemPackages = mkIf cfg.createDesktopItems (concatLists (mapAttrsToList (_k: v: let - start = pkgs.makeDesktopItem { - inherit (v) name; - desktopName = v.long_name; - exec = "${getExe' pkgs.systemd "systemctl"} --user start ${v.name}"; - }; - stop = pkgs.makeDesktopItem { - name = "${v.name}-stop"; - desktopName = "Stop ${v.long_name}"; - exec = "${getExe' pkgs.systemd "systemctl"} --user stop ${v.name}"; - }; - kill = pkgs.makeDesktopItem { - name = "${v.name}-kill"; - desktopName = "Kill ${v.long_name}"; - exec = "${getExe' pkgs.systemd "systemctl"} --user kill --signal=SIGKILL ${v.name}"; - }; - in [ - start - stop - kill - ]) - config.mewtris.games)); - systemd.user.services = mapAttrs' (_k: v: - nameValuePair v.name { - description = v.long_name; - serviceConfig = { - ExecStart = v.startLine; - Type = "simple"; - }; - environment = let - composedEnvironments = concatMap (e: singleton cfg.runnerEnvironments.${e}) v.environments; - combinedEnvironments = merge (composedEnvironments ++ (singleton v.environment)); - replacements = { - ${builtins.placeholder "prefix"} = v.prefixFolder; - ${builtins.placeholder "game"} = v.gameFolder; - ${builtins.placeholder "exe"} = v.gameExecutable; - }; - replacer = replaceStrings (attrNames replacements) (attrValues replacements); - replacePlaceholders = _k: replacer; - in - mapAttrs replacePlaceholders combinedEnvironments; - }) - config.mewtris.games; - }; -} diff --git a/nixos/profiles/gaming/wine.nix b/nixos/profiles/gaming/wine.nix index 62d4af41..19fe1130 100644 --- a/nixos/profiles/gaming/wine.nix +++ b/nixos/profiles/gaming/wine.nix @@ -126,11 +126,11 @@ in { // rec { inherit long_name; prefixFolder = gameStorage + "/VNs"; - gameFolder = prefixFolder; - gameExecutable = "./drive_c/cmd.exe"; + gameFolder = prefixFolder + "/drive_c"; + gameExecutable = "C:\\cmd.exe"; gameArguments = [ "/k" - "C:/script.bat" + "script.bat" ]; environment = { VN_DIR = vnDir; @@ -259,16 +259,6 @@ in { mangohud vkbasalt ]; - #systemd.user.services = - # mapAttrs (k: v: { - # description = v; - # serviceConfig = { - # ExecStart = "${getExe pkgs.katwine} ${k}"; - # Type = "simple"; - # }; - # inherit environment; - # }) - # games; home-manager.users.kat.home.file = { "Games/battlenet/drive_c/script.bat".source = ./bnet_script.bat; diff --git a/tree.nix b/tree.nix index 04fea6e3..0e2179ed 100644 --- a/tree.nix +++ b/tree.nix @@ -92,6 +92,7 @@ nixos-cli.nixosModules.nixos-cli stylix.nixosModules.stylix microvm.nixosModules.host + mewtris.nixosModules.mewtris ]; }; };