{ lib, pkg-config, stdenv, ultimatepp, }: { assembly ? ".", extraAssemblies ? [], includeUppsrcAssembly ? true, package, flags ? [], buildMethod ? if stdenv.cc.isClang then "CLANG" else "GCC", buildShared ? false, ... }@args: let flagsString = lib.optionalString (flags != []) ( "+" + lib.concatStringsSep "," flags); output = if buildShared then "lib/${package}.so" else "bin/${package}"; in stdenv.mkDerivation (self: { nativeBuildInputs = [ pkg-config ultimatepp ] ++ args.nativeBuildInputs or []; buildInputs = ultimatepp.uppsrcDependencies ++ args.buildInputs or []; assemblies = lib.concatStringsSep "," ( lib.singleton assembly ++ extraAssemblies ++ lib.optional includeUppsrcAssembly "${ultimatepp.src}/uppsrc" ); postUnpack = '' mkdir -p .home export HOME=$(realpath .home) ''; UPP_NO_BUILD_INFO = true; # https://www.ultimatepp.org/app$ide$umk$en-us.html # s - use shared libraries # S - use shared libraries and build shared libraries # u - use target directory # v - verbose # r - release mode # FIXME: writing to $out should be done in the install phase buildPhase = '' runHook preBuild mkdir -p $out/${if buildShared then "lib" else "bin"} umk \ "$assemblies" \ ${lib.escapeShellArg package} \ ${buildMethod} \ -${if buildShared then "S" else "s"}uvr \ ${flagsString} \ $out/${output} runHook postBuild ''; # Don't run installPhase unless the user explicitly provides it dontInstall = !lib.hasAttr "installPhase" args; } // lib.removeAttrs args [ "assembly" "extraAssemblies" "includeUppsrcAssembly" "package" "flags" "buildMethod" "buildShared" "nativeBuildInputs" "buildInputs" ])