From 9db8632d4f9eb94cc407aac4259e194a6e8a6662 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 22 Apr 2025 11:59:53 +0200 Subject: [PATCH 1/5] feat: make it somewhat work with buildFHSEnv --- .envrc | 2 ++ .gitignore | 2 ++ README.md | 6 ++++++ flake.nix | 54 +++++++++++++++++++++++++++++------------------------- 4 files changed, 39 insertions(+), 25 deletions(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..fe075fe --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +watch_file flake.lock +use flake diff --git a/.gitignore b/.gitignore index b2be92b..471c0ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ +.direnv result +xml_converter diff --git a/README.md b/README.md index d6196cf..ec9725c 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,9 @@ ldd ./burrito.x86_64 to solve this, as I understand it, I need to use `makeWrapper` in `nativeBuildInputs`, and then provide all packages in `pkgs.lib.makeBinPath (with pkgs; [ xorg.libX11 ])` burrito repo is now working on automated github workflows to create a CI system, so I can have a sneak peek at the build process when they will finish it, because now I can't find any clues from the repo inself. I don't know how godot projects works in this regard. + + +# Additional note + +Running `nix develop` (or having a direnv active) allows to run `burrito-gw2` directly, however it doesn't quite work because burrito invokes `./xml_converter`, a fix is to copy this to the current folder. + diff --git a/flake.nix b/flake.nix index e3c6cf6..feff067 100644 --- a/flake.nix +++ b/flake.nix @@ -9,42 +9,46 @@ let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; + src = pkgs.fetchzip { + url = "https://github.com/AsherGlick/Burrito/releases/download/burrito-1.0.0/burrito-1.0.0.zip"; + stripRoot = false; + sha256 = "10iz1w3vz1881i8h898v2ankhfhcsi439jh8b38z14jpfzbv2m6x"; + }; in { - packages.${system}.default = pkgs.stdenv.mkDerivation { + packages.${system}.default = pkgs.buildFHSUserEnv { name = "burrito-gw2"; - buildInputs = with pkgs; [ + targetPkgs = pkgs: with pkgs; [ + glibc + xorg.libXcursor + xorg.libX11 + xorg.libXinerama + xorg.libXext + xorg.libXrandr + xorg.libXrender + xorg.libXi + libGL + libudev-zero ]; - # will fetch github source code - # src = pkgs.fetchFromGitHub { - # owner = "AsherGlick"; - # repo = "Burrito"; - # # to find out rev view tags on github - # # also can check yourself with - # # https://github.com/AsherGlick/Burrito/archive/refs/tags/alpha-1.4.zip - # rev = "alpha-1.4"; - # # to find sha256 - # # nix-prefetch-url --unpack https://github.com/AsherGlick/Burrito/archive/refs/tags/alpha-1.4.zip --type sha256 - # sha256 = "164wjr7y339s67fk1b3kyz4jdx0j64qx77mkzz09wdizi7idphf3"; - # }; - src = pkgs.fetchzip { - url = "https://github.com/AsherGlick/Burrito/releases/download/alpha-1.4/Burrito_Linux.zip"; - # because zip don't have a root directory - stripRoot=false; - # nix-prefetch-url --unpack --type sha256 - sha256 = "0a9f8dby8b3pn36nz0plf2kyjijlr0f6zc7vb8ym044ivrq97ss9"; - }; + runScript = "${src}/burrito.x86_64"; # dummy # to see whats I'm getting - installPhase = '' - mkdir -p $out/bin - cp -r $src $out/bin - ''; + #installPhase = '' + # mkdir -p $out/bin + # cp -r $src $out/bin + # cp $src/burrito.x86_64 $out/bin/burrito-gw2 + # chmod +x $out/bin/burrito-gw2 + #''; }; + devShell.${system} = pkgs.mkShell { + buildInputs = [ + self.packages.${system}.default + ]; + }; }; } From f958345e0769dd491b4dfe60b5191ccb47fd5e32 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 22 Apr 2025 12:04:13 +0200 Subject: [PATCH 2/5] chore: update readme --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ec9725c..9f6a653 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,14 @@ to solve this, as I understand it, I need to use `makeWrapper` in `nativeBuildIn burrito repo is now working on automated github workflows to create a CI system, so I can have a sneak peek at the build process when they will finish it, because now I can't find any clues from the repo inself. I don't know how godot projects works in this regard. -# Additional note -Running `nix develop` (or having a direnv active) allows to run `burrito-gw2` directly, however it doesn't quite work because burrito invokes `./xml_converter`, a fix is to copy this to the current folder. +# Additional notes + +Running `nix develop` (or using direnv) allows to run `burrito-gw2`, however it doesn't quite work in stand-alone because burrito invokes `./xml_converter`, a fix is to copy this file (found in burrito release) to the current folder. + +It currently involves building a FHS env to satisfy burrito dependencies. + +I'll explore building from sources from within Nix. + +Also I'm planning to try and add some config options like the GW2 path so the .dll could be symlinked in it. From 2d7e4820126fb4c37945359d4ad32df1e2d97591 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 22 Apr 2025 13:42:34 +0200 Subject: [PATCH 3/5] feat: wrap burrito exec to cd in its folder (to be able to run ./xml_converter) --- flake.nix | 11 +---------- script.sh | 4 ++++ 2 files changed, 5 insertions(+), 10 deletions(-) create mode 100755 script.sh diff --git a/flake.nix b/flake.nix index feff067..b76fd94 100644 --- a/flake.nix +++ b/flake.nix @@ -33,16 +33,7 @@ libudev-zero ]; - runScript = "${src}/burrito.x86_64"; - - # dummy - # to see whats I'm getting - #installPhase = '' - # mkdir -p $out/bin - # cp -r $src $out/bin - # cp $src/burrito.x86_64 $out/bin/burrito-gw2 - # chmod +x $out/bin/burrito-gw2 - #''; + runScript = "${self}/script.sh ${src}"; }; devShell.${system} = pkgs.mkShell { diff --git a/script.sh b/script.sh new file mode 100755 index 0000000..103c94d --- /dev/null +++ b/script.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd $1 +./burrito.x86_64 From c3bf8fe0fe57f1a9f3f598ae5603f918489f565a Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 23 Apr 2025 10:59:36 +0200 Subject: [PATCH 4/5] feat: try to package with derivation, patching ELF (/!\ BROKEN) --- flake.nix | 55 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index b76fd94..6190817 100644 --- a/flake.nix +++ b/flake.nix @@ -13,15 +13,11 @@ url = "https://github.com/AsherGlick/Burrito/releases/download/burrito-1.0.0/burrito-1.0.0.zip"; stripRoot = false; sha256 = "10iz1w3vz1881i8h898v2ankhfhcsi439jh8b38z14jpfzbv2m6x"; - }; - in - { - - packages.${system}.default = pkgs.buildFHSUserEnv { - name = "burrito-gw2"; - - targetPkgs = pkgs: with pkgs; [ + }; + deps = with pkgs; [ + stdenv.cc.cc.lib glibc + gcc xorg.libXcursor xorg.libX11 xorg.libXinerama @@ -31,9 +27,48 @@ xorg.libXi libGL libudev-zero - ]; + ]; + in + { + packages.${system} = { + default = self.packages.${system}.burrito; - runScript = "${self}/script.sh ${src}"; + burrito = pkgs.stdenv.mkDerivation { + name = "burrito"; + version = "1.0.0"; + src = src; + nativeBuildInputs = [ pkgs.makeWrapper pkgs.autoPatchelfHook ]; + buildInputs = deps; + runtimeDependencies = deps; + installPhase = '' + mkdir -p $out/bin $out/lib + + # Copy the main executable + cp $src/burrito.x86_64 $out/bin/burrito.x86_64 + chmod +x $out/bin/burrito.x86_64 + + # Copy the xml_converter + cp $src/xml_converter $out/bin/xml_converter + chmod +x $out/bin/xml_converter + + # Copy the libraries + cp $src/*.so $out/lib/ + + # Patch the binary + # chmod +w $out/bin/burrito.x86_64 + # patchelf --set-rpath "$out/lib:${pkgs.lib.makeLibraryPath deps}" $out/bin/burrito.x86_64 + # chmod -w $out/bin/burrito.x86_64 + + # Create a wrapper script + makeWrapper $out/bin/burrito.x86_64 $out/bin/burrito \ + --set LD_LIBRARY_PATH "$out/lib:${pkgs.lib.makeLibraryPath deps}" \ + --chdir "$out/bin" + ''; + meta = { + description = "Burrito Guild Wars 2 overlay"; + platforms = [ "x86_64-linux" ]; + }; + }; }; devShell.${system} = pkgs.mkShell { From e87337c519d75830146b5573f0fcbc1e4367ae50 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Sun, 4 May 2025 15:37:42 +0200 Subject: [PATCH 5/5] feat: add both fhs & wrapped targets to the flake --- flake.nix | 133 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 84 insertions(+), 49 deletions(-) diff --git a/flake.nix b/flake.nix index 6190817..f912f75 100644 --- a/flake.nix +++ b/flake.nix @@ -5,16 +5,17 @@ nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; }; - outputs = { self, nixpkgs, ... }: - let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - src = pkgs.fetchzip { - url = "https://github.com/AsherGlick/Burrito/releases/download/burrito-1.0.0/burrito-1.0.0.zip"; - stripRoot = false; - sha256 = "10iz1w3vz1881i8h898v2ankhfhcsi439jh8b38z14jpfzbv2m6x"; - }; - deps = with pkgs; [ + outputs = + { self, nixpkgs, ... }: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + src = pkgs.fetchzip { + url = "https://github.com/AsherGlick/Burrito/releases/download/burrito-1.0.0/burrito-1.0.0.zip"; + stripRoot = false; + sha256 = "10iz1w3vz1881i8h898v2ankhfhcsi439jh8b38z14jpfzbv2m6x"; + }; + deps = with pkgs; [ stdenv.cc.cc.lib glibc gcc @@ -27,54 +28,88 @@ xorg.libXi libGL libudev-zero - ]; - in - { - packages.${system} = { - default = self.packages.${system}.burrito; + ]; + in + { + packages.${system} = { + burrito-fhs = pkgs.buildFHSUserEnv { + name = "burrito-gw2"; - burrito = pkgs.stdenv.mkDerivation { - name = "burrito"; - version = "1.0.0"; - src = src; - nativeBuildInputs = [ pkgs.makeWrapper pkgs.autoPatchelfHook ]; - buildInputs = deps; - runtimeDependencies = deps; - installPhase = '' - mkdir -p $out/bin $out/lib + targetPkgs = + pkgs: with pkgs; [ + glibc + xorg.libXcursor + xorg.libX11 + xorg.libXinerama + xorg.libXext + xorg.libXrandr + xorg.libXrender + xorg.libXi + libGL + libudev-zero + ]; - # Copy the main executable - cp $src/burrito.x86_64 $out/bin/burrito.x86_64 - chmod +x $out/bin/burrito.x86_64 + runScript = "${self}/script.sh ${src}"; + }; - # Copy the xml_converter - cp $src/xml_converter $out/bin/xml_converter - chmod +x $out/bin/xml_converter + default = self.packages.${system}.burrito; - # Copy the libraries - cp $src/*.so $out/lib/ - - # Patch the binary - # chmod +w $out/bin/burrito.x86_64 - # patchelf --set-rpath "$out/lib:${pkgs.lib.makeLibraryPath deps}" $out/bin/burrito.x86_64 - # chmod -w $out/bin/burrito.x86_64 + burrito = pkgs.stdenv.mkDerivation { + name = "burrito"; + version = "1.0.0"; + src = src; + nativeBuildInputs = [ + pkgs.makeWrapper + # pkgs.autoPatchelfHook + ]; + buildInputs = deps; + # runtimeDependencies = deps; - # Create a wrapper script - makeWrapper $out/bin/burrito.x86_64 $out/bin/burrito \ - --set LD_LIBRARY_PATH "$out/lib:${pkgs.lib.makeLibraryPath deps}" \ - --chdir "$out/bin" - ''; - meta = { + # '' = { description = "Burrito Guild Wars 2 overlay"; platforms = [ "x86_64-linux" ]; + + installPhase = '' + mkdir -p $out/bin $out/lib + + # Copy the main executable + cp $src/burrito.x86_64 $out/bin/burrito.x86_64 + chmod +x $out/bin/burrito.x86_64 + + # Copy the xml_converter + cp $src/xml_converter $out/bin/xml_converter + chmod +x $out/bin/xml_converter + + # Copy the libraries + cp $src/*.so $out/lib/ + + # Patch the binary + # chmod +w $out/bin/burrito.x86_64 + # patchelf --set-rpath "$out/lib:$ {pkgs.lib.makeLibraryPath deps}" $out/bin/burrito.x86_64 + # chmod -w $out/bin/burrito.x86_64 + + # Create a wrapper script + # makeWrapper $out/bin/burrito.x86_64 $out/bin/burrito \ + # --set LD_LIBRARY_PATH "$out/lib:$ {pkgs.lib.makeLibraryPath deps}" \ + # --chdir "$out/bin" + + # Create a wrapper + cat > $out/bin/burrito << EOF + #!/bin/sh + cd $out/bin + export LD_LIBRARY_PATH="$out/lib:${pkgs.lib.makeLibraryPath deps}" + exec ./burrito.x86_64 "\$@" + EOF + + chmod +x $out/bin/burrito + ''; }; }; - }; - devShell.${system} = pkgs.mkShell { - buildInputs = [ - self.packages.${system}.default - ]; + devShell.${system} = pkgs.mkShell { + buildInputs = [ + self.packages.${system}.burrito-fhs + ]; + }; }; - }; }