diff options
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/ngn-k')
-rw-r--r-- | nixpkgs/pkgs/development/interpreters/ngn-k/default.nix | 64 | ||||
-rw-r--r-- | nixpkgs/pkgs/development/interpreters/ngn-k/repl-license-path.patch | 10 |
2 files changed, 74 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/ngn-k/default.nix b/nixpkgs/pkgs/development/interpreters/ngn-k/default.nix new file mode 100644 index 000000000000..dfd6b17f65fa --- /dev/null +++ b/nixpkgs/pkgs/development/interpreters/ngn-k/default.nix @@ -0,0 +1,64 @@ +{ lib +, stdenv +, stdenvNoLibs +, fetchFromGitea +, runtimeShell +, doCheck ? stdenv.hostPlatform == stdenv.buildPlatform +}: + +let + # k itself is compiled with -ffreestanding, but tests require a libc + useStdenv = if doCheck then stdenv else stdenvNoLibs; +in + +useStdenv.mkDerivation { + pname = "ngn-k"; + version = "unstable-2021-12-17"; + + src = fetchFromGitea { + domain = "codeberg.org"; + owner = "ngn"; + repo = "k"; + rev = "26f83645e9ed4798b43390fb9dcdfa0ab8245a8f"; + sha256 = "sha256-VcJcLcL1C8yQH6xvpKR0R0gMrhSfsU4tW+Yy0rGdSSw="; + }; + + patches = [ + ./repl-license-path.patch + ]; + + postPatch = '' + patchShebangs a19/a.sh a20/a.sh a21/a.sh dy/a.sh e/a.sh + + # don't use hardcoded /bin/sh + for f in repl.k m.c;do + substituteInPlace "$f" --replace "/bin/sh" "${runtimeShell}" + done + ''; + + makeFlags = [ "-e" ]; + buildFlags = [ "k" "libk.so" ]; + checkTarget = "t"; + inherit doCheck; + + outputs = [ "out" "dev" "lib" ]; + + installPhase = '' + runHook preInstall + install -Dm755 k "$out/bin/k" + install -Dm755 repl.k "$out/bin/k-repl" + install -Dm755 libk.so "$lib/lib/libk.so" + install -Dm644 k.h "$dev/include/k.h" + 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 ]; + platforms = [ "x86_64-linux" "x86_64-freebsd" ]; + }; +} diff --git a/nixpkgs/pkgs/development/interpreters/ngn-k/repl-license-path.patch b/nixpkgs/pkgs/development/interpreters/ngn-k/repl-license-path.patch new file mode 100644 index 000000000000..6b5d1e4fb6ae --- /dev/null +++ b/nixpkgs/pkgs/development/interpreters/ngn-k/repl-license-path.patch @@ -0,0 +1,10 @@ +--- a/repl.k ++++ b/repl.k +@@ -1,6 +1,6 @@ + #!k + `1:"ngn/k, (c) 2019-2021 ngn, GNU AGPLv3. type \\ for more info\n",repl.prompt:," " +-repl.cmds:(,"a")!{`1:1:repl.joinpath[repl.dirname`argv 0]"LICENSE";} ++repl.cmds:(,"a")!{`1:1:repl.joinpath[repl.dirname`argv 0]"../share/ngn-k/LICENSE";} + repl.dirname:{$[#x:"/"/-1_"/"\x;x;,"."]} + repl.joinpath:{$[x~,".";y;"/"~*|x;x,y;x,"/",y]} + repl.fmt:{$[x~(::);"";(`A~@x)&1<#x;"(",("\n "/`k'x),")\n";`k[x],"\n"]} |