* [bug#44736] [Shepherd PATCH] build: Add guix.scm helper file.
@ 2020-11-19 12:52 Efraim Flashner
2021-01-11 12:36 ` Ludovic Courtès
2023-06-02 13:54 ` bug#44736: " Ludovic Courtès
0 siblings, 2 replies; 4+ messages in thread
From: Efraim Flashner @ 2020-11-19 12:52 UTC (permalink / raw)
To: 44736; +Cc: Efraim Flashner
* build-aux/guix.scm: New file.
---
build-aux/guix.scm | 52 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
create mode 100644 build-aux/guix.scm
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"))
+ )
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [bug#44736] [Shepherd PATCH] build: Add guix.scm helper file.
2020-11-19 12:52 [bug#44736] [Shepherd PATCH] build: Add guix.scm helper file Efraim Flashner
@ 2021-01-11 12:36 ` Ludovic Courtès
2021-01-21 10:13 ` Efraim Flashner
2023-06-02 13:54 ` bug#44736: " Ludovic Courtès
1 sibling, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2021-01-11 12:36 UTC (permalink / raw)
To: Efraim Flashner; +Cc: 44736
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’.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [bug#44736] [Shepherd PATCH] build: Add guix.scm helper file.
2021-01-11 12:36 ` Ludovic Courtès
@ 2021-01-21 10:13 ` Efraim Flashner
0 siblings, 0 replies; 4+ messages in thread
From: Efraim Flashner @ 2021-01-21 10:13 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 44736
[-- Attachment #1.1: Type: text/plain, Size: 3671 bytes --]
On Mon, Jan 11, 2021 at 01:36:38PM +0100, Ludovic Courtès wrote:
> 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’?
Sure
> > +(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
Looking at that list I feel like I'm missing bits. If we go down the
rabiit hole of figuring out all the different files which could possibly
be included in the list I feel like we should keep it as a fancy macro
somewhere. It'd almost be easier to copy the entire directory somewhere,
run 'git clean -dfx' and then use that. Or to parse .gitignore or make
clean.
> > +(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?
Returning a list also seems to work
(ins)efraim@3900XT ~/workspace/shepherd$ guix build -f build-aux/guix.scm -n
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://bayfront.guix.gnu.org'... 100.0%
The following derivations would be built:
/gnu/store/g2ql360i3s02mg42l4ys27lsghpx5xqq-shepherd-0.8.1-HEAD.b482009.drv
/gnu/store/ajlqc21qqmi3fp5j30jq7vc0i1qn701y-guile2.2-shepherd-0.8.1-HEAD.b482009.drv
/gnu/store/nbq7yw0zzmrwvykcld3fsbgmh39fapym-guile2.0-shepherd-0.8.1.drv
> The downside of returning several packages is that ‘guix environment -l
> guix.scm’ won’t work.
Technically it works, but it's not as useful as just getting the inputs
you actually want.
(ins)efraim@3900XT ~/workspace/shepherd$ guix environment -l build-aux/guix.scm
(ins)efraim@3900XT ~/workspace/shepherd [env]$ which -a guile
/gnu/store/xlsi9fmi4blrpwn4xy8cvfq86zhag878-profile/bin/guile
/home/efraim/.guix-profile/bin/guile
/run/current-system/profile/bin/guile
(ins)efraim@3900XT ~/workspace/shepherd [env]$ /gnu/store/xlsi9fmi4blrpwn4xy8cvfq86zhag878-profile/bin/guile --version
guile (GNU Guile) 3.0.2
Copyright (C) 2020 Free Software Foundation, Inc.
License LGPLv3+: GNU LGPL 3 or later <http://gnu.org/licenses/lgpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
(ins)efraim@3900XT ~/workspace/shepherd$ ls /gnu/store/xlsi9fmi4blrpwn4xy8cvfq86zhag878-profile/lib/guile/
2.0 2.2 3.0/
> Thanks,
> Ludo’.
I also got guile2.0-shepherd to build.
--
Efraim Flashner <efraim@flashner.co.il> אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[-- Attachment #1.2: 0001-build-Add-guix.scm-helper-file.patch --]
[-- Type: text/plain, Size: 4289 bytes --]
From 3fe742290f24fa5e514a06c73247537aed3e58a4 Mon Sep 17 00:00:00 2001
From: Efraim Flashner <efraim@flashner.co.il>
Date: Thu, 19 Nov 2020 14:51:28 +0200
Subject: [PATCH] build: Add guix.scm helper file.
* build-aux/guix.scm: New file.
* Makefile.am (EXTRA_DIST): Register it.
---
Makefile.am | 2 +-
build-aux/guix.scm | 79 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 1 deletion(-)
create mode 100644 build-aux/guix.scm
diff --git a/Makefile.am b/Makefile.am
index 774ebba..1c4acda 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -71,7 +71,7 @@ CLEANFILES = \
\f
# Crash handler.
-EXTRA_DIST = etc/crash-handler.c
+EXTRA_DIST = etc/crash-handler.c build-aux/guix.scm
if BUILD_CRASH_HANDLER
diff --git a/build-aux/guix.scm b/build-aux/guix.scm
new file mode 100644
index 0000000..d895db4
--- /dev/null
+++ b/build-aux/guix.scm
@@ -0,0 +1,79 @@
+;;; guix.scm -- Guix package definition
+;; Copyright (C) 2020 Efraim Flashner <efraim@flashner.co.il>
+;;
+;; This file is part of the GNU Shepherd.
+;;
+;; The GNU Shepherd is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3 of the License, or (at
+;; your option) any later version.
+;;
+;; The GNU Shepherd is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with the GNU Shepherd. If not, see <http://www.gnu.org/licenses/>.
+
+(use-modules
+ (guix packages)
+ ((guix git-download) #:select (git-version))
+ ((guix build utils) #:select (find-files))
+ ((guix gexp) #:select (local-file))
+ ((guix utils) #:select (substitute-keyword-arguments))
+ ((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"))
+ (let ((base (build-from-git (specification->package "guile2.0-shepherd"))))
+ (package
+ (inherit base)
+ (arguments
+ (substitute-keyword-arguments (package-arguments base)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-after 'unpack 'patch-source
+ (lambda _
+ ;; (ice-9 threads) isn't available in guile-2.0
+ (substitute* "modules/shepherd.scm"
+ ((".*\\(ice-9 threads\\).*") ""))
+ #t)))))))))
--
2.30.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#44736: [Shepherd PATCH] build: Add guix.scm helper file.
2020-11-19 12:52 [bug#44736] [Shepherd PATCH] build: Add guix.scm helper file Efraim Flashner
2021-01-11 12:36 ` Ludovic Courtès
@ 2023-06-02 13:54 ` Ludovic Courtès
1 sibling, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2023-06-02 13:54 UTC (permalink / raw)
To: Efraim Flashner; +Cc: 44736-done
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’.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-02 13:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-19 12:52 [bug#44736] [Shepherd PATCH] build: Add guix.scm helper file Efraim Flashner
2021-01-11 12:36 ` Ludovic Courtès
2021-01-21 10:13 ` Efraim Flashner
2023-06-02 13:54 ` bug#44736: " Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).