Subject: [PATCH] gnu: ngspice: Preserve libngspice inputs.

From: Richard Sent <[email-masked]>
Date: Mon, 30 Sep 2024 15:38:57 -0400

If inputs are lost between libngspice and ngspice, the configure script will
emit warnings (e.g. bison) or disable functionality (libxaw and X11) in the
executable.

* gnu/packages/engineering.scm (ngspice): Modify libngspice inputs instead of
replacing them.

Change-Id: Ia66fcffba3032b0a37289c60ced12c98b705b548
---
Hi all,

This fixes an issue where functionality in ngspice that should be
enabled would be disabled, most notably X11 support.

To test this, you can use this file:

> .title dual rc ladder
> * file name rcrcac.cir
> R1 int in 10k
> V1 in 0 dc 0 ac 1 PULSE (0 5 1u 1u 1u 1 1)
> R2 out int 1k
> C1 int 0 1u
> C2 out 0 100n
> 
> .control
> ac dec 10 1 100k
> # "Interactive" X11 output.
> plot vdb(out)
> plot ph(out)
> .endc
> 
> .end

Without this patch, "$ guix shell ngspice -- ngspice file.cir" fails
to display graphs, printing "Can't open viewport for graphics."

This also fixes a couple warnings logged during the configure phase,
e.g. bison not found.

 gnu/packages/engineering.scm | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index db35c2532c..e046b6de07 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -41,6 +41,7 @@
 ;;; Copyright © 2023 pinoaffe <[email-masked]>
 ;;; Copyright © 2024 Juliana Sims <[email-masked]>
 ;;; Copyright © 2024 Nguyễn Gia Phong <[email-masked]>
+;;; Copyright © 2024 Richard Sent <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2095,8 +2096,14 @@ (define-public ngspice
        ((#:phases phases)
         #~(modify-phases #$phases
             (delete 'delete-scripts)))))
-    (native-inputs (list perl))
-    (inputs (list libngspice readline))))
+    (native-inputs (modify-inputs (package-native-inputs libngspice)
+                     (prepend perl)))
+    (inputs (modify-inputs (package-inputs libngspice)
+              ;; Make sure libngspice inputs are preserved. The configure
+              ;; script will complain and potentially disable functionality if
+              ;; inputs are not found when the executable and library are
+              ;; built in separate steps. e.g. libxaw and X11 support.
+              (prepend libngspice readline)))))
 
 (define trilinos-serial-xyce
   ;; Note: This is a Trilinos containing only the packages Xyce needs, so we

base-commit: ee64bcfb796ef36db4b63f79540627fb25f3320a
-- 
2.46.0