From f6cbd13f0d0c756f9ee4d49ec97cf14b982ec2f5 Mon Sep 17 00:00:00 2001 From: mib Date: Tue, 5 Nov 2024 19:35:51 +0100 Subject: [PATCH 1/4] etterna: init at 8deab33 pegged to same commit as the released beta clients. should rewrite so `overrideAttrs` works better --- pkgs/by-name/et/etterna/package.nix | 91 +++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 pkgs/by-name/et/etterna/package.nix diff --git a/pkgs/by-name/et/etterna/package.nix b/pkgs/by-name/et/etterna/package.nix new file mode 100644 index 0000000000000..549376032c289 --- /dev/null +++ b/pkgs/by-name/et/etterna/package.nix @@ -0,0 +1,91 @@ +{ lib +, stdenv +, fetchFromGitHub +, writeShellScript + + # dependencies +, alsa-lib +, clang +, cmake +, curl +, libGLU +, libjack2 +, libogg +, mesa +, openssl +, xorg + + # enable crash reporting. makes insecure due to dependency on python2 + # @TODO: fix crashpad; needs depot_tools +, enableCrashpad ? false +, python2 +}: +let + version = "8deab331e6c0e9b34eeeda363863193b26c221a4"; + + artifacts = + stdenv.mkDerivation (finalAttrs: { + pname = "etterna-artifacts"; + inherit version; + + src = fetchFromGitHub { + owner = "etternagame"; + repo = "etterna"; + rev = finalAttrs.version; + hash = "sha256-LdJDTO8c7kS8G52b0MRO4oFhZZlcsexwJl1deVz9vf0="; + }; + + nativeBuildInputs = [ + alsa-lib + clang + cmake + curl + libGLU + libjack2 + libogg + mesa + openssl + xorg.libX11 + xorg.libXext + xorg.libXrandr + ] + # crashpad relies on python2 and depot_tools + ++ lib.optionals enableCrashpad [ python2 ]; + + cmakeFlags = lib.optionals (!enableCrashpad) [ "-D WITH_CRASHPAD=OFF" ]; + }); + + wrapper = writeShellScript "etterna-wrapper" '' + #!/usr/bin/env sh + + export ETTERNA_ROOT_DIR="$HOME/.local/share/etterna" + export ETTERNA_ADDITIONAL_ROOT_DIRS="${artifacts}/Etterna" + + exec ${artifacts}/Etterna/Etterna "$@" + ''; +in +stdenv.mkDerivation (finalAttrs: { + pname = "etterna"; + inherit version; + + dontUnpack = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{bin,share} + + # link artifacts + ln -s ${artifacts}/Etterna $out/share/etterna + ln -s ${wrapper} $out/bin/etterna + + runHook postInstall + ''; + + meta = with lib; { + license = with licenses; [ mit ]; + maintainers = with maintainers; [ mib ]; + mainProgram = "etterna"; + }; + +}) From fcd426528b3a602643fc5bae1b8ff9af6fce5b3e Mon Sep 17 00:00:00 2001 From: mib Date: Wed, 6 Nov 2024 07:25:30 +0100 Subject: [PATCH 2/4] etterna: refactor to use one derivation the wrapper is really weird though and i don't like it. --- pkgs/by-name/et/etterna/package.nix | 105 +++++++++++++++------------- 1 file changed, 55 insertions(+), 50 deletions(-) diff --git a/pkgs/by-name/et/etterna/package.nix b/pkgs/by-name/et/etterna/package.nix index 549376032c289..b985e21619a7f 100644 --- a/pkgs/by-name/et/etterna/package.nix +++ b/pkgs/by-name/et/etterna/package.nix @@ -20,72 +20,77 @@ , enableCrashpad ? false , python2 }: -let - version = "8deab331e6c0e9b34eeeda363863193b26c221a4"; - artifacts = - stdenv.mkDerivation (finalAttrs: { - pname = "etterna-artifacts"; - inherit version; - - src = fetchFromGitHub { - owner = "etternagame"; - repo = "etterna"; - rev = finalAttrs.version; - hash = "sha256-LdJDTO8c7kS8G52b0MRO4oFhZZlcsexwJl1deVz9vf0="; - }; - - nativeBuildInputs = [ - alsa-lib - clang - cmake - curl - libGLU - libjack2 - libogg - mesa - openssl - xorg.libX11 - xorg.libXext - xorg.libXrandr - ] - # crashpad relies on python2 and depot_tools - ++ lib.optionals enableCrashpad [ python2 ]; - - cmakeFlags = lib.optionals (!enableCrashpad) [ "-D WITH_CRASHPAD=OFF" ]; - }); - - wrapper = writeShellScript "etterna-wrapper" '' - #!/usr/bin/env sh - - export ETTERNA_ROOT_DIR="$HOME/.local/share/etterna" - export ETTERNA_ADDITIONAL_ROOT_DIRS="${artifacts}/Etterna" - - exec ${artifacts}/Etterna/Etterna "$@" - ''; -in stdenv.mkDerivation (finalAttrs: { pname = "etterna"; - inherit version; + version = "8deab331e6c0e9b34eeeda363863193b26c221a4"; - dontUnpack = true; + src = fetchFromGitHub { + owner = "etternagame"; + repo = "etterna"; + rev = finalAttrs.version; + hash = "sha256-LdJDTO8c7kS8G52b0MRO4oFhZZlcsexwJl1deVz9vf0="; + }; + + nativeBuildInputs = [ + alsa-lib + clang + cmake + curl + libGLU + libjack2 + libogg + mesa + openssl + xorg.libX11 + xorg.libXext + xorg.libXrandr + ] + # crashpad relies on python2 and depot_tools + ++ lib.optionals enableCrashpad [ python2 ]; installPhase = '' runHook preInstall - mkdir -p $out/{bin,share} + mkdir -p $out/{bin,share/etterna} + + # copy select necessary game files into virtual fs + for dir in \ + Announcers Assets BGAnimations \ + BackgroundEffects BackgroundTransitions \ + Data GameTools NoteSkins Scripts \ + Songs Themes + do + cp -r "/build/source/$dir" "$out/share/etterna/$dir" + done + + # copy binary + cp /build/source/Etterna $out/bin/etterna-unwrapped - # link artifacts - ln -s ${artifacts}/Etterna $out/share/etterna - ln -s ${wrapper} $out/bin/etterna + # wacky insertion of wrapper directly into phase, so that $out is set + cat > $out/bin/etterna << EOF + #!${stdenv.shell} + + export ETTERNA_ROOT_DIR="\$HOME/.local/share/etterna" + export ETTERNA_ADDITIONAL_ROOT_DIRS="$out/share/etterna" + + echo "HOME: \$HOME" + echo "PWD: \$(pwd)" + echo "ETTERNA_ADDITIONAL_ROOT_DIRS: \$ETTERNA_ADDITIONAL_ROOT_DIRS" + + exec $out/bin/etterna-unwrapped "\$@" + EOF + + chmod +x $out/bin/etterna runHook postInstall ''; + cmakeFlags = lib.optionals (!enableCrashpad) [ "-D WITH_CRASHPAD=OFF" ]; + meta = with lib; { license = with licenses; [ mit ]; maintainers = with maintainers; [ mib ]; mainProgram = "etterna"; }; - }) From 1b86cdc2cde9f7b416604bca8a5dd23bccdebabd Mon Sep 17 00:00:00 2001 From: mib Date: Wed, 6 Nov 2024 07:51:28 +0100 Subject: [PATCH 3/4] etterna: format as nixfmt rfc style --- pkgs/by-name/et/etterna/package.nix | 66 +++++++++++++++-------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/pkgs/by-name/et/etterna/package.nix b/pkgs/by-name/et/etterna/package.nix index b985e21619a7f..46b22407f39fe 100644 --- a/pkgs/by-name/et/etterna/package.nix +++ b/pkgs/by-name/et/etterna/package.nix @@ -1,24 +1,25 @@ -{ lib -, stdenv -, fetchFromGitHub -, writeShellScript +{ + lib, + stdenv, + fetchFromGitHub, + writeShellScript, # dependencies -, alsa-lib -, clang -, cmake -, curl -, libGLU -, libjack2 -, libogg -, mesa -, openssl -, xorg + alsa-lib, + clang, + cmake, + curl, + libGLU, + libjack2, + libogg, + mesa, + openssl, + xorg, # enable crash reporting. makes insecure due to dependency on python2 # @TODO: fix crashpad; needs depot_tools -, enableCrashpad ? false -, python2 + enableCrashpad ? false, + python2, }: stdenv.mkDerivation (finalAttrs: { @@ -32,22 +33,23 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-LdJDTO8c7kS8G52b0MRO4oFhZZlcsexwJl1deVz9vf0="; }; - nativeBuildInputs = [ - alsa-lib - clang - cmake - curl - libGLU - libjack2 - libogg - mesa - openssl - xorg.libX11 - xorg.libXext - xorg.libXrandr - ] - # crashpad relies on python2 and depot_tools - ++ lib.optionals enableCrashpad [ python2 ]; + nativeBuildInputs = + [ + alsa-lib + clang + cmake + curl + libGLU + libjack2 + libogg + mesa + openssl + xorg.libX11 + xorg.libXext + xorg.libXrandr + ] + # crashpad relies on python2 and depot_tools + ++ lib.optionals enableCrashpad [ python2 ]; installPhase = '' runHook preInstall From 3589cf4102c1936f8e5adebdc84db844aa58d613 Mon Sep 17 00:00:00 2001 From: mib Date: Wed, 6 Nov 2024 21:50:34 +0100 Subject: [PATCH 4/4] etterna: fix wrapper exec issue due to whitespace preceding shebang --- pkgs/by-name/et/etterna/package.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/et/etterna/package.nix b/pkgs/by-name/et/etterna/package.nix index 46b22407f39fe..0d20628bc97b3 100644 --- a/pkgs/by-name/et/etterna/package.nix +++ b/pkgs/by-name/et/etterna/package.nix @@ -71,16 +71,16 @@ stdenv.mkDerivation (finalAttrs: { # wacky insertion of wrapper directly into phase, so that $out is set cat > $out/bin/etterna << EOF - #!${stdenv.shell} + #!${stdenv.shell} - export ETTERNA_ROOT_DIR="\$HOME/.local/share/etterna" - export ETTERNA_ADDITIONAL_ROOT_DIRS="$out/share/etterna" + export ETTERNA_ROOT_DIR="\$HOME/.local/share/etterna" + export ETTERNA_ADDITIONAL_ROOT_DIRS="$out/share/etterna" - echo "HOME: \$HOME" - echo "PWD: \$(pwd)" - echo "ETTERNA_ADDITIONAL_ROOT_DIRS: \$ETTERNA_ADDITIONAL_ROOT_DIRS" + echo "HOME: \$HOME" + echo "PWD: \$(pwd)" + echo "ETTERNA_ADDITIONAL_ROOT_DIRS: \$ETTERNA_ADDITIONAL_ROOT_DIRS" - exec $out/bin/etterna-unwrapped "\$@" + exec $out/bin/etterna-unwrapped "\$@" EOF chmod +x $out/bin/etterna