From 757989eb988e476480b74209fd9545d219155457 Mon Sep 17 00:00:00 2001 From: rczb Date: Mon, 4 Nov 2024 11:47:12 +0800 Subject: [PATCH] s7: move patchPhase to postPatch, fix installCheck problem --- pkgs/by-name/s7/s7/package.nix | 57 ++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/pkgs/by-name/s7/s7/package.nix b/pkgs/by-name/s7/s7/package.nix index 4338358ed1af..59823d1d2073 100644 --- a/pkgs/by-name/s7/s7/package.nix +++ b/pkgs/by-name/s7/s7/package.nix @@ -2,11 +2,17 @@ lib, fetchFromGitLab, stdenv, - notcurses, - gmp, - mpfr, - libmpc, + flint3, + gmp, + libmpc, + mpfr, + notcurses, + + gsl, + man, + pkg-config, + unstableGitUpdater, writeScript, }: @@ -33,13 +39,9 @@ stdenv.mkDerivation (finalAttrs: { # The following scripts are modified from [Guix's](https://packages.guix.gnu.org/packages/s7/). - patchPhase = '' - runHook prePatch - + postPatch = '' substituteInPlace s7.c \ --replace-fail libc_s7.so $out/lib/libc_s7.so - - runHook postPatch ''; buildPhase = '' @@ -78,11 +80,6 @@ stdenv.mkDerivation (finalAttrs: { -O2 -I. \ -ldl -lm - cc ffitest.c s7.o -o ffitest \ - -I. \ - -Wl,-export-dynamic \ - -ldl -lm - ./s7-repl libc.scm runHook postBuild @@ -99,9 +96,9 @@ stdenv.mkDerivation (finalAttrs: { dst_doc=$out/share/doc/s7 mkdir -p $dst_bin $dst_lib $dst_inc $dst_share $dst_scm $dst_doc - cp -pr -t $dst_bin s7-repl s7-nrepl + mv -t $dst_bin s7-repl s7-nrepl ln -s s7-nrepl $dst_bin/s7 - cp -pr -t $dst_lib libarb_s7.so libnotcurses_s7.so libc_s7.so + mv -t $dst_lib libarb_s7.so libnotcurses_s7.so libc_s7.so cp -pr -t $dst_share s7.c cp -pr -t $dst_inc s7.h cp -pr -t $dst_scm *.scm @@ -112,10 +109,36 @@ stdenv.mkDerivation (finalAttrs: { doInstallCheck = true; + nativeInstallCheckInputs = [ + man + pkg-config + ]; + + installCheckInputs = [ + gsl + ]; + + /* + XXX: The upstream assumes that `$HOME` is `/home/$USER`, and the source files + lie in `$HOME/cl` . The script presented here uses a fake `$USER` and a + symbolic linked `$HOME/cl` , which make the test suite work but do not meet + the conditions completely. + */ installCheckPhase = '' runHook preInstallCheck - $dst_bin/s7-repl s7test.scm + cc ffitest.c s7.o -o ffitest \ + -I. \ + -Wl,-export-dynamic \ + -ldl -lm + mv ffitest $dst_bin + mkdir -p nix-build/home + ln -sr . nix-build/home/cl + + USER=nix-s7-builder PATH="$dst_bin:$PATH" HOME=$PWD/nix-build/home \ + s7-repl s7test.scm + + rm $dst_bin/ffitest runHook postInstallCheck '';