From 4c13ebb2251a43d954c65b12c62f602112d9d855 Mon Sep 17 00:00:00 2001 From: Kopatz <7265381+Kropatz@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:50:50 +0100 Subject: [PATCH] update tetrio myself --- flake.nix | 21 +++---- modules/graphical/shared.nix | 2 +- overlays.nix | 23 +++++++ pkgs/default.nix | 3 + pkgs/tetrio-desktop/package.nix | 94 +++++++++++++++++++++++++++++ pkgs/tetrio-desktop/tetrio-plus.nix | 26 ++++++++ 6 files changed, 156 insertions(+), 13 deletions(-) create mode 100644 overlays.nix create mode 100644 pkgs/default.nix create mode 100644 pkgs/tetrio-desktop/package.nix create mode 100644 pkgs/tetrio-desktop/tetrio-plus.nix diff --git a/flake.nix b/flake.nix index 8f103c9..daffd5d 100644 --- a/flake.nix +++ b/flake.nix @@ -31,21 +31,18 @@ nix-colors, }@inputs: let + inherit (self) outputs; system = "x86_64-linux"; - overlay-unstable = final: prev: { - unstable = import nixpkgs-unstable { - inherit system; - config.allowUnfree = true; - }; - }; in { + overlays = import ./overlays.nix {inherit inputs;}; + nixosConfigurations.server = nixpkgs.lib.nixosSystem { inherit system; modules = [ ### User specific ### ./users/anon ### System sepecific ### - ({ config, pkgs, ... }: { nixpkgs.overlays = [ overlay-unstable ]; }) + ({ config, outputs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages]; }) ./systems/server/configuration.nix ### Modules ### ./modules/cli-tools.nix @@ -83,7 +80,7 @@ ## Custom variables (e.g. ip, interface, etc) vars = import ./systems/userdata-default.nix // import ./systems/server/userdata.nix; pkgsVersion = nixpkgs; - inherit inputs ; + inherit inputs outputs; }; }; nixosConfigurations."kop-pc" = nixpkgs-unstable.lib.nixosSystem { @@ -91,7 +88,7 @@ specialArgs = { vars = import ./systems/userdata-default.nix // import ./systems/pc/userdata.nix; pkgsVersion = nixpkgs-unstable; - inherit inputs ; + inherit inputs outputs; }; modules = [ ### User specific ### @@ -123,7 +120,7 @@ ./modules/docker.nix ./modules/nftables.nix ./modules/noise-supression.nix - ({ config, pkgs, ... }: { nixpkgs.overlays = [ overlay-unstable ]; }) + ({ config, pkgs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages]; }) ./modules/wooting.nix ./modules/wireshark.nix ./modules/tmpfs.nix @@ -145,7 +142,7 @@ modules = [ ### User specific ### ./users/kopatz - ({ config, pkgs, ... }: { nixpkgs.overlays = [ overlay-unstable ]; }) + ({ config, outputs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages]; }) ./modules/graphical/hyprland.nix ./modules/graphical/emulators.nix ./modules/graphical/gamemode.nix @@ -187,7 +184,7 @@ ./users/anon ./modules/nix/settings.nix ./modules/cli-tools.nix - ({ config, pkgs, ... }: { nixpkgs.overlays = [ overlay-unstable ]; }) + ({ config, outputs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages]; }) ./systems/wsl/configuration.nix nixos-wsl.nixosModules.wsl home-manager.nixosModules.home-manager diff --git a/modules/graphical/shared.nix b/modules/graphical/shared.nix index 14f8124..7158621 100644 --- a/modules/graphical/shared.nix +++ b/modules/graphical/shared.nix @@ -4,7 +4,7 @@ let screenshot = pkgs.writeShellScriptBin "screenshot.sh" '' ${pkgs.scrot}/bin/scrot -fs - | ${pkgs.xclip}/bin/xclip -selection clipboard -t image/png -i ''; - tetrioPlus = pkgs.unstable.tetrio-desktop.overrideAttrs (old: { + tetrioPlus = pkgs.tetrio.overrideAttrs (old: { withTetrioPlus = true; }); in diff --git a/overlays.nix b/overlays.nix new file mode 100644 index 0000000..99f666c --- /dev/null +++ b/overlays.nix @@ -0,0 +1,23 @@ +# This file defines overlays +{inputs, ...}: { + # This one brings our custom packages from the 'pkgs' directory + additions = final: _prev: import ./pkgs {pkgs = final;}; + + # This one contains whatever you want to overlay + # You can change versions, add patches, set compilation flags, anything really. + # https://nixos.wiki/wiki/Overlays + modifications = final: prev: { + # example = prev.example.overrideAttrs (oldAttrs: rec { + # ... + # }); + }; + + # When applied, the unstable nixpkgs set (declared in the flake inputs) will + # be accessible through 'pkgs.unstable' + unstable-packages = final: _prev: { + unstable = import inputs.nixpkgs-unstable { + system = final.system; + config.allowUnfree = true; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..160cbc9 --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,3 @@ +{pkgs, ...}: { + tetrio = pkgs.callPackage ./tetrio-desktop/package.nix { }; +} diff --git a/pkgs/tetrio-desktop/package.nix b/pkgs/tetrio-desktop/package.nix new file mode 100644 index 0000000..50663b4 --- /dev/null +++ b/pkgs/tetrio-desktop/package.nix @@ -0,0 +1,94 @@ +{ stdenv +, lib +, fetchurl +, dpkg +, autoPatchelfHook +, wrapGAppsHook +, alsa-lib +, cups +, libGL +, libX11 +, libXScrnSaver +, libXtst +, mesa +, nss +, gtk3 +, libpulseaudio +, systemd +, callPackage +, tetrio-plus ? callPackage ./tetrio-plus.nix { } +, ... +}: + +let + libPath = lib.makeLibraryPath [ + libGL + libpulseaudio + systemd + ]; +in +stdenv.mkDerivation (finalAttrs: { + pname = "tetrio-desktop"; + version = "9.0.0"; + + src = fetchurl { + url = "https://tetr.io/about/desktop/builds/${lib.versions.major finalAttrs.version}/TETR.IO%20Setup.deb"; + hash = "sha256-UriLwMB8D+/T32H4rPbkJAy/F/FFhNpd++0AR1lwEfs="; + }; + + nativeBuildInputs = [ + dpkg + autoPatchelfHook + wrapGAppsHook + ]; + + dontWrapGApps = true; + + buildInputs = [ + alsa-lib + cups + libX11 + libXScrnSaver + libXtst + mesa + nss + gtk3 + ]; + + unpackCmd = "dpkg -x $curSrc src"; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + cp -r opt/ usr/share/ $out + ln -s $out/opt/TETR.IO/TETR.IO $out/bin/tetrio + + substituteInPlace $out/share/applications/TETR.IO.desktop \ + --replace-fail "Exec=/opt/TETR.IO/TETR.IO" "Exec=$out/bin/tetrio" + + runHook postInstall + ''; + + + + postFixup = '' + wrapProgram $out/opt/TETR.IO/TETR.IO \ + --prefix LD_LIBRARY_PATH : ${libPath}:$out/opt/TETR.IO \ + ''${gappsWrapperArgs[@]} + ''; + + meta = { + description = "TETR.IO desktop client"; + downloadPage = "https://tetr.io/about/desktop/"; + homepage = "https://tetr.io"; + license = lib.licenses.unfree; + longDescription = '' + TETR.IO is a modern yet familiar online stacker. + Play against friends and foes all over the world, or claim a spot on the leaderboards - the stacker future is yours! + ''; + mainProgram = "tetrio"; + maintainers = with lib.maintainers; [ wackbyte ]; + platforms = [ "x86_64-linux" ]; + }; +}) diff --git a/pkgs/tetrio-desktop/tetrio-plus.nix b/pkgs/tetrio-desktop/tetrio-plus.nix new file mode 100644 index 0000000..34e359e --- /dev/null +++ b/pkgs/tetrio-desktop/tetrio-plus.nix @@ -0,0 +1,26 @@ +{ lib, stdenv, fetchzip }: +stdenv.mkDerivation rec { + pname = "tetrio-plus"; + version = "0.25.3"; + + src = fetchzip { + url = "https://gitlab.com/UniQMG/tetrio-plus/-/jobs/6465395934/artifacts/raw/app.asar.zip"; + hash = "sha256-24AD63YEypK7XUW6QnqJt56cUExIMrA2WgDi8jS5IFE="; + }; + + installPhase = '' + runHook preInstall + + install app.asar $out + + runHook postInstall + ''; + + meta = with lib; { + description = "TETR.IO customization toolkit"; + homepage = "https://gitlab.com/UniQMG/tetrio-plus"; + license = licenses.mit; + maintainers = with maintainers; [ huantian ]; + platforms = [ "x86_64-linux" ]; + }; +}