unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Bonface M. K." <bonfacemunyoki@gmail.com>
To: Christopher Lemmer Webber <cwebber@dustycloud.org>
Cc: guix-devel@gnu.org, Dimos Dimakakos <me@bendersteed.tech>,
	Pjotr Prins <pjotr2020@thebird.nl>
Subject: Re: Racket packages / build system
Date: Mon, 09 Nov 2020 23:54:29 +0300	[thread overview]
Message-ID: <86blg6xncq.fsf@gmail.com> (raw)
In-Reply-To: <87a6wizuic.fsf@dustycloud.org> (Christopher Lemmer Webber's message of "Mon, 19 Oct 2020 00:53:31 -0400")


[-- Attachment #1.1: Type: text/plain, Size: 4048 bytes --]

Christopher Lemmer Webber <cwebber@dustycloud.org>
writes:

> Bonface M. K. writes:
>

[...]

> I have the notes that Dimos wrote up not long ago in case anyone is
> interested.  Dimos, do you mind if I post them to the list?
>
>  - Chris

Hi! I've been trying to hack around the racket
build system(see attached) for some time now;
mostly using raco... The biggest problem I've
faced so far is that AFAICT, when you use raco to
install packages, racket updates some files from
where it's called(in guix's case store this is the
store where racket is in)--- and I don't think you
are allowed to do this. I've tried doing "raco
install <zipfile>", and also just doing "raco
install" from inside the directory.

The command for building:

--8<---------------cut here---------------start------------->8---
env GUIX_PACKAGE_PATH="/home/bonface/projects/guix-bioinformatics:/home/bonface/projects/guix-past/modules" ./pre-inst-env guix build racket-hello-racket -K
--8<---------------cut here---------------end--------------->8---

with the error:

--8<---------------cut here---------------start------------->8---
starting phase `install'
make-directory: cannot make directory
  path: /homeless-shelter/
  system error: Permission denied; errno=13
  context...:
   /gnu/store/4f148vh30qmrdl6apq1ff6yqb7kl8xlm-racket-minimal-7.8/share/racket/collects/racket/file.rkt:114:0: make-directory*
   [repeats 1 more time]
   /gnu/store/4f148vh30qmrdl6apq1ff6yqb7kl8xlm-racket-minimal-7.8/share/racket/collects/pkg/private/lock.rkt:26:0: with-pkg-lock*
   /gnu/store/4f148vh30qmrdl6apq1ff6yqb7kl8xlm-racket-minimal-7.8/share/racket/collects/pkg/main.rkt:216:16
   (submod "/gnu/store/4f148vh30qmrdl6apq1ff6yqb7kl8xlm-racket-minimal-7.8/share/racket/collects/pkg/main.rkt" main): [running body]
   temp35_0
   for-loop
   run-module-instance!
   for-loop
   [repeats 1 more time]
   run-module-instance!
   "/gnu/store/4f148vh30qmrdl6apq1ff6yqb7kl8xlm-racket-minimal-7.8/share/racket/collects/raco/raco.rkt": [running body]
   temp35_0
   for-loop
   run-module-instance!
   "/gnu/store/4f148vh30qmrdl6apq1ff6yqb7kl8xlm-racket-minimal-7.8/share/racket/collects/raco/main.rkt": [running body]
   ...
Inferred package name from given `--clone' path
  package: source
  given path: /tmp/guix-build-racket-hello-racket-0.0.1.drv-0/source
command "raco" "pkg" "install" "--no-cache" "--no-setup" "--ignore-checksums" "--clone" "/tmp/guix-build-racket-hello-racket-0.0.1.drv-0/source" failed with status 1
builder for `/gnu/store/filph2d8m7k1rq6rpglwx1y082ris6g0-racket-hello-racket-0.0.1.drv' failed with exit code 1
build of /gnu/store/filph2d8m7k1rq6rpglwx1y082ris6g0-racket-hello-racket-0.0.1.drv failed
View build log at '/var/log/guix/drvs/fi/lph2d8m7k1rq6rpglwx1y082ris6g0-racket-hello-racket-0.0.1.drv.bz2'.
guix build: error: build of `/gnu/store/filph2d8m7k1rq6rpglwx1y082ris6g0-racket-hello-racket-0.0.1.drv' failed

--8<---------------cut here---------------end--------------->8---

And when troubleshooting:

--8<---------------cut here---------------start------------->8---
cd /tmp/guix-build-racket-hello-racket-0.0.1.drv-0

/home/bonface/guix/pre-inst-env guix environment \
--no-grafts -C racket-hello-racket --ad-hoc strace gdb

source ./environment-variables

$GUIX_ENVIRONMENT/bin/raco pkg install --no-cache \
--no-setup --ignore-checksums

--8<---------------cut here---------------end--------------->8---

Which works just fine since I'm updating files
inside $GUIX_ENVIRONMENT. Right now I'm looking
for ideas to experiment with to try to overcome
this, and the low hanging fruit is to successfully
build a hello-racket package with zero deps and no
tests.

To simply put it, AFAIU updating a package would
require racket to update it's references(either
links, and other references that I won't go into),
hence creating some form of "global state";
thereby if you use raco, every package updated
would lead to some update with racket's search
paths or dirs somewhere. Any ideas to overcome
this wall? (or anything I've got wrong somewhere?)



[-- Attachment #1.2: /build/racket-build-system --]
[-- Type: text/plain, Size: 2438 bytes --]

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020 Bonface Munyoki Kilyungi <bonfacemunyoki@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix 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.
;;;
;;; GNU Guix 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 GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guix build racket-build-system)
  #:use-module ((guix build gnu-build-system) #:prefix gnu:)
  #:use-module (guix build union)
  #:use-module (guix build utils)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:export (%standard-phases
            racket-build))

;; Commentary:
;;
;; Builder-side code of the racket package build procedure.
;;
;; Code:

(define (racket-package? name)
  (string-prefix? "racket-" name))


;; Currently not working
(define* (check #:key tests? #:allow-other-keys)
  "Run tests for the racket package"
  (if tests?
      (invoke "raco" "test")
      (format #t "test suite not run~%"))
  #t)

(define (call-raco-pkg command params)
  (apply invoke "raco" "pkg" command params))

;; TODO: Find a work around to make this work without modifying where racket
;; store
(define* (install #:key outputs #:allow-other-keys)
  "Install the racket pkg"
  (let ((out (assoc-ref outputs "out")))
    (call-raco-pkg "install"
                   `("--no-cache" "--no-setup"
                     "--ignore-checksums" "--clone" ,(getcwd)))))

(define %standard-phases
  (modify-phases gnu:%standard-phases
    (delete 'bootstrap)
    (delete 'configure)
    (delete 'patch-generated-file-shebangs)
    (delete 'build)
    (replace 'install install)))


(define* (racket-build #:key inputs (phases %standard-phases)
                       #:allow-other-keys #:rest args)
  "Build the given racket package, applying all of PHASES in order."
  (apply gnu:gnu-build #:inputs inputs #:phases phases args))


[-- Attachment #1.3: build-system/racket.scm --]
[-- Type: text/plain, Size: 5047 bytes --]

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020 Bonface Munyoki Kilyungi <bonfacemunyoki@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix 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.
;;;
;;; GNU Guix 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 GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guix build-system racket)
  #:use-module (guix utils)
  #:use-module (guix derivations)
  #:use-module (guix search-paths)
  #:use-module (guix build-system)
  #:use-module (guix build-system gnu)
  #:use-module (guix packages)
  #:use-module (ice-9 match)
  #:export (%racket-build-system-modules
            racket-build
            racket-build-system))

;; Commentary:

;; Builder-side code of the standard Racket package build procedure
;;
;;
;; Background about the Racket Installation methods

(define %racket-build-system-modules
  ;; Build-side modules imported and used by default.
  `((guix build racket-build-system)
    (guix build union)
    ,@%gnu-build-system-modules))

(define (default-racket)
  (let ((scheme (resolve-interface '(gnu packages scheme))))
    (module-ref scheme 'racket-minimal)))

(define* (lower name
                #:key source inputs native-inputs outputs system target
                (racket (default-racket))
                #:allow-other-keys
                #:rest arguments)
  "Return a bag for NAME."
  (define private-keywords
    '(#:source #:target #:racket #:inputs #:native-inputs))

  (and (not target)
       (bag
         (name name)
         (system system)
         (host-inputs `(,@(if source
                              `(("source" ,source))
                              '())
                        ,@inputs
                        ;; Keep the standard inputs of 'gnu-build-system'.
                        ,@(standard-packages)))
         (build-inputs `(("racket" ,racket)
                         ,@native-inputs))
         (outputs outputs)
         (build racket-build)
         (arguments (strip-keyword-arguments private-keywords arguments)))))

(define* (racket-build store name inputs
                   #:key
                   (phases '(@ (guix build racket-build-system)
                               %standard-phases))
                   (outputs '("out"))
                   (search-paths '())
                   (unpack-path "")
                   (build-flags ''())
                   (tests? #t)
                   (system (%current-system))
                   (guile #f)
                   (imported-modules %racket-build-system-modules)
                   (modules '((guix build racket-build-system)
                              (guix build union)
                              (guix build utils))))
  (define builder
    `(begin
       (use-modules ,@modules)
       (racket-build #:name ,name
                 #:source ,(match (assoc-ref inputs "source")
                             (((? derivation? source))
                              (derivation->output-path source))
                             ((source)
                              source)
                             (source
                              source))
                 #:system ,system
                 #:phases ,phases
                 #:outputs %outputs
                 #:search-paths ',(map search-path-specification->sexp
                                       search-paths)
                 #:unpack-path ,unpack-path
                 #:build-flags ,build-flags
                 #:tests? ,tests?
                 #:inputs %build-inputs)))

  (define guile-for-build
    (match guile
      ((? package?)
       (package-derivation store guile system #:graft? #f))
      (#f                                         ; the default
       (let* ((distro (resolve-interface '(gnu packages commencement)))
              (guile  (module-ref distro 'guile-final)))
         (package-derivation store guile system
                             #:graft? #f)))))

  (build-expression->derivation store name builder
                                #:inputs inputs
                                #:system system
                                #:modules imported-modules
                                #:outputs outputs
                                #:guile-for-build guile-for-build))
(define racket-build-system
  (build-system
    (name 'racket)
    (description
     "Build system for Racket programs")
    (lower lower)))

[-- Attachment #1.4: Type: text/plain, Size: 213 bytes --]


-- 
Bonface M. K. <https://www.bonfacemunyoki.com>
Chief Emacs Bazu / Rieng ya software sare
Mchochezi of: <https://upbookclub.com> / Twitter: @BonfaceKilz
GPG Key: D4F09EB110177E03C28E2FE1F5BBAE1E0392253F

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 869 bytes --]

  parent reply	other threads:[~2020-11-09 20:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-17 18:42 Racket will move on top of Chez soon Christopher Lemmer Webber
2020-10-17 19:14 ` Pierre Neidhardt
2020-10-18 13:06 ` Bonface M. K.
2020-10-19  4:53   ` Racket packages / build system Christopher Lemmer Webber
2020-10-19 10:09     ` Bonface M. K.
2020-10-19 17:04       ` Christopher Lemmer Webber
2020-10-19 17:13         ` Dimos Dimakakos
2020-10-19 18:08         ` Bonface M. K.
2020-10-21  0:49           ` Christopher Lemmer Webber
2020-10-21 10:33           ` Ludovic Courtès
2020-10-21 12:59             ` Bonface M. K.
2021-01-28  3:03           ` Stephen Paul Weber
2020-11-09 20:54     ` Bonface M. K. [this message]
2020-11-09 21:21       ` Dimos Dimakakos
2020-11-09 22:51         ` Christopher Lemmer Webber
2020-11-10 12:07           ` Bonface M. K.
2020-11-10 17:37             ` Christopher Lemmer Webber
2020-11-11 10:53               ` Bonface M. K.
2020-11-10 12:30           ` Bonface M. K.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86blg6xncq.fsf@gmail.com \
    --to=bonfacemunyoki@gmail.com \
    --cc=cwebber@dustycloud.org \
    --cc=guix-devel@gnu.org \
    --cc=me@bendersteed.tech \
    --cc=pjotr2020@thebird.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).