Subject: [bug#57361] [PATCH] gnu: Add solvespace.

From: Kristian Lein-Mathisen <[email-masked]>
Date: Tue, 23 Aug 2022 14:08:31 +0200

Hi everyone,

I'm new to Guix and I'm enjoying it very much so far. Here is my little
contribution: a lightweight CAD package. I don't have a lot of experience
with SolveSpace, so I haven't done any testing other than checking if
export to DXF works and drawing some sketches.

I think I've managed to follow the steps in the Submitting Patches
<https://guix.gnu.org/manual/devel/en/html_node/Submitting-Patches.html>
guide. The package has a couple of TODO's though, mostly regarding
extracting dependencies instead of building the git submodules in-place:

- mimalloc This just points to Microsoft's upstream
<https://github.com/microsoft/mimalloc/tree/f819dbb4e4813fab464aee16770f39f11476bfea>,
very close to version 2.0.6. The only other use of mimalloc I found was
rust-mimalloc, but it seems to be
<https://github.com/purpleprotocol/mimalloc_rust/tree/v0.1.20/libmimalloc-sys/c_src>
on version mimalloc 1.6.4.

- dxfrw: I believe this is an independent fork
<https://github.com/solvespace/libdxfrw>, which is unlikely useful
elsewhere.

Please consider this for inclusion,
Thank you.
K.
From e09bfd0058d35b3fd969ed4093cefeb6692715b0 Mon Sep 17 00:00:00 2001
From: Kristian Lein-Mathisen <[email-masked]>
Date: Tue, 23 Aug 2022 12:45:49 +0200
Subject: [PATCH] gnu: Add solvespace.

* gnu/packages/engineering.scm (solvespace): New variable.
---
 gnu/packages/engineering.scm | 79 ++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index f195179413..47a723f329 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -2895,6 +2895,85 @@ (define-public pcb2gcode
 dynamic calibration of the milling depth.")
      (license license:gpl3+))))
 
+(define-public solvespace
+  (let ((commit "ab00823acc2920e45b89ec655e4c51d4b346e5d8")
+        (version "3.1"))
+    (package
+      (name "solvespace")
+      (version (git-version version "1" commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/solvespace/solvespace")
+                      (commit commit)
+                      (recursive? #t)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1qixcja3rrgm7qiwc8ydzqidifh3al9kyqgg15z27hcvjlkv70v4"))))
+      (build-system cmake-build-system)
+      (native-inputs (list pkg-config gettext-minimal))
+      (arguments
+       `(#:build-type "Release"
+         #:tests? #f
+         #:phases (modify-phases %standard-phases
+                    ;; CMakeLists will try to `git describe` by default, which doesn't
+                    ;; work inside the temporary build dir. So we embed the commit hash
+                    ;; as described in CMakeLists.txt's comments.
+                    (add-before 'configure 'embed-git-commit-hash
+                      (lambda _
+                        (substitute* "CMakeLists.txt"
+                          (("include\\(GetGitCommitHash\\)")
+                           (string-append "set(GIT_COMMIT_HASH "
+                                          ,commit ")")))))
+                    ;; TODO: only initialize the needed submodules, instead of
+                    ;; initializing all (with recursive? #t) and then deleting most
+                    (add-before 'configure 'delete-submodules
+                      (lambda _
+                        (delete-file-recursively "extlib/angle")
+                        (delete-file-recursively "extlib/cairo")
+                        (delete-file-recursively "extlib/freetype")
+                        ;; TODO: see if we can package upstream libdxfrw and use that
+                        ;; instead
+                        ;; (delete-file-recursively "extlib/libdxfrw")
+                        ;; TODO: see if we can package upstream mimalloc and use that
+                        ;; instead
+                        ;; (delete-file-recursively "extlib/mimalloc")
+                        (delete-file-recursively "extlib/libpng")
+                        (delete-file-recursively "extlib/pixman")
+                        (delete-file-recursively "extlib/si")
+                        (delete-file-recursively "extlib/zlib"))))))
+      (inputs (list cairo
+                    freetype
+                    gtkmm-3
+                    json-c
+                    libpng
+                    libspnav
+                    mesa
+                    zlib))
+      (synopsis "Parametric 2D/3D CAD")
+      (description
+       "SOLVESPACE is a free (GPLv3) parametric 3D @acronym{CAD,
+Computer Aided Design} tool.  Applications include:
+
+@itemize
+@item modeling 3d parts — draw with extrudes, revolves, helixes and
+      Boolean (union / difference / intersection) operations
+@item modeling 2d parts — draw the part as a single section,
+      and export DXF, PDF, SVG; use 3d assembly to verify fit
+@item 3d-printed parts — export the STL or other triangle mesh
+      expected by most 3d printers
+@item preparing CAM data — export 2d vector art for a waterjet
+      machine or laser cutter; or generate STEP or STL, for import into
+      third-party CAM software for machining
+@item mechanism design — use the constraint solver to simulate planar
+      or spatial linkages, with pin, ball, or slide joints
+@item plane and solid geometry — replace hand-solved trigonometry and spreadsheets
+      with a live dimensioned drawing
+@end itemize")
+      (home-page "https://solvespace.com/")
+      (license license:gpl3+))))
+
 (define-public syscall-intercept
   ;; Upstream provides no tag. Also, last version update is 4 years old.
   (let ((commit "304404581c57d43478438d175099d20260bae74e")

base-commit: 7c47fa25134a2111e596e96198d02644aedae459
-- 
2.37.2