nixpkgs/pkgs/applications/misc/trenchbroom/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

127 lines
4.1 KiB
Nix
Raw Normal View History

2023-07-20 16:46:10 +00:00
{ lib, stdenv, fetchFromGitHub, writeText
, cmake, ninja, curl, git, pandoc, pkg-config, unzip, zip
, libGL, libGLU, freeimage, freetype, assimp
2022-08-07 20:15:30 +00:00
, catch2, fmt, glew, miniz, tinyxml-2, xorg
2021-09-15 18:48:04 +00:00
, qtbase, wrapQtAppsHook
, copyDesktopItems, makeDesktopItem
}:
stdenv.mkDerivation rec {
pname = "TrenchBroom";
2023-07-20 16:46:10 +00:00
version = "2023.1";
2021-09-15 18:48:04 +00:00
src = fetchFromGitHub {
owner = "TrenchBroom";
repo = "TrenchBroom";
rev = "v${version}";
2023-07-20 16:46:10 +00:00
sha256 = "sha256-62xcFKSqxPS+J54+kLo/hewM+Wu/rVBGD8oiECDCJpA=";
2021-09-15 18:48:04 +00:00
fetchSubmodules = true;
};
2023-07-20 16:46:10 +00:00
# Manually simulate a vcpkg installation so that it can link the libraries
# properly.
postUnpack =
let
vcpkg_target = "x64-linux";
vcpkg_pkgs = [
"assimp"
"catch2"
"fmt"
"freeimage"
"freetype"
"glew"
"miniz"
"tinyxml2"
];
updates_vcpkg_file = writeText "update_vcpkg_trenchbroom" (
lib.concatMapStringsSep "\n" (name: ''
Package : ${name}
Architecture : ${vcpkg_target}
Version : 1.0
Status : is installed
'') vcpkg_pkgs);
in ''
export VCPKG_ROOT="$TMP/vcpkg"
mkdir -p $VCPKG_ROOT/.vcpkg-root
mkdir -p $VCPKG_ROOT/installed/${vcpkg_target}/lib
mkdir -p $VCPKG_ROOT/installed/vcpkg/updates
ln -s ${updates_vcpkg_file} $VCPKG_ROOT/installed/vcpkg/status
mkdir -p $VCPKG_ROOT/installed/vcpkg/info
${lib.concatMapStrings (name: ''
touch $VCPKG_ROOT/installed/vcpkg/info/${name}_1.0_${vcpkg_target}.list
'') vcpkg_pkgs}
ln -s ${assimp.lib}/lib/lib* $VCPKG_ROOT/installed/${vcpkg_target}/lib/
ln -s ${catch2}/lib/lib* $VCPKG_ROOT/installed/${vcpkg_target}/lib/
ln -s ${fmt}/lib/lib* $VCPKG_ROOT/installed/${vcpkg_target}/lib/
ln -s ${freeimage}/lib/lib* $VCPKG_ROOT/installed/${vcpkg_target}/lib/
ln -s ${freetype}/lib/lib* $VCPKG_ROOT/installed/${vcpkg_target}/lib/
ln -s ${glew.out}/lib/lib* $VCPKG_ROOT/installed/${vcpkg_target}/lib/
ln -s ${miniz}/lib/lib* $VCPKG_ROOT/installed/${vcpkg_target}/lib/
ln -s ${tinyxml-2}/lib/lib* $VCPKG_ROOT/installed/${vcpkg_target}/lib/
'';
2021-09-15 18:48:04 +00:00
postPatch = ''
substituteInPlace common/src/Version.h.in \
--subst-var-by APP_VERSION_YEAR ${lib.versions.major version} \
--subst-var-by APP_VERSION_NUMBER ${lib.versions.minor version} \
--subst-var-by GIT_DESCRIBE v${version}
2023-07-20 16:46:10 +00:00
substituteInPlace app/CMakeLists.txt \
--replace 'set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")' 'set(CPACK_PACKAGING_INSTALL_PREFIX "'$out'")'
2021-09-15 18:48:04 +00:00
'';
2023-07-20 16:46:10 +00:00
nativeBuildInputs = [ cmake ninja curl git pandoc wrapQtAppsHook copyDesktopItems pkg-config unzip zip ];
2022-08-07 20:15:30 +00:00
buildInputs = [
2023-07-20 16:46:10 +00:00
libGL libGLU xorg.libXxf86vm xorg.libSM
freeimage freetype qtbase catch2 fmt
glew miniz tinyxml-2 assimp
2022-08-07 20:15:30 +00:00
];
2021-09-15 18:48:04 +00:00
QT_PLUGIN_PATH = "${qtbase}/${qtbase.qtPluginPrefix}";
QT_QPA_PLATFORM = "offscreen";
2022-08-07 20:15:30 +00:00
cmakeFlags = [
2023-07-20 16:46:10 +00:00
"-DCMAKE_MAKE_PROGRAM=ninja"
"-DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake"
"-DVCPKG_MANIFEST_INSTALL=OFF"
2022-08-07 20:15:30 +00:00
# https://github.com/TrenchBroom/TrenchBroom/issues/4002#issuecomment-1125390780
"-DCMAKE_PREFIX_PATH=cmake/packages"
];
2021-09-15 18:48:04 +00:00
ninjaFlags = [
"TrenchBroom"
];
postInstall = ''
pushd $out/share/TrenchBroom/icons
for F in icon_*.png; do
SIZE=$(echo $F|sed -e s/icon_// -e s/.png//)
DIR=$out/share/icons/hicolor/$SIZE"x"$SIZE/apps
mkdir -p $DIR
ln -s ../../../../TrenchBroom/icons/$F $DIR/trenchbroom.png
done
popd
'';
desktopItems = [
(makeDesktopItem {
name = "TrenchBroom";
desktopName = "TrenchBroom level editor";
icon = "trenchbroom";
comment = meta.description;
categories = [ "Development" ];
2021-09-15 18:48:04 +00:00
exec = "trenchbroom";
})
];
meta = with lib; {
homepage = "https://trenchbroom.github.io/";
2022-08-07 20:15:30 +00:00
changelog = "https://github.com/TrenchBroom/TrenchBroom/releases/tag/v${version}";
2021-09-15 18:48:04 +00:00
description = "Level editor for Quake-engine based games";
license = licenses.gpl3Only;
maintainers = with maintainers; [ astro ];
2023-07-20 16:46:10 +00:00
platforms = [ "x86_64-linux" ];
2021-09-15 18:48:04 +00:00
};
}