diff mbox series

[bug#44736,Shepherd] build: Add guix.scm helper file.

Message ID 20201119125244.3674-1-efraim@flashner.co.il
State New
Headers show
Series [bug#44736,Shepherd] build: Add guix.scm helper file. | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Efraim Flashner Nov. 19, 2020, 12:52 p.m. UTC
* build-aux/guix.scm: New file.
---
 build-aux/guix.scm | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 build-aux/guix.scm

Comments

Ludovic Courtès Jan. 11, 2021, 12:36 p.m. UTC | #1
Hello!

Efraim Flashner <efraim@flashner.co.il> skribis:

> * build-aux/guix.scm: New file.

Could you (1) add a copyright header, and (2) add this file to
‘EXTRA_DIST’ in ‘Makefile.am’?

> +(define (keep-file? file stat)
> +  (not (any (lambda (my-string)
> +              (string-contains file my-string))
> +            (list ".git" ".dir-locals.el" "build-aux"))))

FWIW, I’m never quite sure what to do here.  In Guile-zstd, I wrote
something that works even from a tarball (not a Git checkout), but it’s
a bit verbose:

  https://notabug.org/guile-zstd/guile-zstd/src/master/guix.scm

> +(define (build-from-git base)
> +  (package
> +    (inherit base)
> +    (version (git-version (package-version base) "HEAD" %git-commit))
> +    (source (local-file %source-dir
> +                        #:recursive? #t
> +                        #:select? keep-file?))

[…]

> +(list (build-from-git (specification->package "shepherd"))
> +      (build-from-git (specification->package "guile2.2-shepherd"))
> +      ;; This version FTBFS due to an import of '(ice-9 threads)' in modules/shepherd.scm
> +      ;(build-from-git (specification->package "guile2.0-shepherd"))
> +      )

Should it be a manifest instead, so that ‘guix build -f’ works?

The downside of returning several packages is that ‘guix environment -l
guix.scm’ won’t work.

Thanks,
Ludo’.
Ludovic Courtès June 2, 2023, 1:54 p.m. UTC | #2
Hi,

Efraim Flashner <efraim@flashner.co.il> skribis:

> * build-aux/guix.scm: New file.

I did something similar quite recently in the Shepherd.  Closing!

Ludo’.
diff mbox series

Patch

diff --git a/build-aux/guix.scm b/build-aux/guix.scm
new file mode 100644
index 0000000..ea9c63f
--- /dev/null
+++ b/build-aux/guix.scm
@@ -0,0 +1,52 @@ 
+;;; guix.scm -- Guix package definition
+
+(use-modules
+  (guix packages)
+  ((guix git-download) #:select (git-version))
+  ((guix build utils) #:select (find-files))
+  ((guix gexp) #:select (local-file))
+  ((gnu packages) #:select (specification->package))
+  ((ice-9 popen) #:select (open-pipe))
+  ((ice-9 rdelim) #:select (read-string))
+  ((srfi srfi-1) #:select (any)))
+
+(define %source-dir (dirname (dirname (current-filename))))
+
+(define %git-commit
+  (read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2" OPEN_READ)))
+
+(define (keep-file? file stat)
+  (not (any (lambda (my-string)
+              (string-contains file my-string))
+            (list ".git" ".dir-locals.el" "build-aux"))))
+
+(define (build-from-git base)
+  (package
+    (inherit base)
+    (version (git-version (package-version base) "HEAD" %git-commit))
+    (source (local-file %source-dir
+                        #:recursive? #t
+                        #:select? keep-file?))
+    (native-inputs
+     `(("autoconf" ,(specification->package "autoconf"))
+       ("automake" ,(specification->package "automake"))
+       ("gettext" ,(specification->package "gettext"))
+       ("help2man" ,(specification->package "help2man"))
+       ("texinfo" ,(specification->package "texinfo"))
+       ,@(package-native-inputs base)))
+    (arguments
+     `(#:configure-flags '("--localstatedir=/var")
+       #:make-flags (list "GUILE_AUTO_COMPILE=0")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'make-po-directory-writable
+           (lambda _
+             (for-each make-file-writable
+               (find-files "po" "."))
+               #t)))))))
+
+(list (build-from-git (specification->package "shepherd"))
+      (build-from-git (specification->package "guile2.2-shepherd"))
+      ;; This version FTBFS due to an import of '(ice-9 threads)' in modules/shepherd.scm
+      ;(build-from-git (specification->package "guile2.0-shepherd"))
+      )