2021-10-28 06:52:43 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, stdenvNoLibs
|
|
|
|
, fetchFromGitea
|
|
|
|
, runtimeShell
|
2022-12-02 08:20:57 +00:00
|
|
|
, doCheck ? withLibc && stdenv.hostPlatform == stdenv.buildPlatform
|
|
|
|
, withLibc ? true
|
2021-10-28 06:52:43 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2022-12-02 08:20:57 +00:00
|
|
|
# k itself can be compiled with -ffreestanding, but tests require a libc;
|
|
|
|
# if we want to build k-libc we need a libc obviously
|
|
|
|
useStdenv = if withLibc || doCheck then stdenv else stdenvNoLibs;
|
2021-10-28 06:52:43 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
useStdenv.mkDerivation {
|
|
|
|
pname = "ngn-k";
|
2022-12-02 08:20:57 +00:00
|
|
|
version = "unstable-2022-11-28";
|
2021-10-28 06:52:43 +00:00
|
|
|
|
|
|
|
src = fetchFromGitea {
|
|
|
|
domain = "codeberg.org";
|
|
|
|
owner = "ngn";
|
|
|
|
repo = "k";
|
2022-12-02 08:20:57 +00:00
|
|
|
rev = "e5138f182a8ced07dd240e3fe58274130842a85d";
|
|
|
|
sha256 = "1pn416znrdndb8iccprzx4zicmsx8c6i9dm3wq5z3jg8nan53p69";
|
2021-10-28 06:52:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./repl-license-path.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2022-12-02 08:20:57 +00:00
|
|
|
patchShebangs --build a19/a.sh a20/a.sh a21/a.sh dy/a.sh e/a.sh
|
2021-10-28 06:52:43 +00:00
|
|
|
|
|
|
|
# don't use hardcoded /bin/sh
|
2022-12-02 08:20:57 +00:00
|
|
|
for f in repl.k repl-bg.k m.c;do
|
2021-10-28 06:52:43 +00:00
|
|
|
substituteInPlace "$f" --replace "/bin/sh" "${runtimeShell}"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
makeFlags = [ "-e" ];
|
2022-12-02 08:20:57 +00:00
|
|
|
buildFlags = [
|
|
|
|
(if withLibc then "k-libc" else "k")
|
|
|
|
"libk.so"
|
|
|
|
];
|
2021-10-28 06:52:43 +00:00
|
|
|
checkTarget = "t";
|
|
|
|
inherit doCheck;
|
|
|
|
|
2021-12-21 02:18:32 +00:00
|
|
|
outputs = [ "out" "dev" "lib" ];
|
|
|
|
|
2022-12-02 08:20:57 +00:00
|
|
|
# TODO(@sternenseemann): package bulgarian translation
|
2021-10-28 06:52:43 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
install -Dm755 k "$out/bin/k"
|
|
|
|
install -Dm755 repl.k "$out/bin/k-repl"
|
2021-12-21 02:18:32 +00:00
|
|
|
install -Dm755 libk.so "$lib/lib/libk.so"
|
|
|
|
install -Dm644 k.h "$dev/include/k.h"
|
2021-10-28 06:52:43 +00:00
|
|
|
install -Dm644 LICENSE -t "$out/share/ngn-k"
|
|
|
|
substituteInPlace "$out/bin/k-repl" --replace "#!k" "#!$out/bin/k"
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "A simple fast vector programming language";
|
|
|
|
homepage = "https://codeberg.org/ngn/k";
|
|
|
|
license = lib.licenses.agpl3Only;
|
|
|
|
maintainers = [ lib.maintainers.sternenseemann ];
|
2022-12-02 08:20:57 +00:00
|
|
|
platforms = [ "x86_64-linux" "x86_64-freebsd13" ];
|
2021-10-28 06:52:43 +00:00
|
|
|
};
|
|
|
|
}
|