diff --git a/flake.lock b/flake.lock index ae48cbe..7eb85c0 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,27 @@ { "nodes": { + "hjem": { + "inputs": { + "nix-darwin": "nix-darwin", + "nixpkgs": [ + "nixpkgs" + ], + "smfh": "smfh" + }, + "locked": { + "lastModified": 1767318528, + "narHash": "sha256-I2zxtEafZbFbqXe71rjqwVeTDv8SIVLaSzQd39SwfwM=", + "owner": "feel-co", + "repo": "hjem", + "rev": "8539013044624a257e8da370069107aea148e985", + "type": "github" + }, + "original": { + "owner": "feel-co", + "repo": "hjem", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -20,6 +42,27 @@ "type": "github" } }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "hjem", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1765065051, + "narHash": "sha256-b7W9WsvyMOkUScNxbzS45KEJp0iiqRPyJ1I3JBE+oEE=", + "owner": "nix-darwin", + "repo": "nix-darwin", + "rev": "7e22bf538aa3e0937effcb1cee73d5f1bcc26f79", + "type": "github" + }, + "original": { + "owner": "nix-darwin", + "repo": "nix-darwin", + "type": "github" + } + }, "nix-flatpak": { "locked": { "lastModified": 1767983141, @@ -54,10 +97,71 @@ }, "root": { "inputs": { + "hjem": "hjem", "home-manager": "home-manager", "nix-flatpak": "nix-flatpak", "nixpkgs": "nixpkgs" } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "hjem", + "smfh", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1763347184, + "narHash": "sha256-6QH8hpCYJxifvyHEYg+Da0BotUn03BwLIvYo3JAxuqQ=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "08895cce80433978d5bfd668efa41c5e24578cbd", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "smfh": { + "inputs": { + "nixpkgs": [ + "hjem", + "nixpkgs" + ], + "rust-overlay": "rust-overlay", + "systems": "systems" + }, + "locked": { + "lastModified": 1763430012, + "narHash": "sha256-06G7pXUdpMnUqR0JWWvV7sA8oNGOZU1cSLqQS1GMf7Y=", + "owner": "feel-co", + "repo": "smfh", + "rev": "eddda76e3dd4c6deaea5f819f174fc16dbe70f90", + "type": "github" + }, + "original": { + "owner": "feel-co", + "repo": "smfh", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 5d63828..ee9256f 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,8 @@ home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest"; + hjem.url = "github:feel-co/hjem"; + hjem.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = @@ -33,12 +35,13 @@ ++ commonModules; }; -# pc + # pc nixosConfigurations.sandalphon = lib.nixosSystem { specialArgs = { inherit inputs; }; modules = [ ./hosts/sandalphon/hardware-configuration.nix ./hosts/sandalphon/configuration.nix + ./hosts/sandalphon/games.nix ] ++ commonModules; }; diff --git a/hosts/sandalphon/configuration.nix b/hosts/sandalphon/configuration.nix index 581bb09..2ef3bdc 100644 --- a/hosts/sandalphon/configuration.nix +++ b/hosts/sandalphon/configuration.nix @@ -45,9 +45,6 @@ in }; environment.systemPackages = with pkgs; [ - prismlauncher # minecraft - waywall # mcsr - r2modman ]; } diff --git a/hosts/sandalphon/games.nix b/hosts/sandalphon/games.nix new file mode 100644 index 0000000..bbcc47c --- /dev/null +++ b/hosts/sandalphon/games.nix @@ -0,0 +1,25 @@ +{ pkgs, ... }: + +{ + imports = [ ./mcsr ]; + + # hardware = { + # xone.enable = true; + # xpadneo.enable = true; + # }; + + environment.systemPackages = with pkgs; [ + prismlauncher # minecraft + r2modman + # osu-lazer-bin + ]; + + programs = { + obs-studio = { + enable = true; + plugins = with pkgs.obs-studio-plugins; [ + obs-pipewire-audio-capture + ]; + }; + }; +} diff --git a/hosts/sandalphon/mcsr/default.nix b/hosts/sandalphon/mcsr/default.nix new file mode 100644 index 0000000..ad60868 --- /dev/null +++ b/hosts/sandalphon/mcsr/default.nix @@ -0,0 +1,46 @@ +# credit to uku: https://git.uku3lig.net/uku/flake/src/branch/main/programs/mcsr +{ + lib, + pkgs, + config, + hjem, + ... +}: + +let + ninjabrain-bot = pkgs.callPackage ./ninjabrain.nix { }; + waywork = pkgs.callPackage ./waywork.nix { }; + cfg = config.programs.waywall; +in +{ + options = { + programs.waywall = { + width = lib.mkOption { + type = lib.types.int; + default = 1920; + }; + + height = lib.mkOption { + type = lib.types.int; + default = 1080; + }; + }; + }; + + config = { + environment.systemPackages = [ pkgs.waywall ]; + hjem.users.dea.files.".config/waywall/init.lua".text = '' + package.path = package.path .. ";${waywork}/?.lua" + local ninb_path = "${lib.getExe ninjabrain-bot}" + local resolution = { w = ${toString cfg.width}, h = ${toString cfg.height} } + local images = { + eye_overlay = "${./eye-overlay.png}", + thin = "${./yukata.jpg}", + wide = "${./yukata.jpg}", + tall = "${./yukata.jpg}", + } + -- end globals + '' + + builtins.readFile ./waywall.lua; + }; +} diff --git a/hosts/sandalphon/mcsr/eye-overlay.png b/hosts/sandalphon/mcsr/eye-overlay.png new file mode 100644 index 0000000..43547b0 Binary files /dev/null and b/hosts/sandalphon/mcsr/eye-overlay.png differ diff --git a/hosts/sandalphon/mcsr/ninjabrain.nix b/hosts/sandalphon/mcsr/ninjabrain.nix new file mode 100644 index 0000000..cfb94f6 --- /dev/null +++ b/hosts/sandalphon/mcsr/ninjabrain.nix @@ -0,0 +1,51 @@ +{ + lib, + stdenvNoCC, + fetchurl, + libx11, + libxinerama, + libxkbcommon, + libxt, + makeWrapper, + temurin-bin-17, +}: +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "ninjabrain-bot"; + version = "1.5.1"; + + src = fetchurl { + url = "https://github.com/Ninjabrain1/Ninjabrain-Bot/releases/download/${finalAttrs.version}/Ninjabrain-Bot-${finalAttrs.version}.jar"; + hash = "sha256-Rxu9A2EiTr69fLBUImRv+RLC2LmosawIDyDPIaRcrdw="; + }; + + nativeBuildInputs = [ makeWrapper ]; + + dontUnpack = true; + + installPhase = '' + runHook preInstall + + install -Dm644 $src $out/share/ninjabrain-bot/ninjabrain-bot.jar + + makeWrapper ${lib.getExe temurin-bin-17} $out/bin/ninjabrain-bot \ + --add-flags "-Dawt.useSystemAAFontSettings=on -jar $out/share/ninjabrain-bot/ninjabrain-bot.jar" \ + --prefix LD_LIBRARY_PATH : ${ + lib.makeLibraryPath [ + libx11 + libxinerama + libxkbcommon + libxt + ] + } + + runHook postInstall + ''; + + meta = { + description = "Stronghold calculator for Minecraft speedrunning"; + homepage = "https://github.com/Ninjabrain1/Ninjabrain-Bot"; + license = lib.licenses.mit; + platforms = lib.platforms.linux; + mainProgram = "ninjabrain-bot"; + }; +}) diff --git a/hosts/sandalphon/mcsr/waywall.lua b/hosts/sandalphon/mcsr/waywall.lua new file mode 100644 index 0000000..a008826 --- /dev/null +++ b/hosts/sandalphon/mcsr/waywall.lua @@ -0,0 +1,152 @@ +local waywall = require("waywall") +local helpers = require("waywall.helpers") + +local Scene = require("waywork.scene") +local Modes = require("waywork.modes") +local Keys = require("waywork.keys") +local Processes = require("waywork.processes") + +local scene = Scene.SceneManager.new(waywall) +local ModeManager = Modes.ModeManager.new(waywall) + +-- resolution is a magic global +local thin_w = resolution.h * 0.28 +local tall_w = 384 +local tall_h = 16384 + +local e_src_scale = thin_w < 640 and 1 or 2 +local e_scale = 10 +local e_w = 49 * e_src_scale +local e_h = 9 * e_src_scale + +local eye_w = (resolution.w - tall_w) / 2 +local eye_h = (resolution.h * eye_w) / resolution.w +local eye_dst = { x = 0, y = (resolution.h - eye_h) / 2, w = eye_w, h = eye_h } +local mc_eye_w = 60 +local mc_eye_h = 580 +local mc_eye_x = (tall_w - mc_eye_w) / 2 +local mc_eye_y = (tall_h - mc_eye_h) / 2 + +-- https://arjuncgore.github.io/waywall-boat-eye-calc/ +-- https://github.com/Esensats/mcsr-calcsens +local normal_sens = 13.117018998967824 +local tall_sens = 0.88486625532087 + +for _, name in ipairs({ "wide", "thin", "tall" }) do + scene:register(name .. "_bg", { + kind = "image", + path = images[name], + options = { + dst = { x = 0, y = 0, w = resolution.w, h = resolution.h }, + depth = -1, + }, + groups = { name }, + }) +end + +local left_middle = (resolution.w - thin_w) / 4 +scene:register("e_counter", { + kind = "mirror", + options = { + src = { x = 1 * e_src_scale, y = 37 * e_src_scale, w = e_w, h = e_h }, + dst = { x = left_middle - (e_w * e_scale / 2), y = resolution.h / 10.8, w = e_w * e_scale, h = e_h * e_scale }, + depth = 0, + }, + groups = { "thin" }, +}) + +scene:register("eye_measure", { + kind = "mirror", + options = { + src = { x = mc_eye_x, y = mc_eye_y, w = mc_eye_w, h = mc_eye_h }, + dst = eye_dst, + depth = 0, + }, + groups = { "tall" }, +}) + +scene:register("eye_overlay", { + kind = "image", + path = images.eye_overlay, + options = { dst = eye_dst, depth = 1 }, + groups = { "tall" }, +}) + +function mode_guard() + return not waywall.get_key("F3") and waywall.state().screen == "inworld" and waywall.state().inworld == "unpaused" +end + +ModeManager:define("thin", { + width = thin_w, + height = resolution.h, + on_enter = function() + scene:enable_group("thin", true) + end, + on_exit = function() + scene:enable_group("thin", false) + end, + toggle_guard = mode_guard, +}) + +ModeManager:define("wide", { + width = resolution.w, + height = resolution.h / 3.6, + on_enter = function() + scene:enable_group("wide", true) + end, + on_exit = function() + scene:enable_group("wide", false) + end, + toggle_guard = mode_guard, +}) + +ModeManager:define("tall", { + width = tall_w, + height = tall_h, + on_enter = function() + scene:enable_group("tall", true) + waywall.set_sensitivity(tall_sens) + end, + on_exit = function() + scene:enable_group("tall", false) + waywall.set_sensitivity(0) + end, + toggle_guard = mode_guard, +}) + +local ensure_ninjabrain = Processes.ensure_application(waywall, ninb_path)("ninjabrain.*\\.jar") +waywall.listen("load", ensure_ninjabrain) + +local config = { + input = { + layout = "fr", + repeat_rate = 40, + repeat_delay = 300, + + sensitivity = normal_sens, + confine_pointer = false, + }, + theme = { + background = "#303030ff", + -- https://github.com/Smithay/smithay/issues/1894 + ninb_anchor = "top", + }, + actions = Keys.actions({ + ["Ctrl-Super-F"] = waywall.toggle_fullscreen, + ["*-N"] = function() + return ModeManager:toggle("thin") + end, + ["*-P"] = function() + return ModeManager:toggle("tall") + end, + ["*-G"] = function() + return ModeManager:toggle("wide") + end, + ["Ctrl-Shift-M"] = function() + ensure_ninjabrain() + helpers.toggle_floating() + end, + }), +} + +return config diff --git a/hosts/sandalphon/mcsr/waywork.nix b/hosts/sandalphon/mcsr/waywork.nix new file mode 100644 index 0000000..6daa62b --- /dev/null +++ b/hosts/sandalphon/mcsr/waywork.nix @@ -0,0 +1,24 @@ +{ stdenvNoCC, fetchFromGitHub }: +stdenvNoCC.mkDerivation { + pname = "waywork"; + version = "0-unstable-2025-11-29"; + + src = fetchFromGitHub { + owner = "Esensats"; + repo = "waywork"; + rev = "60ab89dfe32d894845a759a08cebd3d710262bcb"; + hash = "sha256-XF+FgnLRnn0MydVN3Qthg/CwC8p5+8jo0QhlpPpaWMc="; + }; + + dontBuild = true; + dontCheck = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out/waywork + cp *.lua $out/waywork + + runHook postInstall + ''; +} diff --git a/hosts/sandalphon/mcsr/yukata.jpg b/hosts/sandalphon/mcsr/yukata.jpg new file mode 100755 index 0000000..a8f7aab Binary files /dev/null and b/hosts/sandalphon/mcsr/yukata.jpg differ