summary refs log tree commit diff
diff options
context:
space:
mode:
authorKevin Cox <kevincox@kevincox.ca>2021-11-29 17:16:44 -0500
committerGitHub <noreply@github.com>2021-11-29 17:16:44 -0500
commitb7caba7f59149b238857957f76708485700d9e9f (patch)
tree1c48cdfaf65ff06fc0d362933400a8c972d27d80
parent2b35c41b8138b35e60df79f171fe0028104bab84 (diff)
parent324e9f686ec39ba5d4a760d957509c52039cec27 (diff)
downloadnixpkgs-b7caba7f59149b238857957f76708485700d9e9f.tar
nixpkgs-b7caba7f59149b238857957f76708485700d9e9f.tar.gz
nixpkgs-b7caba7f59149b238857957f76708485700d9e9f.tar.bz2
nixpkgs-b7caba7f59149b238857957f76708485700d9e9f.tar.lz
nixpkgs-b7caba7f59149b238857957f76708485700d9e9f.tar.xz
nixpkgs-b7caba7f59149b238857957f76708485700d9e9f.tar.zst
nixpkgs-b7caba7f59149b238857957f76708485700d9e9f.zip
Merge pull request #146902 from fgaz/vengi/init
vengi-tools: init at 0.0.14
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/vengi-tools.nix29
-rw-r--r--pkgs/applications/graphics/vengi-tools/default.nix119
-rw-r--r--pkgs/applications/graphics/vengi-tools/test-voxconvert-roundtrip.nix15
-rw-r--r--pkgs/top-level/all-packages.nix4
5 files changed, 168 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 5afe05c1b72..e2b9c868bc8 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -487,6 +487,7 @@ in
   vault-postgresql = handleTest ./vault-postgresql.nix {};
   vaultwarden = handleTest ./vaultwarden.nix {};
   vector = handleTest ./vector.nix {};
+  vengi-tools = handleTest ./vengi-tools.nix {};
   victoriametrics = handleTest ./victoriametrics.nix {};
   vikunja = handleTest ./vikunja.nix {};
   virtualbox = handleTestOn ["x86_64-linux"] ./virtualbox.nix {};
diff --git a/nixos/tests/vengi-tools.nix b/nixos/tests/vengi-tools.nix
new file mode 100644
index 00000000000..6b90542887d
--- /dev/null
+++ b/nixos/tests/vengi-tools.nix
@@ -0,0 +1,29 @@
+import ./make-test-python.nix ({ pkgs, ... }: {
+  name = "vengi-tools";
+  meta = with pkgs.lib.maintainers; {
+    maintainers = [ fgaz ];
+  };
+
+  machine = { config, pkgs, ... }: {
+    imports = [
+      ./common/x11.nix
+    ];
+
+    services.xserver.enable = true;
+    environment.systemPackages = [ pkgs.vengi-tools ];
+  };
+
+  enableOCR = true;
+
+  testScript =
+    ''
+      machine.wait_for_x()
+      machine.execute("vengi-voxedit >&2 &")
+      machine.wait_for_window("voxedit")
+      # OCR on voxedit's window is very expensive, so we avoid wasting a try
+      # by letting the window load fully first
+      machine.sleep(15)
+      machine.wait_for_text("Palette")
+      machine.screenshot("screen")
+    '';
+})
diff --git a/pkgs/applications/graphics/vengi-tools/default.nix b/pkgs/applications/graphics/vengi-tools/default.nix
new file mode 100644
index 00000000000..00b3d80adf0
--- /dev/null
+++ b/pkgs/applications/graphics/vengi-tools/default.nix
@@ -0,0 +1,119 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, fetchurl
+
+, cmake
+, pkg-config
+, ninja
+, python3
+, makeWrapper
+
+, glm
+, lua5_4
+, SDL2
+, SDL2_mixer
+, enet
+, libuv
+, libuuid
+, wayland-protocols
+, Carbon
+# optionals
+, opencl-headers
+, OpenCL
+
+, callPackage
+, nixosTests
+}:
+
+# cmake 3.21 inserts invalid `ldd` and `-Wl,--no-as-needed` calls, apparently
+# related to
+# https://cmake.org/cmake/help/v3.21/prop_tgt/LINK_WHAT_YOU_USE.html
+let cmake3_22 = cmake.overrideAttrs (old: {
+  version = "3.22.0";
+  src = fetchurl {
+    url = "https://cmake.org/files/v3.22/cmake-3.22.0.tar.gz";
+    sha256 = "sha256-mYx7o0d40t/bPfimlUaeJLEeK/oh++QbNho/ReHJNF4=";
+  };
+});
+
+in stdenv.mkDerivation rec {
+  pname = "vengi-tools";
+  version = "0.0.14";
+
+  src = fetchFromGitHub {
+    owner = "mgerhardy";
+    repo = "engine";
+    rev = "v${version}";
+    sha256 = "sha256-v82hKskTSwM0NDgLVHpHZNRQW6tWug4pPIt91MrUwUo=";
+  };
+
+  nativeBuildInputs = [
+    cmake3_22
+    pkg-config
+    ninja
+    python3
+    makeWrapper
+  ];
+
+  buildInputs = [
+    glm
+    lua5_4
+    SDL2
+    SDL2_mixer
+    enet
+    libuv
+    libuuid
+    # Only needed for the game
+    #postgresql
+    #libpqxx
+    #mosquitto
+  ] ++ lib.optional stdenv.isLinux wayland-protocols
+    ++ lib.optionals stdenv.isDarwin [ Carbon OpenCL ]
+    ++ lib.optional (!stdenv.isDarwin) opencl-headers;
+
+  cmakeFlags = [
+    # Disable tests due to a problem in linking gtest:
+    # ld: /build/vengi-tests-core.LDHlV1.ltrans0.ltrans.o: in function `main':
+    # <artificial>:(.text.startup+0x3f): undefined reference to `testing::InitGoogleMock(int*, char**)'
+    "-DUNITTESTS=OFF"
+    "-DVISUALTESTS=OFF"
+    # We're only interested in the generic tools
+    "-DGAMES=OFF"
+    "-DMAPVIEW=OFF"
+    "-DAIDEBUG=OFF"
+  ];
+
+  # Set the data directory for each executable. We cannot set it at build time
+  # with the PKGDATADIR cmake variable because each executable needs a specific
+  # one.
+  # This is not needed on darwin, since on that platform data files are saved
+  # in *.app/Contents/Resources/ too, and are picked up automatically.
+  postInstall = lib.optionalString (!stdenv.isDarwin) ''
+    for prog in $out/bin/*; do
+      wrapProgram "$prog" \
+        --set CORE_PATH $out/share/$(basename "$prog")/
+    done
+  '';
+
+  passthru.tests = {
+    voxconvert-roundtrip = callPackage ./test-voxconvert-roundtrip.nix {};
+    run-voxedit = nixosTests.vengi-tools;
+  };
+
+  meta = with lib; {
+    description = "Tools from the vengi voxel engine, including a thumbnailer, a converter, and the VoxEdit voxel editor";
+    longDescription = ''
+      Tools from the vengi C++ voxel game engine. It includes a voxel editor
+      with character animation support and loading/saving into a lot of voxel
+      volume formats. There are other tools like e.g. a thumbnailer for your
+      filemanager and a command line tool to convert between several voxel
+      formats.
+    '';
+    homepage = "https://mgerhardy.github.io/engine/";
+    downloadPage = "https://github.com/mgerhardy/engine/releases";
+    license = [ licenses.mit licenses.cc-by-sa-30 ];
+    maintainers = with maintainers; [ fgaz ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/applications/graphics/vengi-tools/test-voxconvert-roundtrip.nix b/pkgs/applications/graphics/vengi-tools/test-voxconvert-roundtrip.nix
new file mode 100644
index 00000000000..27b0305615a
--- /dev/null
+++ b/pkgs/applications/graphics/vengi-tools/test-voxconvert-roundtrip.nix
@@ -0,0 +1,15 @@
+{ stdenv
+, vengi-tools
+}:
+
+stdenv.mkDerivation {
+  name = "vengi-tools-test-voxconvert-roundtrip";
+  meta.timeout = 10;
+  buildCommand = ''
+    ${vengi-tools}/bin/vengi-voxconvert ${vengi-tools}/share/vengi-voxedit/chr_knight.qb chr_knight.vox
+    ${vengi-tools}/bin/vengi-voxconvert chr_knight.vox chr_knight.qb
+    ${vengi-tools}/bin/vengi-voxconvert chr_knight.qb chr_knight1.vox
+    diff chr_knight.vox chr_knight1.vox
+    touch $out
+  '';
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 96cea130180..f65cbdb60fc 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -28839,6 +28839,10 @@ with pkgs;
 
   vdpauinfo = callPackage ../tools/X11/vdpauinfo { };
 
+  vengi-tools = callPackage ../applications/graphics/vengi-tools {
+    inherit (darwin.apple_sdk.frameworks) Carbon OpenCL;
+  };
+
   verbiste = callPackage ../applications/misc/verbiste {
     inherit (gnome2) libgnomeui;
   };