Files
kte/default.nix
Kyle Isom 2571ab79c1 build now works on nix
1. Static linking - Added KTE_STATIC_LINK CMake option and
   disabled it in default.nix to avoid the "attempted
   static link of dynamic object" error

2. Missing include - Added <cstring> to
   test_swap_edge_cases.cc for std::memset/std::memcpy (GCC
   14 is stricter about transitive includes)
2026-03-17 17:15:16 -07:00

79 lines
1.6 KiB
Nix

{
pkgs ? import <nixpkgs> {},
lib ? pkgs.lib,
stdenv,
cmake,
ncurses,
SDL2,
libGL,
xorg,
kdePackages,
qt6Packages ? kdePackages.qt6Packages,
installShellFiles,
graphical ? false,
graphical-qt ? false,
...
}:
let
cmakeContent = builtins.readFile ./CMakeLists.txt;
cmakeLines = lib.splitString "\n" cmakeContent;
versionLine = lib.findFirst (
l: builtins.match ".*set\\(KTE_VERSION \".+\"\\).*" l != null
) (throw "KTE_VERSION not found in CMakeLists.txt") cmakeLines;
version = builtins.head (builtins.match ".*set\\(KTE_VERSION \"(.+)\"\\).*" versionLine);
in
stdenv.mkDerivation {
pname = "kte";
inherit version;
src = lib.cleanSource ./.;
nativeBuildInputs = [
cmake
ncurses
installShellFiles
]
++ lib.optionals graphical [
SDL2
libGL
xorg.libX11
]
++ lib.optionals graphical-qt [
kdePackages.qt6ct
qt6Packages.qtbase
qt6Packages.wrapQtAppsHook
];
cmakeFlags = [
"-DBUILD_GUI=${if graphical then "ON" else "OFF"}"
"-DKTE_USE_QT=${if graphical-qt then "ON" else "OFF"}"
"-DCMAKE_BUILD_TYPE=Debug"
"-DKTE_STATIC_LINK=OFF"
];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp kte $out/bin/
installManPage ../docs/kte.1
${lib.optionalString graphical ''
mkdir -p $out/bin
${if graphical-qt then ''
cp kge $out/bin/kge-qt
'' else ''
cp kge $out/bin/kge
''}
installManPage ../docs/kge.1
mkdir -p $out/share/icons/hicolor/256x256/apps
cp ../kge.png $out/share/icons/hicolor/256x256/apps/kge.png
''}
runHook postInstall
'';
}