diff --git a/pkgs/by-name/ng/ngn-k/package.nix b/pkgs/by-name/ng/ngn-k/package.nix index 76ff50b64b9e..4268f816f087 100644 --- a/pkgs/by-name/ng/ngn-k/package.nix +++ b/pkgs/by-name/ng/ngn-k/package.nix @@ -3,48 +3,38 @@ , stdenvNoLibs , fetchFromGitea , runtimeShell -, doCheck ? withLibc && stdenv.hostPlatform == stdenv.buildPlatform -, withLibc ? true }: -let - # 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; -in - -useStdenv.mkDerivation { +stdenv.mkDerivation { pname = "ngn-k"; - version = "unstable-2022-11-28"; + version = "0-unstable-2025-01-04"; src = fetchFromGitea { domain = "codeberg.org"; owner = "ngn"; repo = "k"; - rev = "e5138f182a8ced07dd240e3fe58274130842a85d"; - sha256 = "1pn416znrdndb8iccprzx4zicmsx8c6i9dm3wq5z3jg8nan53p69"; + rev = "feb51a61443dac03213c4e97edd8df679a4a3aaa"; + sha256 = "14v2bwbgaxi1rsq5xabp5dmv0bl0vga3lhzwdxyvsyl9q7qybf55"; }; patches = [ ./repl-license-path.patch + ./repl-argv-1.patch ]; postPatch = '' - patchShebangs --build 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 repl-bg.k m.c;do - substituteInPlace "$f" --replace "/bin/sh" "${runtimeShell}" + for f in repl.k m.c;do + substituteInPlace "$f" --replace-fail "/bin/sh" "${runtimeShell}" done ''; makeFlags = [ "-e" ]; buildFlags = [ - (if withLibc then "k-libc" else "k") + "k" "libk.so" ]; checkTarget = "t"; - inherit doCheck; outputs = [ "out" "dev" "lib" ]; @@ -56,7 +46,7 @@ useStdenv.mkDerivation { 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" + substituteInPlace "$out/bin/k-repl" --replace-fail "#!k" "#!$out/bin/k" runHook postInstall ''; diff --git a/pkgs/by-name/ng/ngn-k/repl-argv-1.patch b/pkgs/by-name/ng/ngn-k/repl-argv-1.patch new file mode 100644 index 000000000000..0e54a0845e4a --- /dev/null +++ b/pkgs/by-name/ng/ngn-k/repl-argv-1.patch @@ -0,0 +1,13 @@ +diff --git a/repl.k b/repl.k +index dc89832c..33780850 100755 +--- a/repl.k ++++ b/repl.k +@@ -28,7 +28,7 @@ joinpath:{$[x~,".";y;"/"~*|x;x,y;x,"/",y]} + line0:{c:{0x07~*-2#*x}{(l;r):x;(1:1;r,,(-2_l))}/(x;());"\n"/(*|c),,*c} + line1:{$[#x;;:0];x:-1_x;$[(3>#x)&("\\"=*x)&~^(!cmds)?x 1;cmds[x 1]x 1;.[`1:(fmt;fmtx)[" "~*x]@.:;,x;{`0:`err[]}]];`1:prompt;1} + line:line1@line0@ +-$["repl.k"~basename`argv 1;{cmds::@[cmds;x[1]1;:;{y;`0:x}2_x]}'{(&x~\:80#"-")_x:(1+*&x~\:,"/")_-1_x}@0:`argv 1;]; ++$["k-repl"~basename`argv 1;{cmds::@[cmds;x[1]1;:;{y;`0:x}2_x]}'{(&x~\:80#"-")_x:(1+*&x~\:,"/")_-1_x}@0:`argv 1;]; + run:{`1:banner,prompt;{line@1:`}::/`;} + \d . + diff --git a/pkgs/by-name/ng/ngn-k/repl-license-path.patch b/pkgs/by-name/ng/ngn-k/repl-license-path.patch index 17b998db187e..d3cd8c781b6b 100644 --- a/pkgs/by-name/ng/ngn-k/repl-license-path.patch +++ b/pkgs/by-name/ng/ngn-k/repl-license-path.patch @@ -1,13 +1,13 @@ diff --git a/repl.k b/repl.k -index 4c023467..10414162 100755 +index dc89832c..7a6e0dcf 100755 --- a/repl.k +++ b/repl.k -@@ -2,7 +2,7 @@ - `1:"ngn/k, (c) 2019-2022 ngn, GNU AGPLv3. type \\ for more info\n" - \d repl - `1:prompt:," " /use 0x0720 for emacs integration +@@ -21,7 +21,7 @@ tbl:{[w;u;x]h:`k'!x;d:`k''.x;W:(#'h)|/'#''d + r,par'dd[w-2]'sem/'+@[W;&~^`i`d?_@'.x;-:]$'d} + cell:{$[|/`i`d=@y;-x;x]$z} + par:{opn,x,cls} -cmds:(,"a")!{`1:1:joinpath[dirname`argv 0]"LICENSE";} +cmds:(,"a")!{`1:1:joinpath[dirname`argv 0]"../share/ngn-k/LICENSE";} + basename:{*|"/"\x} dirname:{$[#x:"/"/-1_"/"\x;x;,"."]} joinpath:{$[x~,".";y;"/"~*|x;x,y;x,"/",y]} - fmt:{$[x~(::);"";(`A~@x)&1<#x;"(",("\n "/`k'x),")\n";`k[x],"\n"]}