Skip to content

Commit

Permalink
unilang: format recipe code
Browse files Browse the repository at this point in the history
  • Loading branch information
rc-zb committed Jul 12, 2024
1 parent 9d90359 commit 4becc3d
Showing 1 changed file with 58 additions and 32 deletions.
90 changes: 58 additions & 32 deletions pkgs/by-name/un/unilang/package.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{ lib, stdenv, fetchFromGitHub
{ lib
, stdenv
, fetchFromGitHub
, libffi
, libsForQt5
, lld
Expand All @@ -9,6 +11,7 @@
stdenv.mkDerivation (finalAttrs: {
pname = "unilang";
version = "0.13";

src = fetchFromGitHub {
owner = "linuxdeepin";
repo = "unilang";
Expand All @@ -26,28 +29,61 @@ stdenv.mkDerivation (finalAttrs: {
pkg-config
];

/*
`std.txt` is a component of Unilang installation, and must be kept in
the output.
*/
preBuild = ''
mkdir -p $out/lib/
cp ./std.txt $out/lib/
patchPhase = ''
runHook prePatch
# `std.txt` is a component of Unilang installation, and must be kept in the output.
substituteInPlace ./src/Main.cpp \
--replace-fail \"std.txt\" \"$out/lib/std.txt\" \
--replace-fail \"std.txt\" \"$out/lib/std.txt\"
# Trim the shabang.
sed --in-place --expression='1{/^#!/d}' ./build.sh
runHook postPatch
'';
# LLVM-based JIT is disabled for lack of LLVM 7.

postPatch = ''
# Trim the shabang.
sed --in-place --expression='1{/^#!/d}' ./test.sh
# Change the paths of test logs.
mkdir -p ./test
substituteInPlace ./test.sh \
--replace-fail =/tmp/out =$(pwd)/test/out.log \
--replace-fail =/tmp/err =$(pwd)/test/err.log
'';

buildPhase = ''
runHook preBuild
export Unilang_Output=$out/bin/unilang
export Unilang_BuildDir=$(pwd)/build/
export UNILANG_NO_LLVM=0;
export UNILANG_NO_LLVM=0; # LLVM-based JIT is disabled for lack of LLVM 7.
export LDFLAGS=-fuse-ld=lld
bash ./build.sh
./build.sh
runHook postBuild
'';

installPhase = ''
runHook preInstall
mkdir -p $out/lib
cp ./std.txt $out/lib/
runHook postInstall
'';

doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
export UNILANG=$out/bin/unilang
./test.sh
runHook postInstallCheck
'';

qtWrapperArgs = let
runtimeLibPath = lib.strings.makeLibraryPath [
libffi
Expand All @@ -59,31 +95,21 @@ stdenv.mkDerivation (finalAttrs: {
"--suffix LD_LIBRARY_PATH : ${runtimeLibPath}"
];

doCheck = true;
preCheck = ''
mkdir -p ./test/
substituteInPlace ./test.sh \
--replace-fail =/tmp/out =$(pwd)/test/out.log \
--replace-fail =/tmp/err =$(pwd)/test/err.log
'';
checkPhase = ''
runHook preCheck
export UNILANG=$out/bin/unilang
bash ./test.sh
runHook postCheck
'';

meta = {
description = "A general purpose programming language";
description = "General purpose programming language";
longDescription = ''
Unilang is a general purpose programming language project proposed to adapt to more effective and flexible development of desktop environment applications.
Unilang is a general purpose programming language project proposed to
adapt to more effective and flexible development of desktop environment
applications.
'';
homepage = "https://github.com/linuxdeepin/unilang/";
changelog = "https://github.com/linuxdeepin/unilang/raw/V${finalAttrs.version}/ReleaseNotes.zh-CN.md"; # Currently zh-CN only.
changelog =
# Currently zh-CN only.
"https://github.com/linuxdeepin/unilang/raw/V${finalAttrs.version}/ReleaseNotes.zh-CN.md";
license = lib.licenses.bsd2Patent;
maintainers = with lib.maintainers; [ rc-zb ];
maintainers = with lib.maintainers; [
rc-zb
];
mainProgram = "unilang";
platforms = lib.platforms.linux;
};
Expand Down

0 comments on commit 4becc3d

Please sign in to comment.